pasta_curves
pasta_curves copied to clipboard
Consider implementing (de)serialization for base types (Fp, Fq)
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.
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.