Ensure that pubkey has the correct length and structure.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
3e77a9a158
commit
fe10d3d47c
|
@ -33,6 +33,8 @@ def main():
|
||||||
privkey = ec.derive_private_key(int.from_bytes(rand.b(32), 'little'), ec.SECP256K1())
|
privkey = ec.derive_private_key(int.from_bytes(rand.b(32), 'little'), ec.SECP256K1())
|
||||||
pubkey = privkey.public_key()
|
pubkey = privkey.public_key()
|
||||||
pubkey_bytes = pubkey.public_bytes(Encoding.X962, PublicFormat.CompressedPoint)
|
pubkey_bytes = pubkey.public_bytes(Encoding.X962, PublicFormat.CompressedPoint)
|
||||||
|
assert len(pubkey_bytes) == 33
|
||||||
|
assert pubkey_bytes[0] in (0x02, 0x03)
|
||||||
t_key_bytes = c + pubkey_bytes
|
t_key_bytes = c + pubkey_bytes
|
||||||
else:
|
else:
|
||||||
t_key_bytes = None
|
t_key_bytes = None
|
||||||
|
|
Loading…
Reference in New Issue