Skip to content

perf(crypto): wire keccak_permute ecall into merkle/transcript/grinding#802

Open
Oppen wants to merge 1 commit into
mainfrom
perf/wire_keccak_recursion
Open

perf(crypto): wire keccak_permute ecall into merkle/transcript/grinding#802
Oppen wants to merge 1 commit into
mainfrom
perf/wire_keccak_recursion

Conversation

@Oppen

@Oppen Oppen commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Route the STARK verifier's Keccak-256 usage (Merkle tree backends, Fiat-Shamir transcript, FRI grinding) through the keccak_permute precompile on the riscv64 guest, via a PlatformKeccak256 digest wrapper around lambda_vm_syscalls::keccak::Keccak256; falls back to software sha3 on host.
  • Excludes the riscv-only syscalls crate from the root workspace (exclude = ["syscalls"]): making it reachable from crypto/crypto via a target-gated path dependency caused Cargo to auto-adopt it as an implicit workspace member, so cargo test tried to run its bare-metal unit tests on host and aborted.
  • Adds an end-to-end guest test (keccak_precompile) exercising the ecall-backed sponge against known Keccak-256 vectors (empty, rate-1, exactly-rate, multi-block), covering the padding edge cases.

Cycle comparison (recursion guest, blowup8 preset)

before after speedup
single query 5,234,002,718 1,722,846,582 3.04x
multi query 22,494,934,472 7,687,016,693 2.93x

Test plan

  • make test-profile-recursion-single / -multi before and after (cycles above)
  • test_recursion_execute_1query — in-VM verify accepts with the ecall-backed hasher
  • new test_keccak_precompile guest test — known-answer vectors incl. padding edge cases
  • make lint
  • make test — all pass except math-cuda CUDA tests (expected: no GPU on this machine)

Route the STARK verifier's Keccak-256 usage (Merkle tree backends,
Fiat-Shamir transcript, FRI grinding) through the keccak_permute
precompile on the riscv64 guest via a new PlatformKeccak256 digest
wrapper, falling back to software sha3 on host. The guest previously
used sha3's software permutation exclusively, making it the dominant
verifier cost.

Recursion guest cycles (blowup8 preset):
- single query:  5,234,002,718 -> 1,722,846,582  (3.04x)
- multi query:  22,494,934,472 -> 7,687,016,693  (2.93x)

Also excludes the riscv-only `syscalls` crate from the root workspace:
making it reachable from crypto/crypto (a workspace member) via a
target-gated path dependency caused Cargo to auto-adopt it as an
implicit member, so `cargo test` tried to run its bare-metal unit
tests on host and aborted.

Adds an end-to-end guest test (keccak_precompile) exercising the
ecall-backed sponge against known Keccak-256 vectors, covering the
padding edge cases (empty, rate-1, exactly-rate, multi-block input).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant