def test_ilp_keys(self, sk_ilp, vk_ilp): sk = SigningKey(sk_ilp['b58']) assert sk.encode(encoding='base64') == sk_ilp['b64'] assert binascii.hexlify( sk.encode(encoding='bytes')[:32]) == sk_ilp['hex'] vk = VerifyingKey(vk_ilp['b58']) assert vk.encode(encoding='base64') == vk_ilp['b64'] assert binascii.hexlify(vk.encode(encoding='bytes')) == vk_ilp['hex']
def test_to_bytes(self, sk_ilp, vk_ilp): sk = SigningKey(sk_ilp['b58']) assert sk.encode(encoding='base58') == sk_ilp['b58'] assert sk.encode(encoding='base64') == sk_ilp['b64'] vk = VerifyingKey(vk_ilp['b58']) assert vk.encode(encoding='base58') == vk_ilp['b58'] assert vk.encode(encoding='base64') == vk_ilp['b64']
# # # USq6mSPklezAirGcWi6ntfAlG2OhEobGhnNIstM6xH4UCZGX5KgXQemE4wLk0R6 # ################################################################################################################ import binascii import base58 import cryptoconditions as cc from cryptoconditions.crypto import Ed25519SigningKey as SigningKey message = 'Hello World! Conditions are here!' sk_b58 = base58.b58encode(binascii.unhexlify('833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42')) sk = SigningKey(sk_b58) ed25519_fulfillment = cc.Ed25519Sha256() ed25519_fulfillment.sign(message.encode(), base58.b58decode(sk.encode())) print(ed25519_fulfillment.condition_uri) # prints 'ni:///sha-256;U1YhFdW0lOI-SVF3PbDP4t_lVefj_-tB5P11yvfBaoE?fpt=ed25519-sha-256&cost=131072' print(ed25519_fulfillment.serialize_uri()) # prints 'pGSAIOwXK5OtXlY79JMscOEkUDTDVGfvLv1NZOv4GWg0Z-K_gUC2IpH62UMvjymLnEpIldvik_b_2hpo2t8Mze9fR6D' \ # 'HISpf6jzal6P0wD6p8uisHOyGpR1FISer26CdG28zHAcK' fulfillment_uri = 'pGSAIOwXK5OtXlY79JMscOEkUDTDVGfvLv1NZOv4GWg0Z-K_gUC2IpH62UMvjymLnEpIldvik_b_' \ '2hpo2t8Mze9fR6DHISpf6jzal6P0wD6p8uisHOyGpR1FISer26CdG28zHAcK' condition_uri = 'ni:///sha-256;U1YhFdW0lOI-SVF3PbDP4t_lVefj_-tB5P11yvfBaoE?fpt=ed25519-sha-256&cost=131072' fulfillment = cc.Fulfillment.from_uri(fulfillment_uri) result = fulfillment.validate(message = message.encode()) and condition_uri == fulfillment.condition_uri print(result)
def test_signing_key_decode(self, sk_ilp): sk = SigningKey(sk_ilp['b58']) private_value = sk.encode(encoding='base64') assert private_value == sk_ilp['b64']
def test_signing_key_init(self, sk_ilp): sk = SigningKey(sk_ilp['b58']) assert sk.encode(encoding='base64') == sk_ilp['b64'] assert sk.encode(encoding='bytes') == sk_ilp['byt']
def test_signing_key_encode(self, sk_ilp): sk = SigningKey(sk_ilp['b64'], encoding='base64') private_value_base58 = sk.encode(encoding="base58") assert private_value_base58 == sk_ilp['b58']
def test_generate_key_pair(self): sk_b58, vk_b58 = ed25519_generate_key_pair() assert len(base58.b58decode(sk_b58)) == 32 assert len(base58.b58decode(vk_b58)) == 32 assert SigningKey.encode(SigningKey.decode(sk_b58)) == sk_b58 assert VerifyingKey.encode(VerifyingKey.decode(vk_b58)) == vk_b58
def test_signing_key_encode(self, sk_ilp): private_value_base58 = SigningKey.encode(base64_add_padding(sk_ilp['b64'])) assert private_value_base58 == sk_ilp['b58']