Adds _eq_ method to EncryptedBlob

This commit is contained in:
Sergi Delgado Segura
2019-10-09 15:19:03 +01:00
parent f59c621cc0
commit ecadbc62ef

View File

@@ -5,12 +5,15 @@ from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from pisa import logging from pisa import logging
# FIXME: EncryptedBlob is assuming AESGCM. A cipher field should be part of the object and the decryption should be # FIXME: EncryptedBlob is assuming AES-128-GCM. A cipher field should be part of the object and the decryption should be
# performed depending on the cipher. # performed depending on the cipher.
class EncryptedBlob: class EncryptedBlob:
def __init__(self, data): def __init__(self, data):
self.data = data self.data = data
def __eq__(self, other):
return isinstance(other, EncryptedBlob) and self.data == other.data
def decrypt(self, key): def decrypt(self, key):
# master_key = H(tx_id | tx_id) # master_key = H(tx_id | tx_id)
key = unhexlify(key) key = unhexlify(key)