-
Notifications
You must be signed in to change notification settings - Fork 49
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 fields and curves #48
Conversation
src/serde_impl.rs
Outdated
test_roundtrip(&f); | ||
assert_eq!( | ||
serde_json::from_slice::<EpAffine>( | ||
b"[0,0,0,0,237,48,45,153,27,249,76,9,252,152,70,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not checked this value (or the one for EqAffine::generator()
below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK. Serialising the byte representations looks good to me.
Codecov ReportBase: 66.15% // Head: 72.35% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
==========================================
+ Coverage 66.15% 72.35% +6.20%
==========================================
Files 12 13 +1
Lines 1427 1530 +103
==========================================
+ Hits 944 1107 +163
+ Misses 483 423 -60
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@vmx Would you also consider adding borsh support or is that out of scope? |
@parazyd I won't have time working on borsh support. |
@vmx Alright, I will then add it after this PR is merged. Thank you. |
Is this going to be merged in? |
This PR needs to be rebased (GitHub's UI indicates there is a merge conflict). |
Currently Serde is only implemented for `Fp`, `Fq`, `EpAffine` and `EqAffine`. Support can be enabled with the `serde` feature.
As I needed to rebase, I did merged all commits into a single one. It should now include all the things mentioned in the review. Notable things are:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Human-readable serialization change looks good.
Following this model, I have also implemented Serde for the |
Currently, the Serializer sets `is_human_readable` to false, but the Deserializer implicitly sets it to true. This causes issues when other types try to use serde based on this value, as in zcash/pasta_curves#48, so this PR makes them consistently false. BREAKING CHANGE: the Serde deserializer is now defined as non human readable
Implement serde for fields and curves. Those changes are based on zcash#48 and will eventually also land upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 025362a
fix: make the deserializer human-unreadable (ipld#165) Currently, the Serializer sets `is_human_readable` to false, but the Deserializer implicitly sets it to true. This causes issues when other types try to use serde based on this value, as in zcash/pasta_curves#48, so this PR makes them consistently false. BREAKING CHANGE: the Serde deserializer is now defined as non human readable lint fix try fix CI empty revert try fix 2 fix ci 2 fix ci 3 less branches no dep:, arb feature fix arb lint fixes fix wasm ci fix arb 3 fix wasm ci fix wasm ci 2 fix no_std build requested changes getrandom optional remove getrandom fix recursion requested changes shrink fix duplicate code update `multihash` in other crates fix (cargo-release) version 0.15.0 (cargo-release) version 0.15.0 (cargo-release) version 0.15.0 (cargo-release) version 0.15.0 (cargo-release) version 0.15.0 (cargo-release) version 0.15.0 (cargo-release) version 0.15.0 fixes minor remove custom generator remove arbitrary_ipld_vec/map fn_s remove filtering of fleat nans make arbitrary_ipld private copy size to avoid too small lists/maps fix arbitrary_size with actual size fix size == 0 edgecase fmt && clippy cliipy chore: fix Android build on CI (ipld#169) Also cache `cargo-apk` for faster CI run times. move everything to arb module fmt
Currently, the Serializer sets `is_human_readable` to false, but the Deserializer implicitly sets it to true. This causes issues when other types try to use serde based on this value, as in zcash/pasta_curves#48, so this PR makes them consistently false. BREAKING CHANGE: the Serde deserializer is now defined as non human readable
Currently Serde is only implemented for
Fp
,Fq
,EpAffine
andEqAffine
.Support can be enabled with the
serde
feature.It's based on the implementation in
blstrs
: https://github.com/filecoin-project/blstrs/blob/master/src/serde_impl.rsPlease let me know if that's the correct approach, or e.g. you'd like to serialize them to four
u64
s.I've only implemented it for the things I currently need, but I'm happy to provide an implementation for all curves.