mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-08 22:28:08 -05:00
chore: add snarkjs and circomlibjs type definitions
re #362
Former-commit-id: ebe3628561
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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<FullProof> {
|
||||
): Promise<SemaphoreProof> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -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]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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<boolean> {
|
||||
if (treeDepth < 16 || treeDepth > 32) {
|
||||
|
||||
895
types/circomlibjs/index.d.ts
vendored
895
types/circomlibjs/index.d.ts
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
57
types/snarkjs/index.d.ts
vendored
57
types/snarkjs/index.d.ts
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
dbd14f97542894a9f2a786b0bd06101e4b0a0e65
|
||||
e5e7187387bfd734d9790349178dec9aae5a62b1
|
||||
Reference in New Issue
Block a user