-
Notifications
You must be signed in to change notification settings - Fork 20
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
serde
support
#67
serde
support
#67
Conversation
Codecov Report
@@ Coverage Diff @@
## master #67 +/- ##
==========================================
+ Coverage 81.61% 82.36% +0.74%
==========================================
Files 13 14 +1
Lines 990 1083 +93
==========================================
+ Hits 808 892 +84
- Misses 182 191 +9
Continue to review full report at Codecov.
|
T: SerializableToArray, | ||
S: Serializer, | ||
{ | ||
if serializer.is_human_readable() { |
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.
Where is this is_human_readable
defined? What does it mean?
If the serializer for something "is human readable", we are returning base64?
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.
It's defined by the implementers of specific formats (see docs), e.g. JSON, BSON etc. They decide whether it's supposed to be "human-readable" or not.
If the serializer for something "is human readable", we are returning base64?
Yep. Although I want to make it a hex representation in case of public keys, the same as it currently works in nucypher
.
My 2 cents:
|
This may be useful in
They can be (de)serialized right now, just not with
My rationale was that in order to make the distinction between b64/byte representation for ciphertexts in structs that contain them (e.g. message kits), you'd have to write a custom serializer yourself. As opposed to having a |
Not sure I get it. IMHO in either case, If we use a key-value database for caching (like
Right, it already has
I share this concern.
I see. I would weigh more on the side of the former as it leaves more flexibility to the user. |
Hm, I realize now that I confused two usage scenarios here. This PR is important only for the applications that use Umbral as a Rust library; for JS or Python applications there will be no change whatsoever. So, the question is whether some Rust application would want to:
For example, if we write a Bob in Rust (or some part of Bob), and want to be able to cache retrieved cfrags, we will have to deal with this problem. One may be able to get away with using some key-value storage and deserializing verified cfrags manually with |
Merging in the minimal version for now, to keep things moving. If @vepkenez needs more stuff, I'll add it in another PR. |
Serialize
/Deserialize
implementations forPublicKey
,Signature
,Capsule
,KeyFrag
,CapsuleFrag
PublicKey
is serialized as hex, and the rest in base64-encoded formNote: all the serializations simply use the bytestring produced by
to_array()
for binary formats, and the b64 encoding of it for human-readable formats; this helps preserve compatibility withpyumbral
(as opposed to implementingSerialize
forCurveScalar
andCurvePoint
, and deriving the rest).For now, not including any
serde
support forVerified*
objects - they won't be used as nested fields in any protocol objects, so the existing serialization support is enough. Same for the secret objects (SecretKey
,SecretKeyFactory
).For future: we could expose the binary/b64 mechanic to help serialize ciphertexts too. Either as a wrapper class, or returning a
Ciphertext
object that would implementserde
traits. Not in this PR.