Skip to content

test: cover the Poseidon2 precompile and the sp1-lib hasher - #2943

Open
4waan wants to merge 3 commits into
succinctlabs:mainfrom
4waan:test/poseidon2-precompile
Open

4waan wants to merge 3 commits into
succinctlabs:mainfrom
4waan:test/poseidon2-precompile

Conversation

@4waan

@4waan 4waan commented Aug 23, 2026 •

Copy link
Copy Markdown

just a side on the plate for #2942, which covers the Poseidon2 permutation itself in slop-koala-bear.. this one pins the chip and the guest API

what i added:

A guest program driving both hashing surfaces with three suites over it:

Crate Catches
sp1-core-machine The precompile chip's AIR, memory-access columns and range checks, on a real execution
sp1-core-executor In-guest digests diverging from inner_perm; the byte packing and length prefix as wire format
sp1-hypercube A wrong linear layer, a bad witness, or a witness/AIR mismatch, named locally instead of as a failed proof

Plus a #[cfg(test)] single-row constructor on DebugConstraintBuilder (mirroring the one already inlined in debug_constraints).. also a lil comment correction in crates/zkvm/lib/src/poseidon2.rs: the length-prefix bound is usize not 2^192!

Cost

The proving test adds one small proof to the workspace suite on x86 and ARM, 15.3s locally in --release. Inputs are two field blocks and two short messages, roughly five permutation calls, in line with the existing precompile tests. The other 9 tests need no proof.

4waan added 3 commits August 23, 2026 11:11
Adds crates/test-artifacts/programs/poseidon2, a guest that drives both
Poseidon2 surfaces sp1-lib exposes: the raw rate-8 sponge on
Poseidon2State and the length-prefixed byte hasher Poseidon2ByteHash. It
reads field blocks and byte messages from stdin and commits every digest
so a host can compare them. Registers the crate in the programs
workspace and exports POSEIDON2_ELF. No program in the tree previously
issued the POSEIDON2 syscall, so nothing could reach the precompile.
Proves RiscvAir::Poseidon2 on a real execution, which no test did
before. Checks in-guest digests against inner_perm on the host over
messages that straddle the 24-byte block boundary and messages differing
only by trailing zeros. Covers the AIR operation directly: both
hand-rolled linear layers against Plonky3's matrices, the generated
witness against the reference permutation, and that witness against the
constraints that consume it, perturbing every column in turn so the
constraint test cannot pass vacuously. Adds a #[cfg(test)] single-row
constructor to DebugConstraintBuilder to make that possible. Corrects a
comment in sp1-lib: the length-prefix bound is usize, not 2^192.

This branch has not been deployed

No deployments
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