-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from zama-ai/feat/support-64bits-reencrypt
Feat/support 64bits reencrypt
- Loading branch information
Showing
8 changed files
with
390 additions
and
220 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import sodium from 'libsodium-wrappers'; | ||
import { bytesToNumber, fromHexString } from '../utils'; | ||
import { bytesToBigInt, fromHexString } from '../utils'; | ||
import { ContractKeypair } from './types'; | ||
|
||
export const decrypt = ( | ||
keypair: ContractKeypair, | ||
ciphertext: string | Uint8Array, | ||
): number => { | ||
): bigint => { | ||
const toDecrypt = | ||
typeof ciphertext === 'string' ? fromHexString(ciphertext) : ciphertext; | ||
const decrypted = sodium.crypto_box_seal_open( | ||
toDecrypt, | ||
keypair.publicKey, | ||
keypair.privateKey, | ||
); | ||
return bytesToNumber(decrypted); | ||
return bytesToBigInt(decrypted); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters