Substrate supports multiple signature schemes: ecdsa, sr2551, ed25519. When sending a signed transaction how does substrate know what scheme to use for signature verification?
1 Answer
It is a SCALE-encoded MultiSignature
enum. so in SCALE encoding the first byte tells you which variant the value is. So you will notice that ed25519 signatures always start with 0x00, sr25519 with 0x01, and ecdsa with 0x02.
So in a fully serialized transaction, the "signature" is actually 0x <scheme> + <signature>
.
-
Do you know where in the code base encoded bytes are decoded to MultiSignature based on the scheme type?– ShunsukeMar 13 at 8:22