webb-tools / semaphore-anchor

A interoperable privacy gadget for creating anonymous proof of membership on blockchains.
http://semaphore.appliedzkp.org
MIT License
2 stars 0 forks source link

[BUG] maxEdges isn't being correctly generalized over. #12

Closed semaraugusto closed 1 year ago

semaraugusto commented 1 year ago

Describe the bug When using a group with maxEdges == 7 the smart-contract and typescript interfaces don't properly generate the correct publicSignals to the verifyProof function on Semaphore.sol To Reproduce Setup variables:

    const chainID = BigInt(1099511629113) // Hardhat default TypedChainId
    const wasmFilePath20_8 = __dirname +
       `/../../solidity-fixtures/solidity-fixtures/${treeDepth}/8/semaphore_20_8.wasm`
    const witnessCalcPath20_8 = __dirname +
       `/../../solidity-fixtures/solidity-fixtures/${treeDepth}/8/witness_calculator.js`
    const zkeyFilePath20_8 = __dirname +
        `/../../solidity-fixtures/solidity-fixtures/${treeDepth}/8/circuit_final.zkey`

    const { identities, members } = createIdentities(Number(chainID), 3)
    const signal = "Hello world"
    const bytes32Signal = utils.formatBytes32String(signal)
    const groupId3 = 1338
    const maxEdges = 7
    const linkedGroup = new LinkedGroup(treeDepth, maxEdges)
    linkedGroup.addMember(members[0])
  1. Create a group on Semaphore.sol: await semaphore.createGroup(groupId, treeDepth, adminAddr, maxEdges)
  2. Add member to group: await semaphore.addMember(groupId, commitment)
  3. Generate Proof of Membership:
    const fullProof = await generateProof(
        identities[0],
        linkedGroup,
        BigNumber.from(Date.now()),
        signal,
        chainID,
        {
          wasmFilePath: wasmFilePath20_8,
          zkeyFilePath: zkeyFilePath20_8
        }
      )
    const solidityProof = packToSolidityProof(fullProof.proof)
  4. Call verifyProof on contract:
    
      const transaction = semaphore.contract.verifyProof(
        groupId3,
        bytes32Signal,
        fullProof.publicSignals.nullifierHash,
        fullProof.publicSignals.externalNullifier,
        createRootsBytes(fullProof.publicSignals.roots),
        solidityProof,
        { gasLimit: "0x5B8D80" }
      )


**Expected behavior**
Proof should be verified, but it's currently being reverted.
dutterbutter commented 1 year ago

Closed in https://github.com/webb-tools/semaphore-anchor/pull/10