Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sripwoud committed Sep 21, 2024
1 parent 63fbff2 commit c07ebe9
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions packages/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
import { Project } from '@zk-kit/artifacts'
import { generate, type PoseidonProof } from '@zk-kit/poseidon-proof'
import type { PoseidonProof } from '@zk-kit/poseidon-proof'
import { unpackGroth16Proof } from '@zk-kit/utils'
import { keccak256, toBeHex } from 'ethers'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { groth16 } from 'snarkjs'
const SCOPE = 'scope'

const hash = (message: string) => (BigInt(keccak256(toBeHex(message, 32))) >> BigInt(8)).toString()

const generateProof = (project: Project) => async (preimages: number[]) => {
const numParams = preimages.length
export const SCOPE = 'scope'

return generate(preimages, SCOPE, {
wasm: join(__dirname, '..', project, `${project}-${numParams}.wasm`),
zkey: join(__dirname, '..', project, `${project}-${numParams}.zkey`),
})
}
const hash = (message: string) => (BigInt(keccak256(toBeHex(message, 32))) >> BigInt(8)).toString()

const verifyProof = (project: Project) =>
async (
export const verifyPoseidonProof = (
{ digest, numberOfInputs, proof, scope }: PoseidonProof,
) => {
const verifKey = JSON.parse(readFileSync(join(__dirname, '..', project, `${project}-${numberOfInputs}.json`), 'utf8'))
const verifKey = JSON.parse(
readFileSync(join(__dirname, '..', Project.POSEIDON, `${Project.POSEIDON}-${numberOfInputs}.json`), 'utf8'),
)
return groth16.verify(verifKey, [digest, hash(scope)], unpackGroth16Proof(proof))
}

export const generatePoseidonProof = generateProof(Project.POSEIDON)
export const verifyPoseidonProof = verifyProof(Project.POSEIDON)

0 comments on commit c07ebe9

Please sign in to comment.