perf(keccak): trim c_aux and skip zero-rotation split witness#1309
Open
perf(keccak): trim c_aux and skip zero-rotation split witness#1309
Conversation
Reduce Keccak witness width and range lookups without changing semantics.\n\n- Trim c_aux storage from 5 prefix stages to 4 (drop j=0 copy stage),\n reducing committed columns by 40 and removing redundant init-equality constraints.\n- Special-case RHOPI lanes with rotation=0 to direct byte equality, skipping\n split witnesses/range checks for that lane.\n- Reduce rotation_witness width from 196 to 192 and update\n RANGE_LOOKUPS_PER_ROUND from 290 to 286 accordingly.\n- Keep lookup multiplicity accounting and Keccak tests consistent with the\n new layout.
0280726 to
c32a5c9
Compare
There was a problem hiding this comment.
Pull request overview
Performance-focused cleanup of the Keccak-f lookup-based precompile circuit, reducing redundant witness materialization and a small amount of per-round range-check/rotation-witness work while keeping the same lookup-based constraint model.
Changes:
- Shrinks
c_auxwitness materialization by dropping thej=0prefix stage and updating Theta prefix-XOR constraints/witness generation accordingly. - Skips split-rotation witnesses/range checks for the single
rot == 0RhoPi lane by constraining direct byte equality instead. - Updates per-round accounting constants and refactors Chi byte constraints / multiplicity recording via small helper functions.
Agent-Logs-Url: https://github.com/scroll-tech/ceno/sessions/3ef48921-ce7d-4984-8eae-0f3ab8b4577f Co-authored-by: hero78119 <3962077+hero78119@users.noreply.github.com>
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.
Problem
lookup_keccakfinceno_zkvm/src/precompiles/lookup_keccakf.rshad redundant witness materialization in a prover hot path:c_auxstored thej=0prefix stage, which is a direct copy of input state bytes.0still used split-rotation witness/range checks.This increased committed columns and per-round range lookup load without adding new information.
Design Rationale
This change trims only redundant witness encoding while preserving Keccak semantics and existing lookup model (
u8 x u8 -> u8):c_auxonly forj=1..4,rot == 0lane with direct byte equality instead of split witness decomposition.Trade-off: slightly more branching in builder/witness generation for reduced witness width and range lookups.
Change Highlights
ceno_zkvmKeccakWitCols::c_auxreduced from200to160(drop storedj=0prefix copy).state8[0][i]forj=1.c_auxlayout.rotation_witnessreduced from196to192.rot == 0lane constrained by direct byte equality (skip split witness/range checks for that lane).RANGE_LOOKUPS_PER_ROUNDreduced from290to286.0280726b.Benchmark / Performance Impact
This PR is performance-oriented (column/lookup reduction). End-to-end benchmark numbers are not included yet in this PR description.
Testing
cargo check -p ceno_zkvm --lib RUST_MIN_STACK=67108864 cargo test -p ceno_zkvm lookup_keccakf::tests::test_keccakf -- --nocaptureCopilot Reviewer Directive (keep this section)
When Copilot reviews this PR, apply
.github/copilot-instructions.mdstrictly.