mirror of
https://github.com/plume-sig/zk-nullifier-sig.git
synced 2026-05-08 03:00:15 -04:00
* chore: clean up - [x] Add checks for ci actions - [x] Run prettier, clippy, fmt commands for all the files - [x] Move circom circuits to a circom folder - [x] Get rid of js var statements * chore: add resolver version for cargo.toml * chore: add circom tests * chore: optimize check triggers * chore: remove `check` command * chore: use only `pnpm` * chore: update readme --------- Co-authored-by: 0xmad <0xmad@users.noreply.github.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import {
|
|
hexToBigInt,
|
|
hexToUint8Array,
|
|
uint8ArrayToBigInt,
|
|
uint8ArrayToHex,
|
|
} from "../src/utils/encoding";
|
|
|
|
const TEST_VALS = [
|
|
{
|
|
hex: "a413bc5f",
|
|
uint8: Uint8Array.from([164, 19, 188, 95]),
|
|
bigint: 2752756831n,
|
|
},
|
|
{
|
|
hex: "f09f8fb3efb88fe2808df09f8c88",
|
|
uint8: Uint8Array.from([
|
|
240, 159, 143, 179, 239, 184, 143, 226, 128, 141, 240, 159, 140, 136,
|
|
]),
|
|
bigint: 4880420056602345253094210752449672n,
|
|
},
|
|
];
|
|
|
|
describe("encoding", () => {
|
|
it("hexToUint8Array", () => {
|
|
expect(hexToUint8Array(TEST_VALS[0].hex)).toEqual(TEST_VALS[0].uint8);
|
|
expect(hexToUint8Array(TEST_VALS[1].hex)).toEqual(TEST_VALS[1].uint8);
|
|
});
|
|
|
|
it("uint8ArrayToHex", () => {
|
|
expect(uint8ArrayToHex(TEST_VALS[0].uint8)).toEqual(TEST_VALS[0].hex);
|
|
expect(uint8ArrayToHex(TEST_VALS[1].uint8)).toEqual(TEST_VALS[1].hex);
|
|
});
|
|
|
|
it("hexToBigInt", () => {
|
|
expect(hexToBigInt(TEST_VALS[0].hex)).toEqual(TEST_VALS[0].bigint);
|
|
expect(hexToBigInt(TEST_VALS[1].hex)).toEqual(TEST_VALS[1].bigint);
|
|
});
|
|
|
|
it("uint8ArrayToBigInt", () => {
|
|
expect(uint8ArrayToBigInt(TEST_VALS[0].uint8)).toEqual(TEST_VALS[0].bigint);
|
|
expect(uint8ArrayToBigInt(TEST_VALS[1].uint8)).toEqual(TEST_VALS[1].bigint);
|
|
});
|
|
});
|