-
Notifications
You must be signed in to change notification settings - Fork 303
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
add serialization and deserialization for BytesHash #1645
Conversation
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.
Thank you for this, good catch! Just left a small comment inline.
plonky2/src/hash/hash_types.rs
Outdated
let mut bytes = [0u8; N]; | ||
for i in 0..N { | ||
bytes[i] = seq.next_element().unwrap().unwrap(); | ||
} |
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 think it may be best to catch deserialization errors here instead of simply panicking.
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.
Hi! Thanks for reviewing this!
Good call, we changed that piece of code to catch the errors. Could you look at it?
Also, there is an error when running cargo clippy, but it is not related to the code we modified. Should we fix that?
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.
If you don't mind, you can include it in this PR, otherwise I'll open a separate one and merge yours after :)
Thanks!
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.
Done! We included those changes in a separate commit
6a4617f
to
fb4291a
Compare
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.
Thank you again! LGTM!
This PR adds the implementation of the
serialize
anddeserialize
traits for theBytesHash
struct.Since the
Keccak
hash function usesBytesHash
as its hash type, it is now possible to serialize and deserialize proofs that use theKeccakGoldilocksConfig
, like in this example