Awesome
<img align="right" width="150" height="150" top="100" src="./assets/no_step_on_snark.png">huff-snark-verifier •
huff-snark-verifier
offers an optimized Groth16 SNARK verification smart contract generator for EVM-based blockchains.
Warning This software is experimental, and it has not been audited. Please proceed with caution, and report any bugs in the Issues.
Gas Report
VERSION | GAS CONSUMED |
---|---|
Solidity (1 input) | 207009 |
Huff (1 input) | 188762 |
Solidity (2 inputs) | 215009 |
Huff (2 inputs) | 195354 |
Usage
To generate a Huff SNARK verification contract, you must first have a verification key created by snarkjs.
- Install
huffv
(Requires the rust toolchain to be installed.)
git clone git@github.com:whitenois3/huff-snark-verifier.git
cd huff-snark-verifier && cargo build
cargo install --path .
- Generate verification contract
huffv ./path/to/verification_key.json [-o <output_file_path>]
- Compile verification contract with huffc
huffc ./Verifier.huff -b
Testing
To run tests for this repo, you will need forge, huffc, and the rust toolchain installed.
# Regenerate test contracts
make tests
# Test sample Huff verification contracts against the Solidity version
forge test -vvv
Contributing
All contributions are welcome- create a fork and submit a PR! Please adhere to the PR template provided :smile:
You can test your changes to the template contract by regenerating the single-input & multi-input sample verifiers and running forge test
. See the Testing section above.
To Do
- Tests for proofs with multiple inputs & fail cases.
- Would like a few more tests here with circuits that have more public inputs.
- Finish
huffv
.- Possibly clean up with the handlebars crate instead of
.replace
?
- Possibly clean up with the handlebars crate instead of
- External verification function template.
- Add documentation / README.
- Clean and update comments. (Double check stack comments!)
- More runtime gas / code size optimizations.
License
Released under the GNU GPLv3 License. Go wild.