Skip to content

runtime hash selection with SHA256, Blake3, Keccak support#251

Merged
ashpect merged 5 commits intomainfrom
ysh/generic-hash-config
Mar 6, 2026
Merged

runtime hash selection with SHA256, Blake3, Keccak support#251
ashpect merged 5 commits intomainfrom
ysh/generic-hash-config

Conversation

@yash25198
Copy link
Copy Markdown
Collaborator

@yash25198 yash25198 commented Jan 13, 2026

Summary

  • Runtime hash selection: Replace compile-time feature flags with runtime HashConfig enum, allowing selection between Skyscraper, SHA256, Keccak, and BLAKE3 without recompilation
  • Uses WHIR 2.0's HashEngine API — standard hashes (SHA2, Keccak, Blake3) use WHIR's built-in engines; Skyscraper is registered as a custom engine
  • Runtime TranscriptSponge enum dispatches Fiat-Shamir sponge calls to the active hash variant

Changes

  • New HashConfig enum with serde support for runtime hash algorithm selection
  • TranscriptSponge runtime-dispatch enum wrapping all four sponge implementations
  • SkyscraperHashEngine implementing WHIR's HashEngine trait with batched SIMD leaf hashing
  • Updated CLI prepare command to accept --hash configuration
  • Binary file format updates to store hash config in headers (version bumps for prover/verifier/nps formats)
  • Hash benchmarks (cargo bench --bench hash_bench) covering leaf hash, compression, Merkle layers, and sponge operations

Testing

# Prepare with different hash configurations
provekit-cli prepare --hash sha256 ...
provekit-cli prepare --hash blake3 ...
provekit-cli prepare --hash keccak ...
provekit-cli prepare --hash skyscraper ...  # default

Performance

Operation Skyscraper (baseline) Blake3 Keccak SHA-256
Merkle commit (524K leaves) 22.6 ms (1.00x) 3.30 ms (6.85x) 15.6 ms (1.45x) 6.35 ms (3.56x)
Merkle commit (262K leaves) 10.0 ms (1.00x) 1.66 ms (6.02x) 8.99 ms (1.11x) 2.14 ms (4.67x)
Matrix commit (524K x 8) 146 ms (1.00x) 15.7 ms (9.30x) 44.6 ms (3.27x) 21.6 ms (6.76x)
IRS commit (1M) 337 ms (1.00x) 201 ms (1.68x) 272 ms (1.24x) 262 ms (1.29x)
inner_blinded_prove 410 ms (1.00x) 306 ms (1.34x) 341 ms (1.20x) 288 ms (1.42x)

@yash25198 yash25198 requested a review from Bisht13 January 13, 2026 17:32
@yash25198 yash25198 changed the title Ysh/generic hash config runtime hash selection with SHA256, Blake3, Keccak support Jan 13, 2026
Comment thread provekit/common/src/file/bin.rs
Comment thread provekit/common/src/file/bin.rs
Comment thread provekit/common/src/blake3/hash.rs Outdated
Comment thread provekit/common/src/sha256/sponge.rs Outdated
Comment thread provekit/common/src/blake3/sponge.rs Outdated
Comment thread provekit/prover/src/lib.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread provekit/verifier/src/lib.rs Outdated
@Bisht13
Copy link
Copy Markdown
Collaborator

Bisht13 commented Jan 16, 2026

Can we add e2e tests for all hashes which includes the prepare, prove and verify step?

@yash25198 yash25198 force-pushed the ysh/generic-hash-config branch from f552f33 to febd3a0 Compare February 24, 2026 06:15
Comment thread provekit/common/src/file/mod.rs Outdated
Comment thread provekit/common/src/hash_config.rs
@yash25198 yash25198 force-pushed the ysh/generic-hash-config branch from 4c7446c to 7c6f79d Compare March 3, 2026 18:10
@yash25198 yash25198 force-pushed the ysh/generic-hash-config branch from 5d51ed5 to e64ac14 Compare March 3, 2026 18:22
@yash25198 yash25198 requested a review from ashpect March 5, 2026 05:48
Comment thread provekit/common/src/transcript_sponge.rs
Comment thread provekit/common/src/noir_proof_scheme.rs
Comment thread provekit/common/src/file/mod.rs
@ashpect ashpect merged commit e5d2312 into main Mar 6, 2026
3 checks passed
@Bisht13 Bisht13 deleted the ysh/generic-hash-config branch March 6, 2026 06:55
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.

3 participants