def test_verify(): message = b"deadbeef" public_key, private_key = generate() signature = sign(message, public_key, private_key) assert verify(message, signature, public_key) assert type(verify(message, signature, public_key)) is bool assert verify(message + b'dummy', signature, public_key) is False
def test_sign(): message = b"deadbeef" public_key, private_key = generate() signature = sign(message, public_key, private_key) print(b64decode(signature)) assert len(b64decode(signature)) == 64 for _ in range(1000): assert signature == sign(message, public_key, private_key)
def test_generate(): public_key, private_key = generate() assert len(b64decode(public_key)) == 32 assert len(b64decode(private_key)) == 32 print(b64decode(public_key)) print(b64decode(private_key))
def test_derive_public_key(): public_key, private_key = generate() for _ in range(1000): assert derive_public_key(private_key) == public_key
def generate_keypair_ed25519(): # Mind the private/public key order! public_key, private_key = ed25519.generate() return KeyPair(public_key, private_key)