Skip to content

Commit

Permalink
Merge pull request #104 from zama-ai/decryt-ebytes
Browse files Browse the repository at this point in the history
feat: add decrypt for type up to 2048bits
  • Loading branch information
immortal-tofu authored Oct 18, 2024
2 parents 6320632 + 35615c5 commit 67f5090
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
FheUint16,
FheUint32,
FheUint64,
FheUint128,
FheUint160,
FheUint256,
FheUint512,
FheUint1024,
FheUint2048,
TfheClientKey,
} from 'node-tfhe';

Expand Down Expand Up @@ -91,6 +96,11 @@ export const clientKeyDecryptor = (clientKeySer: Uint8Array) => {
fromHexString(ciphertext),
SERIALIZED_SIZE_LIMIT_CIPHERTEXT,
).decrypt(clientKey),
decrypt128: (ciphertext: string) =>
FheUint128.safe_deserialize(
fromHexString(ciphertext),
SERIALIZED_SIZE_LIMIT_CIPHERTEXT,
).decrypt(clientKey),
decryptAddress: (ciphertext: string) => {
let hex = FheUint160.safe_deserialize(
fromHexString(ciphertext),
Expand All @@ -103,6 +113,26 @@ export const clientKeyDecryptor = (clientKeySer: Uint8Array) => {
}
return '0x' + hex;
},
decrypt256: (ciphertext: string) =>
FheUint256.safe_deserialize(
fromHexString(ciphertext),
SERIALIZED_SIZE_LIMIT_CIPHERTEXT,
).decrypt(clientKey),
decryptEbytes64: (ciphertext: string) =>
FheUint512.safe_deserialize(
fromHexString(ciphertext),
SERIALIZED_SIZE_LIMIT_CIPHERTEXT,
).decrypt(clientKey),
decryptEbytes128: (ciphertext: string) =>
FheUint1024.safe_deserialize(
fromHexString(ciphertext),
SERIALIZED_SIZE_LIMIT_CIPHERTEXT,
).decrypt(clientKey),
decryptEbytes256: (ciphertext: string) =>
FheUint2048.safe_deserialize(
fromHexString(ciphertext),
SERIALIZED_SIZE_LIMIT_CIPHERTEXT,
).decrypt(clientKey),
};
};

Expand Down

0 comments on commit 67f5090

Please sign in to comment.