-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I recently installed the latest version of the crate uint
, and noticed that the code has become deprecated. I encountered the following error:
the trait bound U256: From<[u8; 32]> is not satisfied
To resolve the issue, I had to change the method from
to from_big_endian
. However, I'm unsure whether big-endian or little-endian is the correct choice in this context. For now, I've reverted to version 0.9.5
of the crate to avoid the issue, but it might be useful to address this in future versions of the book.
Thank you for considering this!
// lib/src/sha256.rs
impl Hash {
pub fn hash<T: serde::Serialize>(data: &T) -> Self {
let mut serialized: Vec<u8> = vec![];
if let Err(e) = ciborium::into_writer(data, &mut serialized) {
panic!(
"Failed to serialize data: {:?}. \
This should not happen.",
e
)
}
let hash = digest(&serialized);
let hash_bytes = hex::decode(hash).unwrap();
let hash_array: [u8; 32] = hash_bytes.as_slice().try_into().unwrap();
Hash(U256::from_big_endian(&hash_array))
}
Nelsi11120, mihaidaniel34 and mohammed-maher
Metadata
Metadata
Assignees
Labels
No labels