scsys_crypto/hash/h160/
impl_blake3.rs

1use super::H160;
2use crate::Concat;
3
4impl Concat for H160 {
5    type Output = H160;
6
7    fn concat(&self, other: H160) -> Self {
8        let mut res: Vec<u8> = (*self).into();
9        let mut rnode: Vec<u8> = (*other).into();
10        res.append(&mut rnode);
11
12        blake3::hash(&res).into()
13    }
14}
15
16impl From<blake3::Hash> for H160 {
17    fn from(input: blake3::Hash) -> H160 {
18        let mut raw_hash: [u8; 20] = [0; 20];
19        raw_hash[0..20].copy_from_slice(input.as_bytes());
20        H160(raw_hash)
21    }
22}
23
24// impl From<H160> for blake3::Hash {
25//     fn from(input: H160) -> blake3::Hash {
26//         let hash: [u8; 32] = blake3::Hash::from(input.into::<>());
27
28//     }
29// }