runtime hash selection with SHA256, Blake3, Keccak support#251
runtime hash selection with SHA256, Blake3, Keccak support#251
Conversation
| @@ -0,0 +1,128 @@ | |||
| // SHA256 sponge for Fiat-Shamir transcripts | |||
There was a problem hiding this comment.
This implements a custom duplex sponge construction using SHA256. A few questions:
- Has this construction been reviewed for cryptographic soundness in the Fiat-Shamir context?
- The squeeze_unchecked uses a counter mode (self.squeeze_count). Is this secure for arbitrary-length squeezing in Fiat-Shamir transcripts?
Also, I remember spongefish having their own impl of these for different hashes, do we have them implemented?
There was a problem hiding this comment.
- Cryptographic soundness — Sha256Sponge follows the same counter-mode pattern as spongefish's DigestBridge<D: Digest>. Each squeeze block is H(state || counter), indistinguishable from random under ROM.
- Counter-mode security — Yes — spongefish uses the same approach with domain separation masks (0x00 absorb, 0x01 squeeze, 0x02 squeeze_end).
- Spongefish implementations
- Keccak sponge: Re-exported directly from spongefish::keccak::Keccak
- SHA256 sponge: Spongefish provides DigestBridge; a simpler version with equal security is used here
- BLAKE3 sponge: Not provided by spongefish — the implementation uses native finalize_xof(), which is the correct approach since BLAKE3 is designed as a XOF
- Keccak/BLAKE3 PoW: Re-exported from spongefish-pow
- SHA256 PoW: Custom implementation (spongefish-pow doesn't provide one)
There was a problem hiding this comment.
Can we have an inline comment addressing this?
| @@ -0,0 +1,108 @@ | |||
| //! BLAKE3 sponge for Fiat-Shamir transcripts. | |||
There was a problem hiding this comment.
Similar to the SHA256 sponge, this is a custom duplex construction. BLAKE3's XOF mode is used for squeezing which is good, but the absorb/squeeze state machine (ratcheting on mode switch) should be documented or reviewed for Fiat-Shamir security.
Cargo.toml
Outdated
| # 3rd party | ||
| anyhow = "1.0.93" | ||
| argh = "0.1.12" | ||
| arrayvec = "0.7" |
provekit/verifier/src/lib.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl Verify |
There was a problem hiding this comment.
Verifier impl Verify duplicated, add impl_verify!
|
Can we add e2e tests for all hashes which includes the prepare, prove and verify step? |
Summary
HashConfigenum, allowing selection between Skyscraper, SHA256, Keccak, and BLAKE3 without recompilationBenchmarks
Primitive Operations (16 field elements)
Merkle Layer (4096 nodes)
End-to-End Proving (complete_age_check, 524k leaves)
Changes
HashConfigenum with serde support for runtime hash algorithm selectionruntime_hash!macro for compile-time monomorphization based on runtime configprepare,prove,verify) to accept--hashconfigurationTesting