def verify_key(self): """ Return the corresponding :py:class:`.VerifyKey` object. :rtype: :py:class:`.VerifyKey` """ return VerifyKey(crypto_sign_public_key(self._sk))
def test_crypto_sign_bytes_like(msg): sk = bytes(32) pk = crypto_sign_public_key(sk) for wrapper in [bytes, memoryview, bytearray]: sig = crypto_sign(sk, wrapper(msg)) assert sig == crypto_sign(sk, msg) assert crypto_check(sig, pk, wrapper(msg))
def test_crypto_convert(sk): x25519_sk = crypto_from_eddsa_private(sk) x25519_pk = crypto_x25519_public_key(x25519_sk) pk = crypto_sign_public_key(sk) assert crypto_from_eddsa_public(pk) == x25519_pk
def test_crypto_sign_sk(sk, message, fake_sk): sig = crypto_sign(sk, message) if sk != fake_sk: fake_pk = crypto_sign_public_key(fake_sk) assert not crypto_check(sig, fake_pk, message)
def test_crypto_sign_workflow(sk, message, fake_sig): pk = crypto_sign_public_key(sk) sig = crypto_sign(sk, message) assert crypto_check(sig, pk, message) if fake_sig != sig: assert not crypto_check(fake_sig, pk, message)