-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Make MultiSigner use compressed ECDSA public key
#4502
Conversation
primitives/runtime/src/lib.rs
Outdated
| MultiSigner::Sr25519(who) => <[u8; 32]>::from(who).into(), | ||
| MultiSigner::Ecdsa(who) => sp_io::hashing::blake2_256(who.as_ref()).into(), | ||
| MultiSigner::Ecdsa(who) => sp_io::hashing::blake2_256( | ||
| &who.as_compressed().expect("what should we do?")[..], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavofyork what should we do here? I think the best would be to propagate the error via IdentifyAccount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe this cannot fail for any valid keypair, so .expect should be fine
MultiSigner
MultiSigner MultiSigner use compressed ECDSA public key
|
but... what's the point of supporting uncompressed public key format? |
Good question, I just followed the initial implementation. However, I think that for ergonomic reasons the support for both sounds reasonable to me. If you say that people only use the compressed version, I can remove the support for full public keys. |
|
it does leave this annoying |
Some fixes after: #4502 This removes the unwanted `expect`s from `MultiSigner`. Instead we convert from full to compressed in `TryFrom` and can return an error on invalid input.
Some fixes after: #4502 This removes the unwanted `expect`s from `MultiSigner`. Instead we convert from full to compressed in `TryFrom` and can return an error on invalid input.
MultiSignerdid not compressed the ECDSA public key before hashing it butMultiSignatureexpected that the public key is compressed when verifying a signature. Thus, the signature verification could never succeed.This pr changes the following:
MultiSignercompresses the public key before hashing it withblake256.Verify for ecdsa::Signaturecompresses given public key before comparing it.ecdsa::Publicis now an enum that distinguishes between the full and compressed format.Fixes: #4498