Repository navigation
sha2: succinct patch for 0.11.0 - #10
sebastianst wants to merge 2 commits into
Conversation
Forward-port of patch-sha2-0.10.9-sp1-6.2.0 onto upstream sha2-v0.11.0. On target_os = "zkvm" / target_vendor = "succinct", SHA-256 compression routes to the syscall_sha256_extend + syscall_sha256_compress precompiles; every other target keeps the stock 0.11 backend selection unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
🤖 Claude Fable 5.1 says: zkVM validation done, and the Run locally with the |
|
🤖 Claude Fable 5.1 says: Thanks for cutting |
This branch is one commit on top of upstream tag
sha2-v0.11.0(ffe0939) and is meant to be taggedpatch-sha2-0.11.0-sp1-6.2.0(alias-sp1-6.0.0), not merged — same shape aspatch-sha3-0.11.0-sp1-6.0.0. The PR targetspatch-sha3-v0.11.0only because it is the one branch here that already containssha2-v0.11.0, so the diff shows just this commit (2 files, +80/−1): ethereum-optimism@12e493aecbe2Why
revm-precompile 42 (revm 42, reth v2.5.0) requires
sha2 = "0.11". A[patch.crates-io]entry pointing atpatch-sha2-0.10.9-sp1-6.2.0does not apply to it — cargo only warns:and resolves
sha2 0.11.0from crates.io unpatched. So every SP1 program executing a current revm runs SHA-256 in software, silently. In our guest lockfile both copies are present side by side: the patched0.10.9fork256/p256/kzg-rs/sp1-zkvm/alloy-eips, and an unpatched0.11.0whose only dependent isrevm-precompile 42.0.1.Tracking issue: ethereum-optimism/optimism#22890
What
Forward-port of
patch-sha2-0.10.9-sp1-6.2.0onto upstreamsha2-v0.11.0: same cfg gate (all(target_os = "zkvm", target_vendor = "succinct")), same rawextern "C"syscall declarations, same compress body — the signature is unchanged in 0.11 (fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]])), 0.11 just dropped theGenericArraywrapper that the 0.10 patch had to unwrap.Adaptations:
unsafe extern "C"for edition 2024,pub(super)visibility to match the other 0.11 backends, and onecfg_if!arm ahead of 0.11's new backend selection (which moved from cargo features to thesha2_backend/sha2_256_backendcfgs).No
Cargo.tomlchange and nosp1-libdependency — same shape aspatch-sha3-0.11.0-sp1-6.0.0. 2 files, +80/−1.Verification
Host
cargo check -p sha2andcargo test -p sha2pass (14 tests + 2 doctests: KAT, serialization, rand vectors).succinct.rswas type-checked separately for edition 2024, since the host build cfgs it out.This has not been run in the zkVM. Please add a
sha2-v0-11-0entry topatch-testing/sha/and run it — roughly 30 lines: an optional dep, a feature, a[[bin]], and a[patch.crates-io]entry, mirroring the existingv0-10-9wiring. Worth covering empty input, multi-block input, and an unaligned first block (the aligned fast path reinterprets the block as*const u64, so it is the one thing a host check cannot prove).Judgement calls / open questions
Best guess taken in the code, happy to change any of these:
cfg_if!arm — so zkvm wins over an explicitly requestedsha2_256_backend. The alternative is a dispatch helper like sha3'spermute. sha2 has a singlecompressbinding so the extra indirection did not seem to earn its place, but if you prefer the sha3 shape for consistency I will restructure.unexpected_cfgswarning. sha2 0.11 sets[lints.rust.unexpected_cfgs] level = "warn", sotarget_vendor = "succinct"produces a warning on host builds (sha3 0.11 has no[lints]section, which is why its patch is warning-free). Harmless downstream — cargo caps lints for git deps — but you may want to allow it inCargo.toml.🤖 Co-created with Claude Fable 5.1