Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement serde for PoseidonConstants #165

Merged
merged 6 commits into from
Nov 18, 2022
Merged

Implement serde for PoseidonConstants #165

merged 6 commits into from
Nov 18, 2022

Conversation

samuelburnham
Copy link
Member

@samuelburnham samuelburnham commented Nov 17, 2022

Manual serialization is needed for PoseidonConstants due to Arity's typenum parameter, which doesn't have an easy serde implementation but is only used in CType. Serialization is thus skipped for Arity and easily calculable PoseidonConstants fields like domain_tag and half_full_rounds.

Once const generics are workable and #125 is merged, we could instead derive serde automatically.

src/serde_impl.rs Outdated Show resolved Hide resolved
src/serde_impl.rs Outdated Show resolved Hide resolved
@porcuquine porcuquine requested a review from vmx November 17, 2022 23:23
Copy link
Contributor

@vmx vmx left a comment

Choose a reason for hiding this comment

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

Things look good to me, once the obvious TODOs are fixed.

Comment on lines 33 to 34
state.serialize_field("fr", &self.full_rounds)?;
state.serialize_field("pr", &self.partial_rounds)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how important the actual names are. I recently looked into the poseidon paper. There those are named r_f and r_p, so perhaps naming them rf and rp would make sense.

@samuelburnham samuelburnham marked this pull request as ready for review November 18, 2022 16:30
@samuelburnham samuelburnham changed the title (WIP) Implement serde for PoseidonConstants Implement serde for PoseidonConstants Nov 18, 2022
Cargo.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@porcuquine porcuquine left a comment

Choose a reason for hiding this comment

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

This looks great, @samuelburnham, thank you. I think it also closes #146. Can you confirm, and if so, comment/close once this merges?

@porcuquine porcuquine linked an issue Nov 18, 2022 that may be closed by this pull request
@porcuquine porcuquine merged commit 640d350 into argumentcomputer:master Nov 18, 2022
@porcuquine porcuquine deleted the serde branch November 18, 2022 23:59
storojs72 pushed a commit that referenced this pull request Jan 12, 2023
* (WIP) Implement serde for PoseidonConstants

* Compress struct field names, format

* Formatting, clippy

* Add serde hashing tests

* Remove pasta patch

* Remove comments
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.

Serialize/Deserialize Poseidon Constants
3 participants