The current implementation of Crypto.ecverify_secp256k1(msg: hash, pk: bytes(64), sig: bytes(64)): bool
that Sophia now natively supports can be used to verify a signed message.
TLDR;
From what I see in the code it only supports secp256k1 DER encoded messages (which bitcoin uses).
Are there any plans on supporting RLP encoded secp256k1 signed messages (this is what ethereum uses)? - It will ease lots of transitioning and interoperability between decentralized applications.
Some more context:
Although Ethereum similar to Bitcoin uses secp256k1 curve, ethereum message signatures are RLP encoded whereas Bitcoin message signatures are DER encoded.
The difference is that in RLP encoded signature there are three values present: R,S, and v
, the last one v
allowing public key recovery from the signature, whereas bitcoin’s DER encoding signature contains only R
and S
.
So, the current Sophia Crypto.ecverify_secp256k1(msg: hash, pk: bytes(64), sig: bytes(64)) : bool
implementation is not allowing us to make Ethereum signed messages verification as the ethereum rlp encoded message signature is 65 bytes
long with the additional parameter - longer than the function is expecting (as can be seen here aeternity/aefa_fate_op.erl at master · aeternity/aeternity · GitHub).
Taking a look at the crypto helper functions in aeternity core repo here: aeternity/aeu_crypto.erl at master · aeternity/aeternity · GitHub we can see that there is only der
encoding supported currently, so the signature length is not the only stop.
A bit of info for developers trying to verify ethereum signed messages into Sophia smart contracts:
- There is the possibility of conversion the RLP encoded signature to DER (theoretically possible, but I personally haven’t found any reliable info how to do so easily) and then feed it to the smart contract for verification.
I would have submitted a PR with the proposal otherwise, but I’m not an expert into cryptography, so that is why I’m posting this here, to start a discussion and bring more attention to this.
I would love to help with the efforts to support secp256k1 RLP encoded signature verification in Sophia as it would be very handy for developers later on.
Some helpers: