To get the same byte encoding on all platforms, we should use x.to_le_bytes() instead, or at least be consistent with the opposite conversion. The opposite conversion currently uses u64::from_le_bytes(arr), so we might as well stay with little-endian encoding unless someone has a pronounced opinion about this.
The fix must include a test the verifies that digest conversion to and back from an array of 40 bytes is the identity operation. This new test should be added as a proptest using the #[proptest] pragma from the proptest crate that's already a dependency.
Conversion from
Digest
to[u8, 40]
happens through:To get the same byte encoding on all platforms, we should use
x.to_le_bytes()
instead, or at least be consistent with the opposite conversion. The opposite conversion currently usesu64::from_le_bytes(arr)
, so we might as well stay with little-endian encoding unless someone has a pronounced opinion about this.The fix must include a test the verifies that digest conversion to and back from an array of 40 bytes is the identity operation. This new test should be added as a
proptest
using the#[proptest]
pragma from theproptest
crate that's already a dependency.