Implement gate-featured serde for exported structures #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few weeks ago, I needed
serde
implementations for the types that this library exports, so I coded them on our fork: https://github.com/dusk-network/bls12_381Then I saw the suggestion raised in #35 by @hdevalence and thought that it would be nice to convert our impl to a
feature-gated behind a serde feature
.So I modified our impl according to the gate-feature suggestion and made the PR.
Adds serde impl for:
G1Affine
G2Affine
G2Prepared
which then requiredFp
,Fp2
&Fp6
serde impls.All the implementations will make the deserialization fail if any of the items is not
canonically-encoded
.Appart from that, I think that implement
Write
andRead
for these types would be also nice, since sometimes, you just want to move the point structures as bytes but without doing any compresions/decompressions, having them "serialized" as bytes (which would be much more performant). See: dusk-network/plonk#190 where aProof
takes a considerable amount of time to be deserialized just because we calldecompression
for each point we store on it computing the security checks.I added the
serde
feature to thedefault
features group, but feel free to remove it from there since Idk if everyone will want the feature enabled by default.