Skip to content

DomainSeparator::derive: mandatory (protocol_id, sponge_info, session) and remove new / .session()#114

Open
ricardo-perello wants to merge 2 commits into
arkworks-rs:mainfrom
ricardo-perello:dsfs/domain-separator-derive
Open

DomainSeparator::derive: mandatory (protocol_id, sponge_info, session) and remove new / .session()#114
ricardo-perello wants to merge 2 commits into
arkworks-rs:mainfrom
ricardo-perello:dsfs/domain-separator-derive

Conversation

@ricardo-perello

@ricardo-perello ricardo-perello commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR updates spongefish domain separation so Fiat-Shamir transcript initialization is derived from three explicit inputs:

  • protocol_id: identifies the proof/protocol family;
  • sponge_info: identifies the transcript / sponge / compilation context;
  • session: identifies the invocation or application session.

The old DomainSeparator::new([u8; 64]) plus optional .session(...) path is removed. Callers now build a domain separator through:

DomainSeparator::derive(protocol_id, sponge_info, session).instance(&instance)

This keeps session binding mandatory at the spongefish API layer while still absorbing the instance separately before protocol messages.

Scope

This PR is intentionally scoped to the spongefish domain-separator API and its direct tests/examples.

It does not include DSFS packaging, ia-core, Argus integration, or codec relocation. Those are downstream / separate design work.

The cosmetic documentation/example preference changes from the earlier noisy branch were split out separately in #147.

Derivation

DomainSeparator::derive length-prefixes the triple:

LE32(|protocol_id|) || protocol_id ||
LE32(|sponge_info|) || sponge_info ||
LE32(|session|) || session

and absorbs it into spongefish's existing standard hash transcript. It then squeezes 32 bytes and places them in the existing 64-byte protocol tag slot as:

derived_32 || 0x00 * 32

This avoids adding a new default dependency and matches the agreed 32-byte derivation with zero padding for the existing 64-byte interface.

API Changes

  • Add DomainSeparator::derive(protocol_id, sponge_info, session).
  • Remove DomainSeparator::new.
  • Remove optional .session(...) / .without_session() construction.
  • Keep .instance(...) as the transition from domain data to prover/verifier transcript state.
  • Add DOMAIN_SEPARATOR_MACRO_SPONGE_INFO for the domain_separator! macro's default compilation tag.
  • Add DomainSeparatorPrefix for precomputing the (protocol_id, sponge_info) prefix when only the session varies.

Tests

  • Updated domain-separator tests for the new mandatory derivation path.
  • Updated StdHash and duplex transcript tests to use the derived tag.
  • Updated the Schnorr example and direct docs/tests that used the old construction path.

Locally checked with:

cargo test -p spongefish

@mmaker mmaker requested review from WizardOfMenlo and mmaker April 20, 2026 18:21
@ricardo-perello ricardo-perello marked this pull request as ready for review April 22, 2026 11:17
Comment thread Cargo.toml Outdated
license = "MIT OR Apache-2.0"
version = "0.7.0"
readme = "README.md"
version = "0.6.1"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt this a breaking change? should be 0.7 no?

@ricardo-perello ricardo-perello force-pushed the dsfs/domain-separator-derive branch 2 times, most recently from 15724ef to 092a2cf Compare May 5, 2026 15:48
@ricardo-perello ricardo-perello force-pushed the dsfs/domain-separator-derive branch from 092a2cf to bc9012c Compare May 7, 2026 10:15
@ricardo-perello

Copy link
Copy Markdown
Collaborator Author

On the DomainSeparator::session point: the current branch already supports the staged use case where (protocol_id, sponge_info) are known/preprocessed first and the session is supplied later, via:

let prefix = DomainSeparatorPrefix::new(protocol_id, sponge_info);
let domsep = prefix.with_session(session).instance(&instance);

So the runtime-session flow is still possible, just surfaced through DomainSeparatorPrefix instead of the previous .session(...) builder. Do you specifically want the old .session(...) API restored for compatibility/scope reasons, or is the prefix builder acceptable if documented more clearly?

@ricardo-perello ricardo-perello force-pushed the dsfs/domain-separator-derive branch from bc9012c to 6037fef Compare May 7, 2026 13:00
ricardo-perello added a commit to ricardo-perello/spongefish that referenced this pull request May 15, 2026
The ia-core → spongefish → ia-core → spongefish round trip left cosmetic
reformatting (doc-comment rewrites, import reordering, comment deletions) in
files that are otherwise upstream's own and functionally unchanged. Reverted
to `upstream/main` exact content:

- spongefish/src/{codecs,io,error}.rs
- spongefish/src/drivers/{ark_ec_impl,ark_ff_impl,bls12_381_impl,
  curve25519_dalek_impl,p256_impl,secp256k1_impl,p3_baby_bear,p3_koala_bear,
  p3_mersenne31,tests}.rs

Also reverted spongefish/src/domain_separator.rs to PR arkworks-rs#114's exact version
(dropped a stray blank line, two `#[allow(dead_code)]`, and a `const fn
instance` tweak that don't belong in this PR — that file is PR arkworks-rs#114's).

Net result: this PR's spongefish/ diff vs upstream is now only:
- spongefish/src/deserialize.rs — new channel-side `Deserialize` shim
- ~5 lines of spongefish/src/lib.rs (declare/export `deserialize`, drop the
  moved-out `pub mod dsfs`)
- domain_separator.rs / narg_prover.rs / narg_verifier.rs / tests.rs /
  lib.rs-macro — byte-identical to PR arkworks-rs#114 (arkworks-rs#153 stacks on arkworks-rs#114; this part
  of the diff disappears once arkworks-rs#114 merges to main)

cargo test --workspace --all-features still passes.
mmaker added a commit that referenced this pull request May 29, 2026
This PR takes out the cosmetic changes of #114
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