diff --git a/contracts/libs/zkp/Groth16VerifierHelper.sol b/contracts/libs/zkp/Groth16VerifierHelper.sol index e766d5f8..acbfb766 100644 --- a/contracts/libs/zkp/Groth16VerifierHelper.sol +++ b/contracts/libs/zkp/Groth16VerifierHelper.sol @@ -30,14 +30,14 @@ library Groth16VerifierHelper { * @notice Function to call the `verifyProof` function on the `verifier` contract. * The ZK proof points are wrapped in a structure for convenience * @param verifier_ the address of the autogenerated `Verifier` contract - * @param pubSignals_ the array of the ZK proof public signals * @param proofPoints_ the ProofPoints struct with ZK proof points + * @param pubSignals_ the array of the ZK proof public signals * @return true if the proof is valid, false - otherwise */ function verifyProof( address verifier_, - uint256[] memory pubSignals_, - ProofPoints memory proofPoints_ + ProofPoints memory proofPoints_, + uint256[] memory pubSignals_ ) internal view returns (bool) { return _verifyProof( @@ -53,18 +53,18 @@ library Groth16VerifierHelper { /** * @notice Function to call the `verifyProof` function on the `verifier` contract * @param verifier_ the address of the autogenerated `Verifier` contract - * @param pubSignals_ the array of the ZK proof public signals * @param a_ the A point of the ZK proof * @param b_ the B point of the ZK proof * @param c_ the C point of the ZK proof + * @param pubSignals_ the array of the ZK proof public signals * @return true if the proof is valid, false - otherwise */ function verifyProof( address verifier_, - uint256[] memory pubSignals_, uint256[2] memory a_, uint256[2][2] memory b_, - uint256[2] memory c_ + uint256[2] memory c_, + uint256[] memory pubSignals_ ) internal view returns (bool) { return _verifyProof(verifier_, a_, b_, c_, pubSignals_, pubSignals_.length); } @@ -74,15 +74,15 @@ library Groth16VerifierHelper { * The ZK proof points are wrapped in a structure for convenience * The length of the `pubSignals_` arr must be strictly equal to `pubSignalsCount_` * @param verifier_ the address of the autogenerated `Verifier` contract - * @param pubSignals_ the array of the ZK proof public signals * @param proofPoints_ the ProofPoints struct with ZK proof points + * @param pubSignals_ the array of the ZK proof public signals * @param pubSignalsCount_ the number of public signals * @return true if the proof is valid, false - otherwise */ function verifyProofSafe( address verifier_, - uint256[] memory pubSignals_, ProofPoints memory proofPoints_, + uint256[] memory pubSignals_, uint256 pubSignalsCount_ ) internal view returns (bool) { if (pubSignals_.length != pubSignalsCount_) @@ -103,19 +103,19 @@ library Groth16VerifierHelper { * @notice Function to call the `verifyProof` function on the `verifier` contract * The length of the `pubSignals_` arr must be strictly equal to `pubSignalsCount_` * @param verifier_ the address of the autogenerated `Verifier` contract - * @param pubSignals_ the array of the ZK proof public signals * @param a_ the A point of the ZK proof * @param b_ the B point of the ZK proof * @param c_ the C point of the ZK proof + * @param pubSignals_ the array of the ZK proof public signals * @param pubSignalsCount_ the number of public signals * @return true if the proof is valid, false - otherwise */ function verifyProofSafe( address verifier_, - uint256[] memory pubSignals_, uint256[2] memory a_, uint256[2][2] memory b_, uint256[2] memory c_, + uint256[] memory pubSignals_, uint256 pubSignalsCount_ ) internal view returns (bool) { if (pubSignals_.length != pubSignalsCount_) diff --git a/contracts/mock/libs/zkp/snarkjs/Groth16VerifierHelperMock.sol b/contracts/mock/libs/zkp/snarkjs/Groth16VerifierHelperMock.sol index 51479b73..de248929 100644 --- a/contracts/mock/libs/zkp/snarkjs/Groth16VerifierHelperMock.sol +++ b/contracts/mock/libs/zkp/snarkjs/Groth16VerifierHelperMock.sol @@ -9,39 +9,39 @@ contract Groth16VerifierHelperMock { function verifyProofStruct( address verifier_, - uint256[] memory pubSignals_, - Groth16VerifierHelper.ProofPoints memory proofPoints_ + Groth16VerifierHelper.ProofPoints memory proofPoints_, + uint256[] memory pubSignals_ ) external view returns (bool) { - return verifier_.verifyProof(pubSignals_, proofPoints_); + return verifier_.verifyProof(proofPoints_, pubSignals_); } function verifyProof( address verifier_, - uint256[] memory pubSignals_, uint256[2] memory a_, uint256[2][2] memory b_, - uint256[2] memory c_ + uint256[2] memory c_, + uint256[] memory pubSignals_ ) external view returns (bool) { - return verifier_.verifyProof(pubSignals_, a_, b_, c_); + return verifier_.verifyProof(a_, b_, c_, pubSignals_); } function verifyProofStructSafe( address verifier_, - uint256[] memory pubSignals_, Groth16VerifierHelper.ProofPoints memory proofPoints_, + uint256[] memory pubSignals_, uint256 pubSignalsCount_ ) external view returns (bool) { - return verifier_.verifyProofSafe(pubSignals_, proofPoints_, pubSignalsCount_); + return verifier_.verifyProofSafe(proofPoints_, pubSignals_, pubSignalsCount_); } function verifyProofSafe( address verifier_, - uint256[] memory pubSignals_, uint256[2] memory a_, uint256[2][2] memory b_, uint256[2] memory c_, + uint256[] memory pubSignals_, uint256 pubSignalsCount_ ) external view returns (bool) { - return verifier_.verifyProofSafe(pubSignals_, a_, b_, c_, pubSignalsCount_); + return verifier_.verifyProofSafe(a_, b_, c_, pubSignals_, pubSignalsCount_); } } diff --git a/package-lock.json b/package-lock.json index 54a5d1f4..7869df13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solarity/solidity-lib", - "version": "3.0.0-rc.0", + "version": "3.0.0-rc.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@solarity/solidity-lib", - "version": "3.0.0-rc.0", + "version": "3.0.0-rc.1", "license": "MIT", "dependencies": { "@openzeppelin/contracts": "5.2.0", diff --git a/package.json b/package.json index 9e02be7d..0fabf426 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/solidity-lib", - "version": "3.0.0-rc.0", + "version": "3.0.0-rc.1", "license": "MIT", "author": "Distributed Lab", "readme": "README.md", diff --git a/test/libs/zkp/Groth16VerifierHelper.test.ts b/test/libs/zkp/Groth16VerifierHelper.test.ts index bc82c90d..018990ac 100644 --- a/test/libs/zkp/Groth16VerifierHelper.test.ts +++ b/test/libs/zkp/Groth16VerifierHelper.test.ts @@ -40,25 +40,25 @@ describe("Groth16VerifierHelper", () => { describe("verifyProof", () => { it("should correctly call verifyProof function", async () => { const contractInterface = expect( - await verifierHelper.verifyProofStruct(await verifier3.getAddress(), pubSignals3, { a, b, c }), + await verifierHelper.verifyProofStruct(await verifier3.getAddress(), { a, b, c }, pubSignals3), ).to.be.true; - expect(await verifierHelper.verifyProof(await verifier3.getAddress(), pubSignals3, a, b, c)).to.be.true; + expect(await verifierHelper.verifyProof(await verifier3.getAddress(), a, b, c, pubSignals3)).to.be.true; await verifier2.setVerifyResult(false); - expect(await verifierHelper.verifyProofStruct(await verifier2.getAddress(), pubSignals2, { a, b, c })).to.be + expect(await verifierHelper.verifyProofStruct(await verifier2.getAddress(), { a, b, c }, pubSignals2)).to.be .false; - expect(await verifierHelper.verifyProof(await verifier2.getAddress(), pubSignals2, a, b, c)).to.be.false; + expect(await verifierHelper.verifyProof(await verifier2.getAddress(), a, b, c, pubSignals2)).to.be.false; }); it("should get exception if failed to call verifyProof function", async () => { const wrongPubSignals = [1, 1, 2, 3]; - await expect(verifierHelper.verifyProofStruct(await verifier2.getAddress(), wrongPubSignals, { a, b, c })) + await expect(verifierHelper.verifyProofStruct(await verifier2.getAddress(), { a, b, c }, wrongPubSignals)) .to.be.revertedWithCustomError(verifierHelper, "FailedToCallVerifyProof") .withArgs(); - await expect(verifierHelper.verifyProof(await verifier3.getAddress(), wrongPubSignals, a, b, c)) + await expect(verifierHelper.verifyProof(await verifier3.getAddress(), a, b, c, wrongPubSignals)) .to.be.revertedWithCustomError(verifierHelper, "FailedToCallVerifyProof") .withArgs(); }); @@ -66,23 +66,23 @@ describe("Groth16VerifierHelper", () => { describe("verifyProofSafe", () => { it("should correctly call verifyProof function with additional checks", async () => { - expect(await verifierHelper.verifyProofStructSafe(await verifier3.getAddress(), pubSignals3, { a, b, c }, 3)).to + expect(await verifierHelper.verifyProofStructSafe(await verifier3.getAddress(), { a, b, c }, pubSignals3, 3)).to .be.true; - expect(await verifierHelper.verifyProofSafe(await verifier3.getAddress(), pubSignals3, a, b, c, 3)).to.be.true; + expect(await verifierHelper.verifyProofSafe(await verifier3.getAddress(), a, b, c, pubSignals3, 3)).to.be.true; await verifier2.setVerifyResult(false); - expect(await verifierHelper.verifyProofStructSafe(await verifier2.getAddress(), pubSignals2, { a, b, c }, 2)).to + expect(await verifierHelper.verifyProofStructSafe(await verifier2.getAddress(), { a, b, c }, pubSignals2, 2)).to .be.false; - expect(await verifierHelper.verifyProofSafe(await verifier2.getAddress(), pubSignals2, a, b, c, 2)).to.be.false; + expect(await verifierHelper.verifyProofSafe(await verifier2.getAddress(), a, b, c, pubSignals2, 2)).to.be.false; }); it("should get an exception if it passes invalid public signals arr", async () => { - await expect(verifierHelper.verifyProofStructSafe(await verifier2.getAddress(), pubSignals2, { a, b, c }, 4)) + await expect(verifierHelper.verifyProofStructSafe(await verifier2.getAddress(), { a, b, c }, pubSignals2, 4)) .to.be.revertedWithCustomError(verifierHelper, "InvalidPublicSignalsCount") .withArgs(pubSignals2.length, 4); - await expect(verifierHelper.verifyProofSafe(await verifier3.getAddress(), pubSignals3, a, b, c, 4)) + await expect(verifierHelper.verifyProofSafe(await verifier3.getAddress(), a, b, c, pubSignals3, 4)) .to.be.revertedWithCustomError(verifierHelper, "InvalidPublicSignalsCount") .withArgs(pubSignals3.length, 4); });