perf(keccak): inline θ/ρ halfword shifts as μ-gated identities, drop 120 HWSL sends/row - #889
Merged
Merged
Conversation
…120 HWSL sends/row Replace KECCAK_RND's 120 HWSL bus sends per row (θ rotate-by-1: 20, ρ shifts: 100) with degree-2 linear identities over the same committed cells: μ · (in · 2^rnc − right · 2^16 − left) = 0. The existing IS_BYTE and IS_BIT checks make the split unique — given left, right ∈ [0, 2^16), the pair is the Euclidean quotient/remainder of in · 2^rnc ÷ 2^16, and all values stay < 2^32 ≪ p. Sends/row 1151 → 1031 ⇒ −60 aux extension columns (−180 committed base cells/row, ~4.3k/permutation), zero new columns. Constraints 20 → 140, all degree ≤ 3; max_degree() unchanged. Measured −6.8% median prover time on a pure-keccak guest (see the PR for the full A/B). Matches the chip spec as updated by the research team on spec/main (d397668, #873).
Contributor
Author
|
/bench |
Contributor
Author
|
/bench-gpu |
GPU Benchmark (ABBA) —
|
Contributor
Author
|
/bench-gpu |
Benchmark — real block (
|
| Metric | main | PR | Δ |
|---|---|---|---|
| Peak heap | 52097 MB | 51975 MB | -122 MB (-0.2%) ⚪ |
| Prove time | 159.529s | 158.298s | -1.231s (-0.8%) ⚪ |
✅ No significant change.
Prove-time spread 1.9% (156.677s / 159.747s / 158.543s / 157.769s / 158.298s)
Commit: 6b538c6 · Baseline: cached · Runner: self-hosted bench
Contributor
Author
|
/bench |
Contributor
Author
|
/bench-gpu |
Contributor
Author
|
/bench 5 |
ColoCarletti
approved these changes
Aug 3, 2026
Contributor
Author
|
/bench-gpu 8 |
Contributor
Author
|
/bench-gpu 8 |
This was referenced Aug 5, 2026
MauroToscano
added a commit
that referenced
this pull request
Aug 13, 2026
…alsification gap
The runbook omitted tamper_test.py, so the documented path ran no
removed-constraint control at all; add it and say why it is not optional.
The sibling-verifications section claimed a keccak-sponge gate that exists in
no ref. Cite only the BLAKE3 gate, by branch, since it is unmerged.
The ByteAlu contract listed a nonexistent ADD op and omitted OR; the real row
set is {XOR, AND, OR}, of which keccak_rnd uses XOR and AND.
The KeccakRc contract said nothing about the committed padding rows 24..31
(rc = 0), which it does not cover and which the gate assumes unreachable.
keccak_rnd.rs is byte-identical across main, this branch and 6a28012 (blob
51b7759), so that claim stands. The rs:NNN citations were correct against the
pre-#889 revision d83b4d9 and were invalidated by #889; two of them cite
BusId::Hwsl senders that #889 deleted outright, so the old note's 'the
referenced constructs are unchanged' was false.
Finally, record that a constraint encoded as a variable's sort cannot be
falsified by any negative control: AreBytes and the theta-carry IS_BIT are
load-bearing in the circuit but unremovable from the model, so deleting them
from the Rust would leave this gate green.
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.
What
Replace the 120 HWSL bus sends per KECCAK_RND row (θ rotate-by-1: 20, ρ shifts: 100) with μ-gated degree-2 linear identities over the same committed cells:
The existing IS_BYTE and IS_BIT checks make the split unique: given
left, right ∈ [0, 2^16), the pair is the Euclidean quotient/remainder ofin · 2^rnc ÷ 2^16(all values < 2^32 ≪ p, so field semantics = integer semantics). A shift by a compile-time constant is field-linear, so the lookup bought nothing the identity doesn't — it only paid LogUp aux.max_degree()unchanged)Spec
This matches the chip spec as updated by the research team on
spec/main(d397668, #873), which replaces the θ/ρ HWSL interactions with the same arith identities. This PR intentionally carries only the Rust code;main's copy ofspec/src/keccak_round.tomlstill shows the HWSL form and needs the tooling const-propagation from #873 to typecheck the new one, so syncing it is left to the spec-sync flow.Supersedes #860, which carried the same code plus an alternative spec toml and the z3 verification evidence; see there for the formal-equivalence gate and the full A/B.
Bench
From #860, pure-keccak guest (5000 keccak-f syscalls, single-epoch continuation proof), 32-core box, alternated A/B ×4: −6.8% median prover time (13.982s → 13.027s, distributions disjoint, cv ≈ 1.3%). keccak_rnd was 86.6% of committed cells in that bench; the measured committed-cell delta matched the predicted −180 cells/row. Measured before the transcript rewrite (#841) landed, so worth a fresh
/benchhere before merge.Tests
test_keccak_constraint_counts(140),test_keccak_bitwise_ops_count(HWSL 2880 → 0),test_keccak_bus_interaction_counts,test_keccak_column_countskeccak_rnd_constraint_set_folder_capture_agree(prover folder ≡ verifier folder ≡ captured IR)test_prove_elfs_keccak,_keccak_multi_call(tiny-keccak cross-check),_unaligned_state_addr(tamper still rejected)make lintclean