Skip to content

Commit 59665cc

Browse files
committed
testnet adaptions
1 parent bdbac79 commit 59665cc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

coti/crypto_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ def decrypt_rsa(private_key_bytes, ciphertext):
206206
)
207207
return plaintext
208208

209+
#This function recovers a user's key by decrypting two encrypted key shares with the given private key,
210+
#and then XORing the two key shares together.
211+
def recover_user_key(private_key_bytes, encrypted_key_share0, encrypted_key_share1):
212+
key_share0 = decrypt_rsa(private_key_bytes, encrypted_key_share0)
213+
key_share1 = decrypt_rsa(private_key_bytes, encrypted_key_share1)
214+
215+
# XOR both key shares to get the user key
216+
return bytes([a ^ b for a, b in zip(key_share0, key_share1)])
217+
209218

210219
# Function to compute Keccak-256 hash
211220
def keccak256(data):

0 commit comments

Comments
 (0)