-
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 #59 from zama-ai/decryptAddress
feat: add decryptAddress
- Loading branch information
Showing
6 changed files
with
188 additions
and
34 deletions.
There are no files selected for viewing
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
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,23 +1,27 @@ | ||
import { numberToBytes, bytesToBigInt } from './utils'; | ||
import { bigIntToBytes, bytesToBigInt } from './utils'; | ||
|
||
describe('decrypt', () => { | ||
it('converts a number to bytes', async () => { | ||
const value = 28482; | ||
const bytes = numberToBytes(value); | ||
const value = BigInt(28482); | ||
const bytes = bigIntToBytes(value); | ||
expect(bytes).toEqual(new Uint8Array([111, 66])); | ||
|
||
const value2 = 255; | ||
const bytes2 = numberToBytes(value2); | ||
const value2 = BigInt(255); | ||
const bytes2 = bigIntToBytes(value2); | ||
expect(bytes2).toEqual(new Uint8Array([255])); | ||
}); | ||
|
||
it('converts bytes to number', async () => { | ||
const value = new Uint8Array([23, 200, 15]); | ||
const bytes = bytesToBigInt(value); | ||
expect(bytes.toString()).toBe('1558543'); | ||
const bigint1 = bytesToBigInt(value); | ||
expect(bigint1.toString()).toBe('1558543'); | ||
|
||
const value2 = new Uint8Array(); | ||
const bytes2 = bytesToBigInt(value2); | ||
expect(bytes2.toString()).toBe('0'); | ||
const value2 = new Uint8Array([37, 6, 210, 166, 239]); | ||
const bigint2 = bytesToBigInt(value2); | ||
expect(bigint2.toString()).toBe('159028258543'); | ||
|
||
const value0 = new Uint8Array(); | ||
const bigint0 = bytesToBigInt(value0); | ||
expect(bigint0.toString()).toBe('0'); | ||
}); | ||
}); |
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