From 59665ccd66e526b8864b372d2bd690671a49a034 Mon Sep 17 00:00:00 2001 From: eitanz Date: Thu, 12 Sep 2024 16:03:38 +0300 Subject: [PATCH] testnet adaptions --- coti/crypto_utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/coti/crypto_utils.py b/coti/crypto_utils.py index 804d2ce..2ba055a 100644 --- a/coti/crypto_utils.py +++ b/coti/crypto_utils.py @@ -206,6 +206,15 @@ def decrypt_rsa(private_key_bytes, ciphertext): ) return plaintext +#This function recovers a user's key by decrypting two encrypted key shares with the given private key, +#and then XORing the two key shares together. +def recover_user_key(private_key_bytes, encrypted_key_share0, encrypted_key_share1): + key_share0 = decrypt_rsa(private_key_bytes, encrypted_key_share0) + key_share1 = decrypt_rsa(private_key_bytes, encrypted_key_share1) + + # XOR both key shares to get the user key + return bytes([a ^ b for a, b in zip(key_share0, key_share1)]) + # Function to compute Keccak-256 hash def keccak256(data):