mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 05:57:59 +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:
@@ -376,6 +376,33 @@ impl Hash for BlakeTwo256 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Keccak-256 Hash implementation.
|
||||
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub struct Keccak256;
|
||||
|
||||
impl Hasher for Keccak256 {
|
||||
type Out = sp_core::H256;
|
||||
type StdHasher = hash256_std_hasher::Hash256StdHasher;
|
||||
const LENGTH: usize = 32;
|
||||
|
||||
fn hash(s: &[u8]) -> Self::Out {
|
||||
sp_io::hashing::keccak_256(s).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for Keccak256 {
|
||||
type Output = sp_core::H256;
|
||||
|
||||
fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> Self::Output {
|
||||
sp_io::trie::keccak_256_root(input)
|
||||
}
|
||||
|
||||
fn ordered_trie_root(input: Vec<Vec<u8>>) -> Self::Output {
|
||||
sp_io::trie::keccak_256_ordered_root(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// Something that can be checked for equality and printed out to a debug channel if bad.
|
||||
pub trait CheckEqual {
|
||||
/// Perform the equality check.
|
||||
|
||||
Reference in New Issue
Block a user