digest: add blanket-impls feature to gate blanket Digest impl#2311
digest: add blanket-impls feature to gate blanket Digest impl#2311remix7531 wants to merge 1 commit intoRustCrypto:masterfrom
Conversation
Add a new `blanket-impls` feature flag (enabled by default) that gates the blanket `impl<D: FixedOutput + Default + Update + HashMarker> Digest for D` implementation. This allows downstream crates that provide their own manual `Digest` implementations to disable the blanket impl and avoid coherence conflicts.
|
Maybe it is better to make this an opt in feature. Open for feedback. |
The If you absolutely want to work with a one-shot function AND implement |
|
The reason this is useful is because of how the proof works.
My functional digest and the incremental API are separate. Additionally, working with traits is not so easy with HAX and F* Please re-open |
|
You haven't answered how exactly removal of the blanket implementation helps. Do you plan to implement only The Additionally, the proposed feature is not additive. For example, a crate may simultaneously implement No one forces you to implement |
|
I will push the code soon. I am implementing all methods of the digest trait. I want high level compatibility with RustCrypto. |
|
If you are able to implement |
Summary
This PR adds a
blanket-implsfeature flag (enabled by default) to thedigestcrate that gates the blanket implementation:Motivation
I am working on a formally verified hash function and want to implement the
Digesttrait for it. For formal verification, it is desirable to express the hasher as a single pure function rather than splitting it across theUpdate+FixedOutputtrait hierarchy, as the incremental update model does not map cleanly to the verification model.Currently this is impossible due to coherence: the always-present blanket impl conflicts with any manual
Digestimplementation at compile time, with no way to opt out.Gating the blanket impl behind a feature flag unblocks this use case. Crates that need a manual implementation can opt out with
default-features = false, while all existing users are unaffected.Compatibility
Non-breaking. The feature is on by default, so existing users and downstream crates are unaffected.