Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
2
Indexable
Never
import { Identity } from '@semaphore-protocol/identity'
import { Group } from '@semaphore-protocol/group'
import { useState } from 'react'

const {
  generateProof,
  verifyProof,
  packToSolidityProof,
} = require('@semaphore-protocol/proof')

export const useGenerateProof = async (identityKey) => {
  const [var1, setVar1] = useState()
  const [var2, setVar2] = useState()
  const [var3, setVar3] = useState()

  const identity = new Identity(identityKey)
  const identityCommitment = identity.generateCommitment().toString()
  setVar1(identity)
  // console.log(groupId)

  const group = new Group(16)
  group.addMember(identityCommitment)

  const externalNullifier = group.root
  setVar2(externalNullifier)
  const signal = 'proposal_1'
  setVar3(signal)

  // const fullProof = await generateProof(
  //   identity,
  //   group,
  //   externalNullifier,
  //   signal,
  //   {
  //     zkeyFilePath:
  //       'https://www.trusted-setup-pse.org/semaphore/16/semaphore.zkey',
  //     wasmFilePath:
  //       'https://www.trusted-setup-pse.org/semaphore/16/semaphore.wasm',
  //   },
  // )

  return [var1, var2, var3]
}