Ensure that pubkey has the correct length and structure.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Kris Nuttycombe 2021-12-10 12:25:45 -07:00 committed by GitHub
parent 3e77a9a158
commit fe10d3d47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -33,6 +33,8 @@ def main():
privkey = ec.derive_private_key(int.from_bytes(rand.b(32), 'little'), ec.SECP256K1())
pubkey = privkey.public_key()
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
else:
t_key_bytes = None