In a `HashEngine` the `length` field represents number of bytes input into the hash engine. Note also: > the midstate bytes are only updated when the compression function is run, which only happens every 64 bytes. Currently our midstate API allows extracting the midstate after any amount of input bytes, this is probably not what users want. Note also that most users should not be using the midstate API anyways. With all this in mind, add a private `length` field to the `Midstate` struct and enforce an invariant that it is modulo 64. Add a single const `Midstate` constructor that panics if the invariant is violated. The `Midstate` is niche enough that panic is acceptable. Remove the `from_slice`, `from_byte_array`, and `to_byte_array` functions because they no longer make sense. Keep `AsRef<[u8]>` for cheap access to the midstate's inner byte slice. Note change to `Debug`: `bytes` field now does not include the `0x` prefix because `as_hex` because of the use of `debug_struct`. Enjoy nice warm fuzzy feeling from hacking on crypto code. |
||
---|---|---|
.. | ||
regression.rs |