-
Notifications
You must be signed in to change notification settings - Fork 256
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
Hashing Structures helpers #86
Comments
huitseeker
added a commit
to huitseeker/algebra
that referenced
this issue
Apr 21, 2021
…lize - this saves an alllocation w.r.t the suggested approach by implementing io::Write on the input instance of digest::Digest, - note that most instances of digest::Digest [already](https://gist.github.com/huitseeker/e827161413063e347ce5a496b66ff287) have an [io::Write instance](https://github.com/rustcrypto/hashes#hashing-readable-objects), but CanonicalSerialize consuming its io::Write argument prevents its usage, - this hence implements io::Write on a [cheap newtype wrapper](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html) Fixes arkworks-rs#86
huitseeker
added a commit
to huitseeker/algebra
that referenced
this issue
Apr 21, 2021
…alize` - this saves an alllocation w.r.t the suggested approach by implementing `io::Write` on the input instance of `digest::Digest`, - note that most instances of `digest::Digest` [already](https://gist.github.com/huitseeker/e827161413063e347ce5a496b66ff287) have an [`io::Write` instance](https://github.com/rustcrypto/hashes#hashing-readable-objects), but `CanonicalSerialize` consuming its `io::Write` argument prevents its usage, - this hence implements `io::Write` on a [cheap newtype wrapper](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html) Fixes arkworks-rs#86
6 tasks
huitseeker
added a commit
to huitseeker/algebra
that referenced
this issue
Apr 21, 2021
…alize` - this saves an alllocation w.r.t the suggested approach by implementing `io::Write` on the input instance of `digest::Digest`, - note that most instances of `digest::Digest` [already](https://gist.github.com/huitseeker/e827161413063e347ce5a496b66ff287) have an [`io::Write` instance](https://github.com/rustcrypto/hashes#hashing-readable-objects), but `CanonicalSerialize` consuming its `io::Write` argument prevents its usage, - this hence implements `io::Write` on a [cheap newtype wrapper](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html) Fixes arkworks-rs#86
huitseeker
added a commit
to huitseeker/algebra
that referenced
this issue
Apr 21, 2021
…alize` - this saves an alllocation w.r.t the suggested approach by implementing `io::Write` on the input instance of `digest::Digest`, - note that most instances of `digest::Digest` [already](https://gist.github.com/huitseeker/e827161413063e347ce5a496b66ff287) have an [`io::Write` instance](https://github.com/rustcrypto/hashes#hashing-readable-objects), but `CanonicalSerialize` consuming its `io::Write` argument prevents its usage, - this hence implements `io::Write` on a [cheap newtype wrapper](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html) Fixes arkworks-rs#86
huitseeker
added a commit
to huitseeker/algebra
that referenced
this issue
Apr 21, 2021
…alize` - this saves an alllocation w.r.t the suggested approach by implementing `io::Write` on the input instance of `digest::Digest`, - note that most instances of `digest::Digest` [already](https://gist.github.com/huitseeker/e827161413063e347ce5a496b66ff287) have an [`io::Write` instance](https://github.com/rustcrypto/hashes#hashing-readable-objects), but `CanonicalSerialize` consuming its `io::Write` argument prevents its usage, - this hence implements `io::Write` on a [cheap newtype wrapper](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html) Fixes arkworks-rs#86
weikengchen
added a commit
that referenced
this issue
Apr 23, 2021
…lize` (#265) * Implements hashing as a blanket trait for instances of `CanonicalSerialize` - this saves an alllocation w.r.t the suggested approach by implementing `io::Write` on the input instance of `digest::Digest`, - note that most instances of `digest::Digest` [already](https://gist.github.com/huitseeker/e827161413063e347ce5a496b66ff287) have an [`io::Write` instance](https://github.com/rustcrypto/hashes#hashing-readable-objects), but `CanonicalSerialize` consuming its `io::Write` argument prevents its usage, - this hence implements `io::Write` on a [cheap newtype wrapper](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html) Fixes #86 * Adjust post review - rename Hash -> CanonicalSerialize Ext according to [extension trait best practices](https://rust-lang.github.io/rfcs/0445-extension-trait-conventions.html#the-convention) - add the same structure for hashing uncompressed bytes * Changelog entries for #263, #265 * Update CHANGELOG.md Co-authored-by: Weikeng Chen <w.k@berkeley.edu>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depends on arkworks-rs/snark#104
It'd be nice to have a helper method as an extension trait over
CanonicalSerialize
which calls a cryptographically secure hash function (maybe make it take aDigest
?) on the serialized input, and returns the fixed size hash of the provided data.It'd be even better if it would also be available on structs composing such elements.
Example:
This would serialize all elements (compressed or uncompressed? i don't think it matters) to a buffer, and then take the hash of the buffer.
It becomes a bit trickier I believe if the struct ends up having non-CanonicalSerialize elements.
e.g.
The text was updated successfully, but these errors were encountered: