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

fix: gnark plonky2 verifier #234

Merged
merged 31 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9402efa
modified verifier
puma314 Oct 12, 2023
c74218b
Test now works
puma314 Oct 12, 2023
2243a39
cleanup
puma314 Oct 12, 2023
d3e5ab6
Clean up verifier test
puma314 Oct 12, 2023
7d06381
Circuit digest works
puma314 Oct 12, 2023
a4a696a
clippy
puma314 Oct 12, 2023
5a4471b
Changed smart contract
puma314 Oct 12, 2023
6943848
udpdate succinct json
puma314 Oct 12, 2023
ec7908c
go mod tidy
ctian1 Oct 12, 2023
d227b18
change to plonk
puma314 Oct 12, 2023
d499896
Updates to work with new verifier
puma314 Oct 13, 2023
57d4e8d
Solidty version
puma314 Oct 13, 2023
587a3f9
anotehr try
puma314 Oct 13, 2023
ffccb04
cursed
puma314 Oct 13, 2023
8af64be
benchmarking code (#236)
puma314 Oct 13, 2023
53bded2
Updated logic in backend/function and removed assets/Verifier.sol
puma314 Oct 13, 2023
9c1a69e
nits
puma314 Oct 13, 2023
f88dfb2
Forge fmt
puma314 Oct 13, 2023
c50cbf5
upgraded to optimized version of gnark
puma314 Oct 13, 2023
1f82c01
Test works
puma314 Oct 13, 2023
32e412b
With tons of debug statements
puma314 Oct 17, 2023
876f7e2
Made go command have a cli with stdin for circuitPath
puma314 Oct 17, 2023
9c9522d
Modified function/mod.rs to write to stdout
puma314 Oct 17, 2023
f115978
std pipe
puma314 Oct 18, 2023
5f297de
try again
puma314 Oct 18, 2023
896c471
Cleanup test
puma314 Oct 18, 2023
ea2db3b
Forge fmt
puma314 Oct 18, 2023
41bb8bd
clippy
puma314 Oct 18, 2023
93ebac5
fix: john edits
jtguibas Oct 18, 2023
255f09b
fix: john edits
jtguibas Oct 18, 2023
9aa369f
fix: john edits
jtguibas Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 0 additions & 307 deletions assets/Verifier.sol

This file was deleted.

64 changes: 64 additions & 0 deletions contracts/test/verifiers/TestVerifier.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import "forge-std/Vm.sol";
import "forge-std/console.sol";
import "forge-std/Test.sol";

import {Verifier as Groth16Verifier} from "./VerifierGroth16.sol";
import {PlonkVerifier} from "./VerifierPlonk.sol";
import {PlonkVerifier as PlonkRangeCheckVerifier} from "./VerifierPlonkRangeCheck.sol";
import {VmSafe} from "forge-std/Vm.sol";
import {stdJson} from "forge-std/StdJson.sol";

contract VerifierTest is Test {
function testVerifierGroth16() public {
Groth16Verifier verifier = new Groth16Verifier();

string memory groth16Json = vm.readFile("test/verifiers/groth16_proof_data.json");
uint256[] memory proof = stdJson.readUintArray(groth16Json, "$.proof");
uint256[] memory input = stdJson.readUintArray(groth16Json, "$.inputs");

uint256[8] memory proofConverted;
for (uint256 i = 0; i < 8; i++) {
proofConverted[i] = uint256(proof[i]);
}

uint256[3] memory inputConverted;
for (uint256 i = 0; i < 3; i++) {
inputConverted[i] = uint256(input[i]);
}
uint256 startGas = gasleft();
verifier.verifyProof(proofConverted, inputConverted);
uint256 endGas = gasleft();
console.log("gas used: %d", startGas - endGas);

uint256[4] memory compressedProof = verifier.compressProof(proofConverted);
startGas = gasleft();
verifier.verifyCompressedProof(compressedProof, inputConverted);
endGas = gasleft();
console.log("gas used for verifying compressed proof: %d", startGas - endGas);
}

function testVerifierPlonk() public {
PlonkVerifier verifier = new PlonkVerifier();
string memory proofJson = vm.readFile("test/verifiers/plonk_proof_data.json");
bytes memory proof = stdJson.readBytes(proofJson, "$.proof");
uint256[] memory input = stdJson.readUintArray(proofJson, "$.inputs");
uint256 startGas = gasleft();
verifier.Verify(proof, input);
uint256 endGas = gasleft();
console.log("gas used: %d", startGas - endGas);
}

function testVerifierPlonkRangeCheck() public {
PlonkRangeCheckVerifier verifier = new PlonkRangeCheckVerifier();
string memory proofJson = vm.readFile("test/verifiers/plonk_proof_data_range_check.json");
bytes memory proof = stdJson.readBytes(proofJson, "$.proof");
uint256[] memory input = stdJson.readUintArray(proofJson, "$.inputs");
uint256 startGas = gasleft();
verifier.Verify(proof, input);
uint256 endGas = gasleft();
console.log("gas used: %d", startGas - endGas);
}
}
Loading
Loading