mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Cryptographer.sigrec_decode assumed signatures where properly encoded.
- Fixes a bug in sigrec_decode where the decoding function assumend that the first by was formatted as 31 + SigRec. Non properly encoded signatures made the function to crash due to an overflow (int_to_bytes(x) for negative x)
This commit is contained in:
@@ -208,6 +208,15 @@ def test_recover_pk():
|
||||
assert isinstance(rpk, PublicKey)
|
||||
|
||||
|
||||
def test_recover_pk_invalid_sigrec():
|
||||
message = "Hey, it's me"
|
||||
signature = "ddbfb019e4d56155b4175066c2b615ab765d317ae7996d188b4a5fae4cc394adf98fef46034d0553149392219ca6d37dca9abdfa6366a8e54b28f19d3e5efa8a14b556205dc7f33a"
|
||||
|
||||
# The given signature, when zbase32 decoded, has a fist byte with value lower than 31.
|
||||
# The first byte of the signature should be 31 + SigRec, so this should fail
|
||||
assert Cryptographer.recover_pk(message, signature) is None
|
||||
|
||||
|
||||
def test_recover_pk_ground_truth():
|
||||
# Use a message a signature generated by c-lightning and see if we recover the proper key
|
||||
message = b"Test message"
|
||||
|
||||
Reference in New Issue
Block a user