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

Consider implementing (de)serialization for base types (Fp, Fq) #77

Open
bazzilic opened this issue Aug 17, 2023 · 1 comment
Open

Consider implementing (de)serialization for base types (Fp, Fq) #77

bazzilic opened this issue Aug 17, 2023 · 1 comment

Comments

@bazzilic
Copy link

It is quite typical, at least in my experience, for code using pasta_curves crate to have the necessity to persist or transfer structs with fields of types Fp and Fq, which requires (de)serialization.

As Rust doesn't allow implementing traits for imported structs, we have to manually write (de)serializers for every struct that contains Fp or Fq fields instead of being able to just do a simple #[derive].

Would you consider adding serialization impl's to these types? At least for some popular serialization libraries such as serde and borsh. The implementations could be behind a feature flag. The change, I believe, would be as much as adding a #[derive(Serialize,Deserialize,BorshSerialize,BorshDeserialize)] to the struct declaration.

I can do a PR, if you prefer.

@bazzilic
Copy link
Author

I don't know why it took me so long to realize that pasta_curves actually does have a serde feature.
Is there a reason why you implement ser/de functions manually instead of deriving them?
And do you think it would be possible to also add impl's for borsh? It seems to gain quite a popularity in crypto space.

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

No branches or pull requests

1 participant