RustCrypto / traits

Collection of cryptography-related traits
590 stars 191 forks source link

digest: reduce the number of required methods in `Digest`? #1696

Closed fjarri closed 1 month ago

fjarri commented 1 month ago

It seems that a number of currently required methods in Digest can be expressed via other methods, for example:

Is there a reason it's not currently done?

newpavlov commented 1 month ago

You mean why those methods don't have blanket impls? It's because those implementations reside in the blanket impl of the trait itself. It uses the underlying traits directly without adding a layer of indirection (i.e. we use Update::update directly instead of using Digest::update which in turn uses Update::update). We could've used blanket methods implementations, but it's a very minor implementation detail considering that Digest should not be directly implemented by user crates.

fjarri commented 1 month ago

Ah, I see, that makes sense. I don't think it would hurt adding the blanket impls still, but I don't insist on it. Closing.