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
Remove Hash
impl from new hash types created with hash_newtype
#2698
Remove Hash
impl from new hash types created with hash_newtype
#2698
Conversation
Run `cargo +nightly fmt`, on other manual changes.
This change is the result of quite a few sessions trying to re-work the |
Pull Request Test Coverage Report for Build 8745032843Details
💛 - Coveralls |
I"ll fix CI if I get a concept ack. |
Yep, concept ACK. |
`rustfmt` does not format this macro code for short lines, do so manually. Refactor only, no logic changes.
Use concrete hash types instead of generic `Hash`. Refactor only, no logic changes.
New hash types created with `hash_newtype` are not meant to be general purpose hashes but currently we implement `Hash` for the newtype, this makes the API for the newtype misleading. Instead of implementing `Hash` we can make the `Hash` trait methods inherent on the new type, this allows the module that creates the new type to hash stuff ergonomically but does not pollute the public API for the type.
a208c30
to
aead5c3
Compare
Please see new text in PR description. |
Interesting question. I'm gonna say no, it's not. In general, the hash newtypes shouldn't have "engines" that users create and can write arbitrary data to (I believe Kix made this point in one of the "overhaul Maybe we should have a second macro that creates an engine? I guess this also then brings up the question of how to properly tie engine types to hash types.. |
This is the crux of the whole API re-write in my opinion. When I re-wrote the
|
1, 2 and 4 are all straightforward attributes of a wrapper around As for 3, in #2496 (comment) I suggested that we use I think if the hash engines implemented I believe this would require us to have a macro alongside |
If #2708 gets any traction this PR is not needed.
The first 4 patches are preparation, the last patch is:
Please note the changes to the docs on
is_sighash_single_bug
- shows that now the new hash types don't enable getting an engine that can be used as a writer to pass to the encode to writer functions insighash
(eg,legacy_encode_signing_data_to
). Is this acceptable?