mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Fix beefy mock ecdsa keys (#10854)
Compressed ECDSA keys requires to have 0x02 or 0x03 as their first byte in order to allow public key recovery. Nevertheless the test was working because of the `unwrap_or_default()` at the end of the conversion routine (i.e. the invalid keys were converted to an empty vector).
This commit is contained in:
@@ -158,9 +158,12 @@ impl pallet_session::SessionManager<u64> for MockSessionManager {
|
||||
|
||||
// Note, that we can't use `UintAuthorityId` here. Reason is that the implementation
|
||||
// of `to_public_key()` assumes, that a public key is 32 bytes long. This is true for
|
||||
// ed25519 and sr25519 but *not* for ecdsa. An ecdsa public key is 33 bytes.
|
||||
// ed25519 and sr25519 but *not* for ecdsa. A compressed ecdsa public key is 33 bytes,
|
||||
// with the first one containing information to reconstruct the uncompressed key.
|
||||
pub fn mock_beefy_id(id: u8) -> BeefyId {
|
||||
let buf: [u8; 33] = [id; 33];
|
||||
let mut buf: [u8; 33] = [id; 33];
|
||||
// Set to something valid.
|
||||
buf[0] = 0x02;
|
||||
let pk = Public::from_raw(buf);
|
||||
BeefyId::from(pk)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user