Skip to content

whitenois3/huff-snark-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

huff-snark-verifier • ci

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.

  1. 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 .
  1. Generate verification contract
huffv ./path/to/verification_key.json [-o <output_file_path>]
  1. 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 😄

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.
  • 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.

About

Generate an optimized Groth16 SNARK verification smart contract for use on EVM-based blockchains.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published