Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code after verifyProof() call becomes unreachable #392

Open
0xbok opened this issue Jun 26, 2023 · 1 comment
Open

code after verifyProof() call becomes unreachable #392

0xbok opened this issue Jun 26, 2023 · 1 comment

Comments

@0xbok
Copy link

0xbok commented Jun 26, 2023

I am not able to inherit the latest version of smart contract verifier for Groth16 in another contract. The reason being that verifyProof() function executes entirely in assembly. On calling this function from another function, all the subsequent statements are marked as "Unreachable code". Tested this with foundry. For this refactor, it started working correctly:

    function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[2] calldata _pubSignals) public view returns (bool) {
+       bool isValid;
        assembly {
            ...
-            let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+            isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
         }
+      return isValid;
     }
@Arvolear
Copy link
Contributor

Unfortunately, this is a common snarkjs limitation, you may check this template that has been rewritten to memory to allow for inheritance and verify() function calls in the same context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants