diff --git a/package.json b/package.json index 6d68a7bc4..e34b6539c 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,13 @@ "@commitlint/cli": "^16.0.2", "@commitlint/config-conventional": "^16.0.0", "@rollup/plugin-typescript": "^8.3.0", + "@types/circomlibjs": "^0.1.1", "@types/download": "^8.0.1", "@types/glob": "^7.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.9", "@types/rimraf": "^3.0.2", + "@types/snarkjs": "^0.7.2", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "babel-jest": "^27.4.6", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 263091734..783d8027e 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -30,7 +30,7 @@ "@types/rimraf": "^3.0.2", "chai": "^4.3.5", "circomlib": "^2.0.2", - "circomlibjs": "^0.0.8", + "circomlibjs": "^0.1.7", "download": "^8.0.0", "ethers": "^5.6.8", "hardhat": "^2.9.7", diff --git a/packages/contracts/tasks/deploy-semaphore-voting.ts b/packages/contracts/tasks/deploy-semaphore-voting.ts index 10d06f365..249af9fe3 100644 --- a/packages/contracts/tasks/deploy-semaphore-voting.ts +++ b/packages/contracts/tasks/deploy-semaphore-voting.ts @@ -1,4 +1,4 @@ -import { poseidon_gencontract as poseidonContract } from "circomlibjs" +import { poseidonContract } from "circomlibjs" import { task, types } from "hardhat/config" task("deploy:semaphore-voting", "Deploy a SemaphoreVoting contract") diff --git a/packages/contracts/tasks/deploy-semaphore-whistleblowing.ts b/packages/contracts/tasks/deploy-semaphore-whistleblowing.ts index 795d23155..f16cc6dc1 100644 --- a/packages/contracts/tasks/deploy-semaphore-whistleblowing.ts +++ b/packages/contracts/tasks/deploy-semaphore-whistleblowing.ts @@ -1,4 +1,4 @@ -import { poseidon_gencontract as poseidonContract } from "circomlibjs" +import { poseidonContract } from "circomlibjs" import { task, types } from "hardhat/config" task("deploy:semaphore-whistleblowing", "Deploy a SemaphoreWhistleblowing contract") diff --git a/packages/contracts/tasks/deploy-semaphore.ts b/packages/contracts/tasks/deploy-semaphore.ts index 08597fcd0..bdcb0ee59 100644 --- a/packages/contracts/tasks/deploy-semaphore.ts +++ b/packages/contracts/tasks/deploy-semaphore.ts @@ -1,4 +1,4 @@ -import { poseidon_gencontract as poseidonContract } from "circomlibjs" +import { poseidonContract } from "circomlibjs" import { task, types } from "hardhat/config" import { saveDeployedContracts } from "../scripts/utils" diff --git a/packages/hardhat/src/tasks/deploy-semaphore.ts b/packages/hardhat/src/tasks/deploy-semaphore.ts index 6ede1501c..1646ae7de 100644 --- a/packages/hardhat/src/tasks/deploy-semaphore.ts +++ b/packages/hardhat/src/tasks/deploy-semaphore.ts @@ -1,4 +1,4 @@ -import { poseidon_gencontract as poseidonContract } from "circomlibjs" +import { poseidonContract } from "circomlibjs" import { task, types } from "hardhat/config" task("deploy:semaphore", "Deploy a Semaphore contract") diff --git a/packages/proof/src/generateProof.ts b/packages/proof/src/generateProof.ts index f82dc6f44..78f57b9cf 100644 --- a/packages/proof/src/generateProof.ts +++ b/packages/proof/src/generateProof.ts @@ -3,10 +3,10 @@ import { BytesLike, Hexable } from "@ethersproject/bytes" import { Group } from "@semaphore-protocol/group" import type { Identity } from "@semaphore-protocol/identity" import { MerkleProof } from "@zk-kit/incremental-merkle-tree" -import { groth16 } from "snarkjs" +import { groth16, NumericString } from "snarkjs" import hash from "./hash" import packProof from "./packProof" -import { FullProof, SnarkArtifacts } from "./types" +import { SemaphoreProof, SnarkArtifacts } from "./types" /** * Generates a Semaphore proof. @@ -23,7 +23,7 @@ export default async function generateProof( externalNullifier: BytesLike | Hexable | number | bigint, signal: BytesLike | Hexable | number | bigint, snarkArtifacts?: SnarkArtifacts -): Promise { +): Promise { let merkleProof: MerkleProof if ("depth" in groupOrMerkleProof) { @@ -61,8 +61,8 @@ export default async function generateProof( return { merkleTreeRoot: publicSignals[0], nullifierHash: publicSignals[1], - signal: BigNumber.from(signal).toString(), - externalNullifier: BigNumber.from(externalNullifier).toString(), + signal: BigNumber.from(signal).toString() as NumericString, + externalNullifier: BigNumber.from(externalNullifier).toString() as NumericString, proof: packProof(proof) } } diff --git a/packages/proof/src/hash.ts b/packages/proof/src/hash.ts index c950f7825..328b3ef52 100644 --- a/packages/proof/src/hash.ts +++ b/packages/proof/src/hash.ts @@ -1,15 +1,16 @@ import { BigNumber } from "@ethersproject/bignumber" import { BytesLike, Hexable, zeroPad } from "@ethersproject/bytes" import { keccak256 } from "@ethersproject/keccak256" +import { NumericString } from "snarkjs" /** * Creates a keccak256 hash of a message compatible with the SNARK scalar modulus. * @param message The message to be hashed. * @returns The message digest. */ -export default function hash(message: BytesLike | Hexable | number | bigint): bigint { +export default function hash(message: BytesLike | Hexable | number | bigint): NumericString { message = BigNumber.from(message).toTwos(256).toHexString() message = zeroPad(message, 32) - return BigInt(keccak256(message)) >> BigInt(8) + return (BigInt(keccak256(message)) >> BigInt(8)).toString() as NumericString } diff --git a/packages/proof/src/index.test.ts b/packages/proof/src/index.test.ts index 249ed4510..420a45bec 100644 --- a/packages/proof/src/index.test.ts +++ b/packages/proof/src/index.test.ts @@ -6,7 +6,7 @@ import calculateNullifierHash from "./calculateNullifierHash" import generateProof from "./generateProof" import hash from "./hash" import packProof from "./packProof" -import { FullProof } from "./types" +import { SemaphoreProof } from "./types" import unpackProof from "./unpackProof" import verifyProof from "./verifyProof" @@ -21,7 +21,7 @@ describe("Proof", () => { const identity = new Identity() - let fullProof: FullProof + let fullProof: SemaphoreProof let curve: any beforeAll(async () => { @@ -34,9 +34,7 @@ describe("Proof", () => { describe("# generateProof", () => { it("Should not generate Semaphore proofs if the identity is not part of the group", async () => { - const group = new Group(treeDepth) - - group.addMembers([BigInt(1), BigInt(2)]) + const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2)]) const fun = () => generateProof(identity, group, externalNullifier, signal, { @@ -48,9 +46,7 @@ describe("Proof", () => { }) it("Should not generate a Semaphore proof with default snark artifacts with Node.js", async () => { - const group = new Group(treeDepth) - - group.addMembers([BigInt(1), BigInt(2), identity.commitment]) + const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2), identity.commitment]) const fun = () => generateProof(identity, group, externalNullifier, signal) @@ -58,9 +54,7 @@ describe("Proof", () => { }) it("Should generate a Semaphore proof passing a group as parameter", async () => { - const group = new Group(treeDepth) - - group.addMembers([BigInt(1), BigInt(2), identity.commitment]) + const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2), identity.commitment]) fullProof = await generateProof(identity, group, externalNullifier, signal, { wasmFilePath, @@ -72,9 +66,7 @@ describe("Proof", () => { }, 20000) it("Should generate a Semaphore proof passing a Merkle proof as parameter", async () => { - const group = new Group(treeDepth) - - group.addMembers([BigInt(1), BigInt(2), identity.commitment]) + const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2), identity.commitment]) fullProof = await generateProof(identity, group.generateMerkleProof(2), externalNullifier, signal, { wasmFilePath, @@ -104,47 +96,35 @@ describe("Proof", () => { it("Should hash the signal value correctly", async () => { const signalHash = hash(signal) - expect(signalHash.toString()).toBe( - "8665846418922331996225934941481656421248110469944536651334918563951783029" - ) + expect(signalHash).toBe("8665846418922331996225934941481656421248110469944536651334918563951783029") }) it("Should hash the external nullifier value correctly", async () => { const externalNullifierHash = hash(externalNullifier) - expect(externalNullifierHash.toString()).toBe( + expect(externalNullifierHash).toBe( "244178201824278269437519042830883072613014992408751798420801126401127326826" ) }) it("Should hash a number", async () => { - expect(hash(2).toString()).toBe( - "113682330006535319932160121224458771213356533826860247409332700812532759386" - ) + expect(hash(2)).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386") }) it("Should hash a big number", async () => { - expect(hash(BigInt(2)).toString()).toBe( - "113682330006535319932160121224458771213356533826860247409332700812532759386" - ) + expect(hash(BigInt(2))).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386") }) it("Should hash an hex number", async () => { - expect(hash("0x2").toString()).toBe( - "113682330006535319932160121224458771213356533826860247409332700812532759386" - ) + expect(hash("0x2")).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386") }) it("Should hash an string number", async () => { - expect(hash("2").toString()).toBe( - "113682330006535319932160121224458771213356533826860247409332700812532759386" - ) + expect(hash("2")).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386") }) it("Should hash an array", async () => { - expect(hash([2]).toString()).toBe( - "113682330006535319932160121224458771213356533826860247409332700812532759386" - ) + expect(hash([2])).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386") }) }) diff --git a/packages/proof/src/packProof.ts b/packages/proof/src/packProof.ts index d1c73f369..6677eaeab 100644 --- a/packages/proof/src/packProof.ts +++ b/packages/proof/src/packProof.ts @@ -1,19 +1,20 @@ -import { SnarkJSProof, Proof } from "./types" +import { Groth16Proof } from "snarkjs" +import { PackedProof } from "./types" /** * Packs a proof into a format compatible with Semaphore. - * @param originalProof The proof generated with SnarkJS. + * @param proof The Groth16 proof generated with SnarkJS. * @returns The proof compatible with Semaphore. */ -export default function packProof(originalProof: SnarkJSProof): Proof { +export default function packProof(proof: Groth16Proof): PackedProof { return [ - originalProof.pi_a[0], - originalProof.pi_a[1], - originalProof.pi_b[0][1], - originalProof.pi_b[0][0], - originalProof.pi_b[1][1], - originalProof.pi_b[1][0], - originalProof.pi_c[0], - originalProof.pi_c[1] + proof.pi_a[0], + proof.pi_a[1], + proof.pi_b[0][1], + proof.pi_b[0][0], + proof.pi_b[1][1], + proof.pi_b[1][0], + proof.pi_c[0], + proof.pi_c[1] ] } diff --git a/packages/proof/src/types/index.ts b/packages/proof/src/types/index.ts index f47159d0e..20fba3800 100644 --- a/packages/proof/src/types/index.ts +++ b/packages/proof/src/types/index.ts @@ -1,33 +1,25 @@ -export type BigNumberish = string | bigint +export type NumericString = `${number}` export type SnarkArtifacts = { wasmFilePath: string zkeyFilePath: string } -export type SnarkJSProof = { - pi_a: BigNumberish[] - pi_b: BigNumberish[][] - pi_c: BigNumberish[] - protocol: string - curve: string +export type SemaphoreProof = { + merkleTreeRoot: NumericString + signal: NumericString + nullifierHash: NumericString + externalNullifier: NumericString + proof: PackedProof } -export type FullProof = { - merkleTreeRoot: BigNumberish - signal: BigNumberish - nullifierHash: BigNumberish - externalNullifier: BigNumberish - proof: Proof -} - -export type Proof = [ - BigNumberish, - BigNumberish, - BigNumberish, - BigNumberish, - BigNumberish, - BigNumberish, - BigNumberish, - BigNumberish +export type PackedProof = [ + NumericString, + NumericString, + NumericString, + NumericString, + NumericString, + NumericString, + NumericString, + NumericString ] diff --git a/packages/proof/src/unpackProof.ts b/packages/proof/src/unpackProof.ts index 37a006730..68ba66599 100644 --- a/packages/proof/src/unpackProof.ts +++ b/packages/proof/src/unpackProof.ts @@ -1,11 +1,12 @@ -import { SnarkJSProof, Proof } from "./types" +import { Groth16Proof } from "snarkjs" +import { PackedProof } from "./types" /** * Unpacks a proof into its original form. * @param proof The proof compatible with Semaphore. * @returns The proof compatible with SnarkJS. */ -export default function unpackProof(proof: Proof): SnarkJSProof { +export default function unpackProof(proof: PackedProof): Groth16Proof { return { pi_a: [proof[0], proof[1]], pi_b: [ diff --git a/packages/proof/src/verifyProof.ts b/packages/proof/src/verifyProof.ts index 1352f399d..6a43cc1e6 100644 --- a/packages/proof/src/verifyProof.ts +++ b/packages/proof/src/verifyProof.ts @@ -1,6 +1,6 @@ import { groth16 } from "snarkjs" import hash from "./hash" -import { FullProof } from "./types" +import { SemaphoreProof } from "./types" import unpackProof from "./unpackProof" import verificationKeys from "./verificationKeys.json" @@ -11,7 +11,7 @@ import verificationKeys from "./verificationKeys.json" * @returns True if the proof is valid, false otherwise. */ export default function verifyProof( - { merkleTreeRoot, nullifierHash, externalNullifier, signal, proof }: FullProof, + { merkleTreeRoot, nullifierHash, externalNullifier, signal, proof }: SemaphoreProof, treeDepth: number ): Promise { if (treeDepth < 16 || treeDepth > 32) { diff --git a/types/circomlibjs/index.d.ts b/types/circomlibjs/index.d.ts deleted file mode 100644 index 143e7812d..000000000 --- a/types/circomlibjs/index.d.ts +++ /dev/null @@ -1,895 +0,0 @@ -/** Declaration file generated by dts-gen */ - -declare module "circomlibjs" { - export class evmasm { - constructor(...args: any[]) - - add(...args: any[]): void - - addmod(...args: any[]): void - - address(...args: any[]): void - - and(...args: any[]): void - - balance(...args: any[]): void - - blockhash(...args: any[]): void - - byte(...args: any[]): void - - call(...args: any[]): void - - callcode(...args: any[]): void - - calldatacopy(...args: any[]): void - - calldataload(...args: any[]): void - - calldatasize(...args: any[]): void - - caller(...args: any[]): void - - callvalue(...args: any[]): void - - codecopy(...args: any[]): void - - codesize(...args: any[]): void - - coinbase(...args: any[]): void - - create(...args: any[]): void - - createTxData(...args: any[]): void - - delegatecall(...args: any[]): void - - difficulty(...args: any[]): void - - div(...args: any[]): void - - dup(...args: any[]): void - - eq(...args: any[]): void - - exp(...args: any[]): void - - extcodecopy(...args: any[]): void - - extcodesize(...args: any[]): void - - gas(...args: any[]): void - - gaslimit(...args: any[]): void - - gasprice(...args: any[]): void - - gt(...args: any[]): void - - invalid(...args: any[]): void - - iszero(...args: any[]): void - - jmp(...args: any[]): void - - jmpi(...args: any[]): void - - keccak(...args: any[]): void - - label(...args: any[]): void - - log0(...args: any[]): void - - log1(...args: any[]): void - - log2(...args: any[]): void - - log3(...args: any[]): void - - log4(...args: any[]): void - - lt(...args: any[]): void - - mload(...args: any[]): void - - mod(...args: any[]): void - - msize(...args: any[]): void - - mstore(...args: any[]): void - - mstore8(...args: any[]): void - - mul(...args: any[]): void - - mulmod(...args: any[]): void - - not(...args: any[]): void - - number(...args: any[]): void - - or(...args: any[]): void - - origin(...args: any[]): void - - pc(...args: any[]): void - - pop(...args: any[]): void - - push(...args: any[]): void - - return(...args: any[]): void - - returndatacopy(...args: any[]): void - - returndatasize(...args: any[]): void - - revert(...args: any[]): void - - sdiv(...args: any[]): void - - selfdestruct(...args: any[]): void - - sgt(...args: any[]): void - - sha3(...args: any[]): void - - shor(...args: any[]): void - - signextend(...args: any[]): void - - sload(...args: any[]): void - - slt(...args: any[]): void - - smod(...args: any[]): void - - sstore(...args: any[]): void - - staticcall(...args: any[]): void - - stop(...args: any[]): void - - sub(...args: any[]): void - - swap(...args: any[]): void - - timestamp(...args: any[]): void - } - - export class smt_memdb { - constructor(...args: any[]) - - get(...args: any[]): void - - getRoot(...args: any[]): void - - multiDel(...args: any[]): void - - multiGet(...args: any[]): void - - multiIns(...args: any[]): void - - setRoot(...args: any[]): void - } - - export function poseidon(inputs: any): any - - export function poseidon_slow(inputs: any): any - - export namespace babyjub { - const A: any - - const Base8: any[] - - const D: any - - const Generator: any[] - - const order: any - - const p: any - - const subOrder: any - - function addPoint(a: any, b: any): any - - function inCurve(P: any): any - - function inSubgroup(P: any): any - - function mulPointEscalar(base: any, e: any): any - - function packPoint(P: any): any - - function unpackPoint(_buff: any): any - - namespace F { - const R: any - - const Ri: any - - const bitLength: number - - const half: any - - const m: number - - const mask: any - - const n32: number - - const n64: number - - const n8: number - - const negone: any - - const nqr: any - - const nqr_to_t: any - - const one: any - - const p: any - - const s: number - - const sqrt_q: any - - const sqrt_s: number - - const sqrt_t: any - - const sqrt_tm1d2: any - - const sqrt_z: any - - const t: any - - const two: any - - const type: string - - const zero: any - - function add(...args: any[]): void - - function band(...args: any[]): void - - function bnot(...args: any[]): void - - function bor(...args: any[]): void - - function bxor(...args: any[]): void - - function div(...args: any[]): void - - function e(...args: any[]): void - - function eq(...args: any[]): void - - function exp(...args: any[]): void - - function fromRng(...args: any[]): void - - function fromRprBE(...args: any[]): void - - function fromRprBEM(...args: any[]): void - - function fromRprLE(...args: any[]): void - - function fromRprLEM(...args: any[]): void - - function geq(...args: any[]): void - - function gt(...args: any[]): void - - function idiv(...args: any[]): void - - function inv(...args: any[]): void - - function isZero(...args: any[]): void - - function land(...args: any[]): void - - function leq(...args: any[]): void - - function lnot(...args: any[]): void - - function lor(...args: any[]): void - - function lt(...args: any[]): void - - function mod(...args: any[]): void - - function mul(...args: any[]): void - - function mulScalar(...args: any[]): void - - function neg(...args: any[]): void - - function neq(...args: any[]): void - - function normalize(...args: any[]): void - - function pow(...args: any[]): void - - function random(...args: any[]): void - - function shl(...args: any[]): void - - function shr(...args: any[]): void - - function sqrt(a: any): any - - function sqrt_old(...args: any[]): void - - function square(...args: any[]): void - - function sub(...args: any[]): void - - function toRprBE(...args: any[]): void - - function toRprBEM(...args: any[]): void - - function toRprLE(...args: any[]): void - - function toRprLEM(...args: any[]): void - - function toString(...args: any[]): void - } - } - - export namespace eddsa { - function packSignature(sig: any): any - - function pruneBuffer(_buff: any): any - - function prv2pub(prv: any): any - - function sign(prv: any, msg: any): any - - function signMiMC(prv: any, msg: any): any - - function signMiMCSponge(prv: any, msg: any): any - - function signPoseidon(prv: any, msg: any): any - - function unpackSignature(sigBuff: any): any - - function verify(msg: any, sig: any, A: any): any - - function verifyMiMC(msg: any, sig: any, A: any): any - - function verifyMiMCSponge(msg: any, sig: any, A: any): any - - function verifyPoseidon(msg: any, sig: any, A: any): any - } - - export namespace mimc7 { - function getConstants(seed: any, nRounds: any): any - - function getIV(seed: any): any - - function hash(_x_in: any, _k: any): any - - function multiHash(arr: any, key: any): any - - namespace F { - const R: any - - const Ri: any - - const bitLength: number - - const half: any - - const m: number - - const mask: any - - const n32: number - - const n64: number - - const n8: number - - const negone: any - - const nqr: any - - const nqr_to_t: any - - const one: any - - const p: any - - const s: number - - const sqrt_q: any - - const sqrt_s: number - - const sqrt_t: any - - const sqrt_tm1d2: any - - const sqrt_z: any - - const t: any - - const two: any - - const type: string - - const zero: any - - function add(...args: any[]): void - - function band(...args: any[]): void - - function bnot(...args: any[]): void - - function bor(...args: any[]): void - - function bxor(...args: any[]): void - - function div(...args: any[]): void - - function e(...args: any[]): void - - function eq(...args: any[]): void - - function exp(...args: any[]): void - - function fromRng(...args: any[]): void - - function fromRprBE(...args: any[]): void - - function fromRprBEM(...args: any[]): void - - function fromRprLE(...args: any[]): void - - function fromRprLEM(...args: any[]): void - - function geq(...args: any[]): void - - function gt(...args: any[]): void - - function idiv(...args: any[]): void - - function inv(...args: any[]): void - - function isZero(...args: any[]): void - - function land(...args: any[]): void - - function leq(...args: any[]): void - - function lnot(...args: any[]): void - - function lor(...args: any[]): void - - function lt(...args: any[]): void - - function mod(...args: any[]): void - - function mul(...args: any[]): void - - function mulScalar(...args: any[]): void - - function neg(...args: any[]): void - - function neq(...args: any[]): void - - function normalize(...args: any[]): void - - function pow(...args: any[]): void - - function random(...args: any[]): void - - function shl(...args: any[]): void - - function shr(...args: any[]): void - - function sqrt(a: any): any - - function sqrt_old(...args: any[]): void - - function square(...args: any[]): void - - function sub(...args: any[]): void - - function toRprBE(...args: any[]): void - - function toRprBEM(...args: any[]): void - - function toRprLE(...args: any[]): void - - function toRprLEM(...args: any[]): void - - function toString(...args: any[]): void - } - } - - export namespace mimc_gencontract { - const abi: { - constant: boolean - inputs: { - name: string - type: string - }[] - name: string - outputs: { - name: string - type: string - }[] - payable: boolean - stateMutability: string - type: string - }[] - - function createCode(seed: any, n: any): any - } - - export namespace mimcsponge { - function getConstants(seed: any, nRounds: any): any - - function getIV(seed: any): any - - function hash(_xL_in: any, _xR_in: any, _k: any): any - - function multiHash(arr: any, key: any, numOutputs: any): any - } - - export namespace mimcsponge_gencontract { - const abi: { - constant: boolean - inputs: { - name: string - type: string - }[] - name: string - outputs: { - name: string - type: string - }[] - payable: boolean - stateMutability: string - type: string - }[] - - function createCode(seed: any, n: any): any - } - - export namespace pedersenHash { - function getBasePoint(baseHashType: any, pointIdx: any): any - - function hash(msg: any, options: any): any - } - - export namespace poseidon_gencontract { - function createCode(nInputs: any): any - - function generateABI(nInputs: any): any - } - - export namespace smt { - class SMT { - constructor(...args: any[]) - - delete(...args: any[]): void - - find(...args: any[]): void - - insert(...args: any[]): void - - update(...args: any[]): void - } - - class SMTMemDB { - constructor(...args: any[]) - - get(...args: any[]): void - - getRoot(...args: any[]): void - - multiDel(...args: any[]): void - - multiGet(...args: any[]): void - - multiIns(...args: any[]): void - - setRoot(...args: any[]): void - } - - function loadFromFile(fileName: any): void - - function newMemEmptyTrie(): any - } - - export namespace smt_hashes_mimc { - function hash0(left: any, right: any): any - - function hash1(key: any, value: any): any - - namespace F { - const R: any - - const Ri: any - - const bitLength: number - - const half: any - - const m: number - - const mask: any - - const n32: number - - const n64: number - - const n8: number - - const negone: any - - const nqr: any - - const nqr_to_t: any - - const one: any - - const p: any - - const s: number - - const sqrt_q: any - - const sqrt_s: number - - const sqrt_t: any - - const sqrt_tm1d2: any - - const sqrt_z: any - - const t: any - - const two: any - - const type: string - - const zero: any - - function add(...args: any[]): void - - function band(...args: any[]): void - - function bnot(...args: any[]): void - - function bor(...args: any[]): void - - function bxor(...args: any[]): void - - function div(...args: any[]): void - - function e(...args: any[]): void - - function eq(...args: any[]): void - - function exp(...args: any[]): void - - function fromRng(...args: any[]): void - - function fromRprBE(...args: any[]): void - - function fromRprBEM(...args: any[]): void - - function fromRprLE(...args: any[]): void - - function fromRprLEM(...args: any[]): void - - function geq(...args: any[]): void - - function gt(...args: any[]): void - - function idiv(...args: any[]): void - - function inv(...args: any[]): void - - function isZero(...args: any[]): void - - function land(...args: any[]): void - - function leq(...args: any[]): void - - function lnot(...args: any[]): void - - function lor(...args: any[]): void - - function lt(...args: any[]): void - - function mod(...args: any[]): void - - function mul(...args: any[]): void - - function mulScalar(...args: any[]): void - - function neg(...args: any[]): void - - function neq(...args: any[]): void - - function normalize(...args: any[]): void - - function pow(...args: any[]): void - - function random(...args: any[]): void - - function shl(...args: any[]): void - - function shr(...args: any[]): void - - function sqrt(a: any): any - - function sqrt_old(...args: any[]): void - - function square(...args: any[]): void - - function sub(...args: any[]): void - - function toRprBE(...args: any[]): void - - function toRprBEM(...args: any[]): void - - function toRprLE(...args: any[]): void - - function toRprLEM(...args: any[]): void - - function toString(...args: any[]): void - } - } - - export namespace smt_hashes_poseidon { - function hash0(left: any, right: any): any - - function hash1(key: any, value: any): any - - namespace F { - const R: any - - const Ri: any - - const bitLength: number - - const half: any - - const m: number - - const mask: any - - const n32: number - - const n64: number - - const n8: number - - const negone: any - - const nqr: any - - const nqr_to_t: any - - const one: any - - const p: any - - const s: number - - const sqrt_q: any - - const sqrt_s: number - - const sqrt_t: any - - const sqrt_tm1d2: any - - const sqrt_z: any - - const t: any - - const two: any - - const type: string - - const zero: any - - function add(...args: any[]): void - - function band(...args: any[]): void - - function bnot(...args: any[]): void - - function bor(...args: any[]): void - - function bxor(...args: any[]): void - - function div(...args: any[]): void - - function e(...args: any[]): void - - function eq(...args: any[]): void - - function exp(...args: any[]): void - - function fromRng(...args: any[]): void - - function fromRprBE(...args: any[]): void - - function fromRprBEM(...args: any[]): void - - function fromRprLE(...args: any[]): void - - function fromRprLEM(...args: any[]): void - - function geq(...args: any[]): void - - function gt(...args: any[]): void - - function idiv(...args: any[]): void - - function inv(...args: any[]): void - - function isZero(...args: any[]): void - - function land(...args: any[]): void - - function leq(...args: any[]): void - - function lnot(...args: any[]): void - - function lor(...args: any[]): void - - function lt(...args: any[]): void - - function mod(...args: any[]): void - - function mul(...args: any[]): void - - function mulScalar(...args: any[]): void - - function neg(...args: any[]): void - - function neq(...args: any[]): void - - function normalize(...args: any[]): void - - function pow(...args: any[]): void - - function random(...args: any[]): void - - function shl(...args: any[]): void - - function shr(...args: any[]): void - - function sqrt(a: any): any - - function sqrt_old(...args: any[]): void - - function square(...args: any[]): void - - function sub(...args: any[]): void - - function toRprBE(...args: any[]): void - - function toRprBEM(...args: any[]): void - - function toRprLE(...args: any[]): void - - function toRprLEM(...args: any[]): void - - function toString(...args: any[]): void - } - } -} diff --git a/types/snarkjs/index.d.ts b/types/snarkjs/index.d.ts deleted file mode 100644 index 7d118e2d9..000000000 --- a/types/snarkjs/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** Declaration file generated by dts-gen */ - -declare module "snarkjs" { - export = snarkjs - - declare const snarkjs: { - groth16: { - exportSolidityCallData: any - fullProve: any - prove: any - verify: any - } - plonk: { - exportSolidityCallData: any - fullProve: any - prove: any - setup: any - verify: any - } - powersOfTau: { - beacon: any - challengeContribute: any - contribute: any - convert: any - exportChallenge: any - exportJson: any - importResponse: any - newAccumulator: any - preparePhase2: any - truncate: any - verify: any - } - r1cs: { - exportJson: any - info: any - print: any - } - wtns: { - calculate: any - debug: any - exportJson: any - } - zKey: { - beacon: any - bellmanContribute: any - contribute: any - exportBellman: any - exportJson: any - exportSolidityVerifier: any - exportVerificationKey: any - importBellman: any - newZKey: any - verifyFromInit: any - verifyFromR1cs: any - } - } -} diff --git a/yarn.lock b/yarn.lock index dbd14f975..e5e718738 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4960,6 +4960,13 @@ __metadata: languageName: node linkType: hard +"@types/circomlibjs@npm:^0.1.1": + version: 0.1.1 + resolution: "@types/circomlibjs@npm:0.1.1" + checksum: 81485e8c5a8c81cef5f5f837d5890bafd8fe0d507251295fb72a0d03c4450fe0614764071137b8f58800dc4743851effd544eb35f345e4910b88e6afb5a2e257 + languageName: node + linkType: hard + "@types/clear@npm:^0.1.2": version: 0.1.2 resolution: "@types/clear@npm:0.1.2" @@ -5415,6 +5422,13 @@ __metadata: languageName: node linkType: hard +"@types/snarkjs@npm:^0.7.2": + version: 0.7.2 + resolution: "@types/snarkjs@npm:0.7.2" + checksum: 4b675e43a495306e7d1b69dc07496fe3775390c1fe1ca151d54b3e9a111f9336534cc1a5322a95b3e5c6b024e9cd83411b48dcbabe3673c997d5cbb1586de330 + languageName: node + linkType: hard + "@types/ssri@npm:*": version: 7.1.1 resolution: "@types/ssri@npm:7.1.1" @@ -7546,6 +7560,18 @@ __metadata: languageName: node linkType: hard +"circomlibjs@npm:^0.1.7": + version: 0.1.7 + resolution: "circomlibjs@npm:0.1.7" + dependencies: + blake-hash: ^2.0.0 + blake2b: ^2.1.3 + ethers: ^5.5.1 + ffjavascript: ^0.2.45 + checksum: 843aa422e7a203d06e1ef9ae6bf334d726a8091eda5afcc3a6531727a6ea3acb5c4a2498bf444fda35824064d45c25cb89fe99b02410fc0f7ff2dc6d7101d779 + languageName: node + linkType: hard + "circuits@workspace:packages/circuits": version: 0.0.0-use.local resolution: "circuits@workspace:packages/circuits" @@ -8027,7 +8053,7 @@ __metadata: "@zk-kit/incremental-merkle-tree.sol": 1.3.3 chai: ^4.3.5 circomlib: ^2.0.2 - circomlibjs: ^0.0.8 + circomlibjs: ^0.1.7 download: ^8.0.0 ethers: ^5.6.8 hardhat: ^2.9.7 @@ -9724,7 +9750,7 @@ __metadata: languageName: node linkType: hard -"ethers@npm:^5.0.0, ethers@npm:^5.4.7, ethers@npm:^5.7.2": +"ethers@npm:^5.0.0, ethers@npm:^5.4.7, ethers@npm:^5.5.1, ethers@npm:^5.7.2": version: 5.7.2 resolution: "ethers@npm:5.7.2" dependencies: @@ -10114,6 +10140,17 @@ __metadata: languageName: node linkType: hard +"ffjavascript@npm:^0.2.45": + version: 0.2.60 + resolution: "ffjavascript@npm:0.2.60" + dependencies: + wasmbuilder: 0.0.16 + wasmcurves: 0.2.2 + web-worker: ^1.2.0 + checksum: 5dbd597ee108373af1ba1877757a08b47db4bcd7b3b043b260d4475a0b1125454de00fb214224f85d9e6e6a6c0a1cfabd1ba9a2b68279b99c581404266e78138 + languageName: node + linkType: hard + "figlet@npm:^1.5.2": version: 1.5.2 resolution: "figlet@npm:1.5.2" @@ -17411,11 +17448,13 @@ __metadata: "@commitlint/cli": ^16.0.2 "@commitlint/config-conventional": ^16.0.0 "@rollup/plugin-typescript": ^8.3.0 + "@types/circomlibjs": ^0.1.1 "@types/download": ^8.0.1 "@types/glob": ^7.2.0 "@types/jest": ^27.4.0 "@types/node": ^17.0.9 "@types/rimraf": ^3.0.2 + "@types/snarkjs": ^0.7.2 "@typescript-eslint/eslint-plugin": ^5.9.1 "@typescript-eslint/parser": ^5.9.1 babel-jest: ^27.4.6 @@ -19820,6 +19859,15 @@ __metadata: languageName: node linkType: hard +"wasmcurves@npm:0.2.2": + version: 0.2.2 + resolution: "wasmcurves@npm:0.2.2" + dependencies: + wasmbuilder: 0.0.16 + checksum: 95ca8afe3816862f16d4f8f4cbed4a4fb522be03a41af3cf7d65429bcac9ff4ccbc6e02762dd14933f0e5903cfb93d15cf31fc4acc953f3fcdb31190eba969e8 + languageName: node + linkType: hard + "wcwidth@npm:^1.0.1": version: 1.0.1 resolution: "wcwidth@npm:1.0.1"