-
Notifications
You must be signed in to change notification settings - Fork 587
chore: opt sol verifier scope + renaming #20069
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
Merged
iakovenkos
merged 3 commits into
merge-train/barretenberg
from
si/opt-sol-scope-renaming
Feb 2, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...erg/cpp/src/barretenberg/dsl/acir_proofs/OPTIMIZED_HONK_VERIFIER_AUDIT_SCOPE.md
This file contains hidden or 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,73 @@ | ||
| # Optimized Honk Verifier - Audit Scope | ||
|
|
||
| **Primary file to audit**: `barretenberg/sol/src/honk/optimised/honk-optimized.sol.template` | ||
|
|
||
| ## Generation Pipeline | ||
|
|
||
| The optimized verifier is a **circuit-agnostic** template. Blake is used only as the test circuit for Solidity test coverage. | ||
|
|
||
| 1. **honk-optimized.sol.template** | ||
| - Generic Honk verifier logic (sumcheck, shplemini, KZG) | ||
| - Contains Blake VK values as placeholders for testing | ||
| - Contract name: `BlakeOptHonkVerifier` (for Solidity tests) | ||
|
|
||
| 2. **sync_blake_opt_vk.sh** injects VK from `BlakeHonkVerificationKey.sol` | ||
|
|
||
| 3. **honk-optimized.sol** (testable contract) | ||
| - Used by Solidity tests (`blakeOpt.t.sol`) | ||
| - Has concrete Blake circuit VK values | ||
|
|
||
| 4. **copy_optimized_to_cpp.sh** replaces VK values | ||
| - Replaces hardcoded VK values with `{{ TEMPLATE }}` placeholders | ||
| - Renames contract to `HonkVerifier` | ||
|
|
||
| 5. **honk_optimized_contract.hpp** (C++ template) | ||
| - Contains `HONK_CONTRACT_OPT_SOURCE` with `{{ placeholders }}` | ||
| - `get_optimized_honk_solidity_verifier(vk)` injects any circuit's VK | ||
|
|
||
| 6. **bb CLI** with `--optimized` flag produces **HonkVerifier.sol** | ||
| - Circuit-specific VK values injected | ||
| - Ready for on-chain deployment | ||
|
|
||
| ## What It Does | ||
|
|
||
| Gas-optimized Solidity assembly verifier for Honk proofs. Uses EVM precompiles: | ||
| - `ecAdd` (0x06), `ecMul` (0x07), `ecPairing` (0x08) | ||
|
|
||
| ## C++ Reference | ||
|
|
||
| Must match: `UltraVerifier_<UltraKeccakFlavor, DefaultIO>` in `ultra_honk/ultra_verifier.*` | ||
|
|
||
| ## Verification Steps (Solidity ↔ C++) | ||
|
|
||
| | Step | Solidity | C++ | | ||
| |------|----------|-----| | ||
| | VK Loading | `loadVk()` | `OinkVerifier::verify()` | | ||
| | Public Inputs | `computePublicInputDelta()` | `OinkVerifier::verify()` | | ||
| | Sumcheck | `verifySumcheck()` | `SumcheckVerifier::verify()` | | ||
| | Shplemini | `computeBatchOpeningClaim()` | `ShpleminiVerifier::compute_batch_opening_claim()` | | ||
| | KZG | `batchAccumulate()` + pairing | `KZG::reduce_verify_batch_opening_claim()` | | ||
|
|
||
|
|
||
| ## Upcoming Change: Public Input Encoding | ||
|
|
||
| **Current**: 4 limbs per Fq (16 Fr elements for pairing points) | ||
| **Planned**: 2 limbs per Fq (8 Fr elements for pairing points) | ||
|
|
||
| Affects pairing point encoding in final verification step. | ||
|
|
||
| ## Testing | ||
|
|
||
| ```bash | ||
| cd barretenberg/sol | ||
|
|
||
| # Primary test for optimized verifier | ||
| forge test --match-path test/honk/blakeOpt.t.sol | ||
|
|
||
| # Regenerate after changes | ||
| ./scripts/sync_blake_opt_vk.sh && ./scripts/copy_optimized_to_cpp.sh -f | ||
| ``` | ||
|
|
||
| **Primary test**: `blakeOpt.t.sol` - tests the optimized assembly verifier | ||
|
|
||
| **Standard verifier tests** (different code path, for reference only): `Add2`, `Blake`, `ECDSA`, `Recursive` (+ ZK variants) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| blake-opt.sol | ||
| blake-opt.sol.bak | ||
| honk-optimized.sol | ||
| honk-optimized.sol.bak |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
blake-opt did always confuse me