def test_signature_hash(self):
        data = bytearray("test".encode())
        crypto = VirgilCrypto()
        key_pair = crypto.generate_key_pair()
        signature = crypto.generate_signature(data, key_pair.private_key)

        self.assertEqual(signature[:17],
                         bytearray(b64decode("MFEwDQYJYIZIAWUDBAIDBQA=")))
    def test_signature_hash(self):
        # STC-30
        crypto = VirgilCrypto()
        key_pair = crypto.generate_key_pair()
        test_data = bytearray("test".encode())
        signature = crypto.generate_signature(test_data, key_pair.private_key)

        self.assertEqual(bytearray(signature[0:17]),
                         b64decode("MFEwDQYJYIZIAWUDBAIDBQA="))
Ejemplo n.º 3
0
# Create public/private keys for the sender. Default algorithm is EC_X25519
sender_keys = crypto.generate_key_pair()
sender_public_key = sender_keys.public_key
sender_private_key = sender_keys.private_key

# Middleman Keys
middleman_keys = crypto.generate_key_pair()
middleman_private_key = middleman_keys.private_key

# Create data that we want to verify between the two clients. This data won't be sent yet, just for signature validation purposes.
message = "Hey Deren! My location is lat=42.361145,long=-71.057083"
message_data = message.encode()

# Sign the message data with the senders private key.
signature = crypto.generate_signature(message_data, sender_private_key)

# Middleman signature
middleman_signature = crypto.generate_signature(message_data,
                                                middleman_private_key)

# Verify if the message can be decoded with the given public key : "sender_public_key"
verification = crypto.verify_signature(message_data, signature,
                                       sender_public_key)

# Middleman unverified signature
unverification = crypto.verify_signature(message_data, middleman_signature,
                                         sender_public_key)

print(verification)
print(unverification)