Open max-l opened 4 years ago
from nacl.encoding import HexEncoder from nacl.signing import SigningKey
signing_key = SigningKey.generate()
signed_hex = signing_key.sign(b"Attack at Dawn", encoder=HexEncoder)
verify_key = signing_key.verify_key
verify_key_hex = verify_key.encode(encoder=HexEncoder)
verify_key = VerifyKey(verify_key_hex, encoder=HexEncoder)
verify_key.verify(signed_hex.signature, signed_hex.message, encoder=HexEncoder)
forged = signed_hex[:-1] + bytes([int(signed_hex[-1]) ^ 1])
verify_key.verify(forged)
I get an encoding/decoding error when running this example without changes:
https://pynacl.readthedocs.io/en/latest/signing/#id1
The version of python is 3.7.4
The stack trace is:
The code is :