-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces an UltraHonk ZK contract and unit tests together with some refactorings/renamings in the pipeline for generating circuits for Solidity unit tests. Flows for testing a deployed contract will be added in a follow-up PR.
- Loading branch information
1 parent
b168601
commit a68369f
Showing
51 changed files
with
3,546 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
set -eux | ||
|
||
VFLAG=${VERBOSE:+-v} | ||
BFLAG="-b ./target/program.json" | ||
FLAGS="-c $CRS_PATH $VFLAG" | ||
|
||
export PROOF="$PWD/sol_honk_zk_proof" | ||
export PROOF_AS_FIELDS="$PWD/sol_honk_zk_proof_fields.json" | ||
export VK="$PWD/sol_honk_zk_vk" | ||
|
||
# Create a proof, write the solidity contract, write the proof as fields in order to extract the public inputs | ||
$BIN prove_ultra_keccak_honk_zk -o $PROOF $FLAGS $BFLAG | ||
$BIN write_vk_ultra_keccak_honk -o $VK $FLAGS $BFLAG | ||
$BIN verify_ultra_keccak_honk_zk -k $VK -p $PROOF $FLAGS | ||
$BIN proof_as_fields_honk $FLAGS -p $PROOF -o $PROOF_AS_FIELDS | ||
$BIN contract_ultra_honk_zk -k $VK $FLAGS -o ZKVerifier.sol | ||
|
||
# Export the paths to the environment variables for the js test runner | ||
export VERIFIER_PATH="$PWD/ZKVerifier.sol" | ||
export TEST_PATH=$(realpath "../../sol-test/ZKHonkTest.sol") | ||
export TESTING_HONK="true" | ||
export HAS_ZK="true" | ||
|
||
|
||
# Use solcjs to compile the generated key contract with the template verifier and test contract | ||
# index.js will start an anvil, on a random port | ||
# Deploy the verifier then send a test transaction | ||
export TEST_NAME=$(basename $PWD) | ||
node ../../sol-test/src/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// THIS FILE WILL NOT COMPILE BY ITSELF | ||
// Compilation is handled in `src/index.js` where solcjs gathers the dependencies | ||
|
||
pragma solidity >=0.8.4; | ||
|
||
import {HonkVerifier} from "./ZKVerifier.sol"; | ||
|
||
contract Test { | ||
HonkVerifier verifier; | ||
|
||
constructor() { | ||
verifier = new HonkVerifier(); | ||
} | ||
|
||
function test(bytes calldata proof, bytes32[] calldata publicInputs) public view returns (bool) { | ||
return verifier.verify(proof, publicInputs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
a68369f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.wasmconstruct_proof_ultrahonk_power_of_2/20
14624.863808
ms/iter13573.823908000002
ms/iter1.08
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ludamad @codygunton