Add BlakeGGate AIR component with full prove+verify#421
Open
alon-f wants to merge 9 commits intostav/blake_in_circuitfrom
Open
Add BlakeGGate AIR component with full prove+verify#421alon-f wants to merge 9 commits intostav/blake_in_circuitfrom
alon-f wants to merge 9 commits intostav/blake_in_circuitfrom
Conversation
…limbs representation State words use packed u16 limbs in a single QM31: (low, high, 0, 0). All wire values are canonical M31. Input extraction uses Simd::unpack_idx. Introduces U32Wrapper<T> type for type-safe u32 packed-limbs wires. BLAKE2S_IV moved from circuit_air to circuits::blake (single source of truth). Includes blake_from_gates() and comparison test against monolithic blake. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove section header comments, numbered prefixes
- Extract blake_g_mixing() to deduplicate G mixing logic
- Extract read_u32() helper for U32Var -> u32 conversion
- Delete u32_to_qm31, use M31::from().into() directly
- Rename variables for clarity (prev_h, current_permutation, new_a/b/c/d)
- Extract constants (BLOCK_BYTES, WORDS_PER_BLOCK, N_G_CALLS_PER_ROUND)
- Fix docs (BlakeGGate message format, M31ToU32Gate, unpack_u32)
- Use crate::blake::{pack_u32, unpack_u32} in circuit.rs instead of duplicating
- Add independent test for blake_from_gates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generate address and multiplicity preprocessed columns for M31ToU32Gate (3 cols), BlakeGGate (11 cols), and TripleXorGate (5 cols). BlakeGGate uses a single shared multiplicity column for all 4 outputs, with a preprocessing-time assertion that they are identical and at most 1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Integrates the auto-generated M31ToU32 gate AIR into the circuit prover: - Preprocessed columns for all 3 decomposed gates (m31_to_u32, blake_g, triple_xor) - M31ToU32 AIR component (circuit_eval, framework eval, witness trace) - Padding in finalize_context for m31_to_u32 - Full prove+verify test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Integrates the auto-generated TripleXor gate AIR into the circuit prover: - New triple_xor component (framework eval, circuit eval, witness trace) - Preprocessed column IDs renamed to match new AIR (triple_xor_input_addr_0/1/2, triple_xor_output_addr, triple_xor_multiplicity) - Padding in finalize_context for triple_xor gates - Full prove+verify test - Updated FIBONACCI_CIRCUIT_PREPROCESSED_ROOT for N_COMPONENTS=17 The old triple_xor_32 component stays alongside (blake_gate depends on it via the TripleXor32 relation). The new triple_xor operates independently through the Gate relation with preprocessed address columns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
5428926 to
3fee2b4
Compare
Integrates the auto-generated BlakeGGate into the circuit prover: - BlakeGGate added to ComponentList, CircuitComponents, trace writing, interaction trace, statement, and prover - Preprocessed column IDs renamed to match the AIR (blake_g_gate_input_addr_a/b/c/d/f0/f1, blake_g_gate_output_addr_a/b/c/d, blake_g_gate_multiplicity) - Padding for blake_g gates in finalize_context - Full prove+verify test (test_prove_and_stark_verify_blake_g_gate_context) - Updated FIBONACCI_CIRCUIT_PREPROCESSED_ROOT for N_COMPONENTS=18 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3fee2b4 to
9d9af7f
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
blake_g_gate_input_addr_a/b/c/d/f0/f1,blake_g_gate_output_addr_a/b/c/d,blake_g_gate_multiplicity)Details
This PR is based on
stav/blake_in_circuitwhich provides the auto-generated blake_g_gate files.All three decomposed Blake gates are now fully integrated:
Test plan
test_prove_and_stark_verify_blake_g_gate_context)🤖 Generated with Claude Code
Note
High Risk
Touches core proving/verification and preprocessing logic by adding new AIR components and changing how traces/interaction claims are built, which can break soundness or make proofs unverifiable. Also updates circuit hashing/roots, so mismatches can invalidate existing fixtures and integrations.
Overview
Integrates three new AIR components into the end-to-end circuit pipeline:
BlakeGGate,M31ToU32, andTripleXor, wiring them intocircuit_air’s component list/statement and the prover’s component chain so they participate in proving, interaction traces, and lookup checks.Extends preprocessing/finalization to support these decomposed gates by adding new preprocessed columns (including renamed
blake_g_gate_*IDs), enforcing a shared multiplicity invariant forBlakeGGate, and paddingblake_g,m31_to_u32, andtriple_xorgate lists to power-of-two sizes.Updates the
circuitslayer to include new gate types plus ablake_from_gatesimplementation (usingm31_to_u32_gate,blake_g_gate,triple_xor_gate) and aU32Wrapper, refactors prover trace construction to append evals (dropping twiddle-based interpolation), and refreshes expected constants/preprocessed roots and adds coverage tests for preprocessing and prove+verify of each new gate type.Written by Cursor Bugbot for commit 9d9af7f. This will update automatically on new commits. Configure here.