Skip to content

Add ROMode for configurable Poseidon sponge width#490

Merged
srinathsetty merged 4 commits intomainfrom
poseidon
Apr 2, 2026
Merged

Add ROMode for configurable Poseidon sponge width#490
srinathsetty merged 4 commits intomainfrom
poseidon

Conversation

@srinathsetty
Copy link
Copy Markdown
Collaborator

@srinathsetty srinathsetty commented Apr 2, 2026

Add an ROMode enum (Wide / Narrow) to ROTrait and ROCircuitTrait with new_with_mode() constructors, enabling callers to select a reduced-width Poseidon sponge without introducing new type parameters.

Exisiting code

ROMode defaults to Wide, new() is unchanged, and PoseidonConstantsCircuit/PoseidonRO/PoseidonROCircuit retain their existing type signatures. Callers opt in to narrow mode via new_with_mode(constants, ROMode::Narrow).

@srinathsetty srinathsetty force-pushed the poseidon branch 2 times, most recently from f0d1847 to 81e4e8e Compare April 2, 2026 19:40
@srinathsetty srinathsetty changed the title make Poseidon RO generic over arity Add ROMode for configurable Poseidon sponge width Apr 2, 2026
Add ROMode enum (Wide/Narrow) to ROTrait and ROCircuitTrait with
new_with_mode() constructors. Wide (U24) is the default; Narrow (U5)
uses fewer constraints per squeeze for lightweight transcripts.

PoseidonConstantsCircuit now holds constants for both widths.
PoseidonRO and PoseidonROCircuit dispatch based on mode at squeeze time.

Also add set_compact() on ROCircuitTrait for backends that support
trading constraints for fewer non-zeros.
@iontzialla
Copy link
Copy Markdown
Contributor

Is this fully backwards compatible? Seems like it changes the serialization of PoseidonConstantsCircuit which seems to be part of PublicParams. So if any user has previously serialized public params they won't be able to parse it after the updates, right?

@srinathsetty
Copy link
Copy Markdown
Collaborator Author

Is this fully backwards compatible? Seems like it changes the serialization of PoseidonConstantsCircuit which seems to be part of PublicParams. So if any user has previously serialized public params they won't be able to parse it after the updates, right?

Good point! Fixed PR description.

@srinathsetty srinathsetty merged commit 90fa317 into main Apr 2, 2026
12 checks passed
@srinathsetty srinathsetty deleted the poseidon branch April 5, 2026 01:13
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.

2 participants