MACs icon indicating copy to clipboard operation
MACs copied to clipboard

hmac: introduce a helper trait to simplify public bounds

Open newpavlov opened this issue 4 years ago • 0 comments

Right now public bounds are quite scary:

pub struct HmacCore<D>
where
    D: CoreProxy,
    D::Core: HashMarker
        + UpdateCore
        + FixedOutputCore
        + BufferKindUser<BufferKind = Eager>
        + Default
        + Clone,
    <D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
    Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{ .. }

Ideally we would use trait aliases, but they are currently not available in stable Rust. As a workaround we can introduce a sealed trait with blanket impl for types which satisfy the current bound and use it in our public bounds.

newpavlov avatar Jan 27 '22 06:01 newpavlov