mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Changes derypt key input type and return
The input types for Blob.encrypt and EncryptedBlob.decrypt were not consistent. The former was in hex whereas the later was in bytes. Format the later in hex for consistency.
This commit is contained in:
@@ -64,8 +64,7 @@ class BlockProcessor:
|
||||
for uuid in locator_uuid_map[locator]:
|
||||
try:
|
||||
# ToDo: #20-test-tx-decrypting-edge-cases
|
||||
justice_rawtx = appointments[uuid].encrypted_blob.decrypt(binascii.unhexlify(dispute_txid))
|
||||
justice_rawtx = binascii.hexlify(justice_rawtx).decode()
|
||||
justice_rawtx = appointments[uuid].encrypted_blob.decrypt(dispute_txid)
|
||||
justice_txid = bitcoin_cli.decoderawtransaction(justice_rawtx).get('txid')
|
||||
matches.append((locator, uuid, dispute_txid, justice_txid, justice_rawtx))
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class EncryptedBlob:
|
||||
|
||||
def decrypt(self, key):
|
||||
# master_key = H(tx_id | tx_id)
|
||||
key = unhexlify(key)
|
||||
master_key = sha256(key + key).digest()
|
||||
|
||||
# The 16 MSB of the master key will serve as the AES GCM 128 secret key. The 16 LSB will serve as the IV.
|
||||
@@ -27,5 +28,6 @@ class EncryptedBlob:
|
||||
aesgcm = AESGCM(sk)
|
||||
data = unhexlify(self.data.encode())
|
||||
raw_tx = aesgcm.decrypt(nonce=nonce, data=data, associated_data=None)
|
||||
hex_raw_tx = hexlify(raw_tx).decode('utf8')
|
||||
|
||||
return raw_tx
|
||||
return hex_raw_tx
|
||||
|
||||
Reference in New Issue
Block a user