mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 20:01:08 +00:00
Add Keccak hasher (#6101)
* fix keccak hasher * Update hasher.rs Co-authored-by: Gavin Wood <i@gavwood.com>
This commit is contained in:
@@ -36,3 +36,23 @@ pub mod blake2 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod keccak {
|
||||
use hash_db::Hasher;
|
||||
use hash256_std_hasher::Hash256StdHasher;
|
||||
use crate::hash::H256;
|
||||
|
||||
/// Concrete implementation of Hasher using Keccak 256-bit hashes
|
||||
#[derive(Debug)]
|
||||
pub struct KeccakHasher;
|
||||
|
||||
impl Hasher for KeccakHasher {
|
||||
type Out = H256;
|
||||
type StdHasher = Hash256StdHasher;
|
||||
const LENGTH: usize = 32;
|
||||
|
||||
fn hash(x: &[u8]) -> Self::Out {
|
||||
crate::hashing::keccak_256(x).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ pub use crypto::{DeriveJunction, Pair, Public};
|
||||
pub use hash_db::Hasher;
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::hasher::blake2::Blake2Hasher;
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::hasher::keccak::KeccakHasher;
|
||||
|
||||
pub use sp_storage as storage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user