Skip to content

Remove secret-state equality from Sponge - #40

Merged
HDauven merged 1 commit into
mainfrom
fix/remove-sponge-equality
Sep 12, 2026
Merged

HDauven merged 1 commit into
mainfrom
fix/remove-sponge-equality

Conversation

@HDauven

@HDauven HDauven commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove PartialEq from Sponge, retaining Clone, so the API no longer exposes ordinary whole-state equality over secret state and buffered output.
  • Add migration guidance and a compile-fail regression using equality-capable backend/element bounds.
  • Remove the stored domain_sep field, which becomes unused without derived equality. The constructor still includes the domain separator in the initial tag.

Fixes #39.

Compatibility

Breaking Rust API change for the next breaking release. Remove whole-sponge comparisons and Sponge: PartialEq requirements when upgrading; no replacement comparison API is introduced. This PR does not bump the package version.

Sponge state width, arithmetic, pattern encoding, field-based zeroization and backend authentication through Encryption::is_equal are unchanged. The inspected Poseidon callers keep sponges local and return outputs rather than exposing a serialized or FFI sponge layout. This is API hardening, not a claim of a demonstrated deployed timing leak.

Validation

Rust 1.96.1, final source, local checks:

  • make test: 20 debug + 20 release test executions; existing zeroize 1.5.4 consumer check passes.
  • No-default-feature tests: 13 pass.
  • make cq, documentation, and bare-metal builds with/without encryption pass.
  • Existing frozen encryption fixtures match; no fixture was regenerated.
  • Downstream release tests: Poseidon 20, Phoenix-core 29, Poseidon-Merkle 2, Rusk-core 65 pass with this SAFE source selected by Cargo patches. These are the selected existing consumer snapshots, not every downstream version or a full-node replay.
  • Negative control: restoring only PartialEq to the final source makes the new doctest fail because the supposedly non-compiling comparison compiles successfully.

Only two files ship; benchmark and investigation scaffolding remains local. No contract source, WASM, dependency or CI change is included.

Remove derived PartialEq while retaining Clone and the separate backend authentication contract. Drop the otherwise-unused stored domain separator; initialization still binds the separator into the tag.

Document migration away from whole-sponge comparisons and guard the API with a compile-fail doctest.

Fixes #39
@HDauven
HDauven merged commit 8c38f57 into main Sep 12, 2026
3 checks passed
@HDauven
HDauven deleted the fix/remove-sponge-equality branch September 12, 2026 18:27
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.

Remove secret-state equality from Sponge in the next breaking release

2 participants