Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testnet #12

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions coti/crypto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading