Implements hashing as a blanket trait for instances of CanonicalSerialize - #265
Merged
Conversation
huitseeker
force-pushed
the
hashes
branch
2 times, most recently
from
April 21, 2021 22:50
e15b4c5 to
48847ee
Compare
…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
Pratyush
reviewed
Apr 21, 2021
Pratyush
reviewed
Apr 22, 2021
Member
Is it not possible to work around this by doing |
Contributor
Author
|
@Pratyush Sure, though this signature change would change the API of Moreover, I'm not sure we want to depend on the
They're here .. just not very reliably so. |
Member
|
Ok that makes sense, let's proceed as is. This LGTM modulo the change to |
- 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
Pratyush
approved these changes
Apr 22, 2021
Member
|
Oh @huitseeker if you could add a CHANGELOG entry that would be great (also for #263) |
ValarDragon
reviewed
Apr 23, 2021
ValarDragon
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for adding this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
io::Writeon the input instance ofdigest::Digest,digest::Digestalready have anio::Writeinstance, butCanonicalSerializeconsuming itsio::Writeargument prevents its usage,io::Writeon a cheap newtype wrappercloses: #86
Pendingsection inCHANGELOG.mdFiles changedin the Github PR explorer