Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whitenois3/huff-snark-verifier
Generate an optimized Groth16 SNARK verification smart contract for use on EVM-based blockchains.
https://github.com/whitenois3/huff-snark-verifier
Last synced: about 2 months ago
JSON representation
Generate an optimized Groth16 SNARK verification smart contract for use on EVM-based blockchains.
- Host: GitHub
- URL: https://github.com/whitenois3/huff-snark-verifier
- Owner: whitenois3
- License: gpl-3.0
- Created: 2022-08-24T00:34:22.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-04T11:04:34.000Z (over 2 years ago)
- Last Synced: 2024-08-03T16:09:26.698Z (5 months ago)
- Language: Solidity
- Homepage:
- Size: 300 KB
- Stars: 126
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-huff - huff-snark-verifier - based blockchains. (Huff projects you can learn from and contribute to)
README
# huff-snark-verifier • [![ci](https://github.com/whitenois3/huff-snark-verifier/actions/workflows/ci.yaml/badge.svg)](https://github.com/whitenois3/huff-snark-verifier/actions/workflows/ci.yaml)
> `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](https://github.com/whitenois3/huff-snark-verifier/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](https://github.com/iden3/snarkjs).
1. Install `huffv` (Requires the [rust toolchain](https://www.rust-lang.org/tools/install) to be installed.)
```
git clone [email protected]:whitenois3/huff-snark-verifier.git
cd huff-snark-verifier && cargo build
cargo install --path .
```2. Generate verification contract
```
huffv ./path/to/verification_key.json [-o ]
```3. Compile verification contract with [huffc](https://github.com/huff-language/huff-rs)
```
huffc ./Verifier.huff -b
```## Testing
To run tests for this repo, you will need [forge](https://github.com/foundry-rs/foundry),
[huffc](https://github.com/huff-language/huff-rs), and the [rust toolchain](https://www.rust-lang.org/tools/install) installed.```sh
# 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](#Testing) section above.
### To Do
- [x] Tests for proofs with multiple inputs & fail cases.
- [ ] Would like a few more tests here with circuits that have more public inputs.
- [x] Finish `huffv`.
- [ ] Possibly clean up with the [handlebars crate](https://crates.io/crates/handlebars) instead of `.replace`?
- [ ] External verification function template.
- [x] Add documentation / README.
- [ ] Clean and update comments. (Double check stack comments!)
- [ ] More runtime gas / code size optimizations.## License
Released under the [GNU GPLv3 License](./LICENSE.md). Go wild.