You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As can be seen from the ZKPVerifier smartcontract used to submit proof requests and verify proofs, the logic that computes the query hash of the proof request has slotIndex hardcoded to 0
whereas the internal logic of generateProof in the sdk sets the slotIndex either to 2 or 5, which results in a query hash mismatch when trying to submit the proof generated by this function with the AtomicQuerySigV2OnChain circuit
To Reproduce
I managed to reproduce the issue with the following repo where I changed the circuit for AtomicQuerySigV2OnChain in the test fixture kycAgeProofReqSig:
note the 876854063388751259451046665973179579453696431476710960571891857639659962126 which is the (presumably wrong) query hash. As soon as I hacked the polygon js sdk to return slotIndex 0 instead of 2/5, the returned query hash changed to 15045271939084694661437431358729281571840804299863053791890179002991342242959 which seems to match successful executions of the verification on chain, e.g. https://mumbai.polygonscan.com/tx/0x477a5df34d390fdd0a0e4f46526dad078292ffb48e248f1c51c1b5efc049d5f6
Expected behavior
slotIndex should be 0 as per the latest ZKPVerifier contract, or perhaps overridable from outside
Screenshots
If applicable, add screenshots to help explain your problem.
** Environment info (please complete the following information):**
OS version [e.g. Mac OS]
Node version: [e.g. 18.16]
Browser [e.g. chrome, safari]
Package version [e.g. 1.0.0]
Build [e.g. umd, cjs]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
thank you @refi93, this is a very nice catch.
It looks like a contradiction between the choice of the value of the slot index in the sdk and ZKPVerifier latest contract.
Fixed in #114 . For merklized credentials, slotIndex in the query must be equal to zero and not a position of merklization root.
It has no influence on check in the off-chain circuits, but it aligns with on-chain verification standard
Describe the bug
Not sure if a bug, but it has been causing me a query hash mismatch when trying to do the onchain verification based on https://github.com/0xPolygonID/tutorial-examples/tree/main/on-chain-verification
As can be seen from the ZKPVerifier smartcontract used to submit proof requests and verify proofs, the logic that computes the query hash of the proof request has
slotIndex
hardcoded to 0https://github.com/0xPolygonID/tutorial-examples/blob/6052cdff6ecdb9b0fe5a297bace7c81b1d03c95f/on-chain-verification/contracts/verifiers/ZKPVerifier.sol#L67
whereas the internal logic of
generateProof
in the sdk sets the slotIndex either to 2 or 5, which results in a query hash mismatch when trying to submit the proof generated by this function with theAtomicQuerySigV2OnChain
circuitCan you clarify whether this mismatch is intentional? I see earlier iterations of the verifier contract actually allowing to set the slotIndex from outside, so perhaps the
generateProof
logic just wasn't updated accordingly: https://github.com/codingwithmanny/polygonid-on-chain-verification/blob/211e82ce87f7092d6d8354342593c2c0e24fa9ba/contracts/verifiers/ZKPVerifier.sol#L85To Reproduce
I managed to reproduce the issue with the following repo where I changed the circuit for
AtomicQuerySigV2OnChain
in the test fixturekycAgeProofReqSig
:https://github.com/joelamouche/polygon-getProof-test/blob/e93a63dc90bed5020e4d931ed7fa0018add66c67/test/testKYCAgeConstants.ts#L9
which then prints the following proof:
note the
876854063388751259451046665973179579453696431476710960571891857639659962126
which is the (presumably wrong) query hash. As soon as I hacked the polygon js sdk to return slotIndex 0 instead of 2/5, the returned query hash changed to15045271939084694661437431358729281571840804299863053791890179002991342242959
which seems to match successful executions of the verification on chain, e.g. https://mumbai.polygonscan.com/tx/0x477a5df34d390fdd0a0e4f46526dad078292ffb48e248f1c51c1b5efc049d5f6Expected behavior
slotIndex should be 0 as per the latest
ZKPVerifier
contract, or perhaps overridable from outsideScreenshots
If applicable, add screenshots to help explain your problem.
** Environment info (please complete the following information):**
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: