aboutsummaryrefslogtreecommitdiff
path: root/src/hash.rs
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2020-11-30 19:11:36 +0100
committerNicholas Rodrigues Lordello <[email protected]>2020-11-30 19:11:36 +0100
commita699b6b4fe6f0e2567f7298fd8174e779f1bd43d (patch)
treee79f3927acc133cd05e06e22b1c95c776effe991 /src/hash.rs
parent678d45e7ae09510796d27a80ecd894f6a1ad8279 (diff)
hd wallet impl
Diffstat (limited to 'src/hash.rs')
-rw-r--r--src/hash.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/hash.rs b/src/hash.rs
index 6382a7a..b3091d2 100644
--- a/src/hash.rs
+++ b/src/hash.rs
@@ -1,6 +1,14 @@
//! Module implementing various hashing utilities.
-use sha2::{Digest, Sha256};
+use sha2::{Digest as _, Sha256};
+use sha3::Keccak256;
+
+/// Returns the Keccak-256 hash of the specified input.
+pub fn keccak256(data: impl AsRef<[u8]>) -> [u8; 32] {
+ let mut hasher = Keccak256::new();
+ hasher.update(data.as_ref());
+ hasher.finalize().into()
+}
/// Returns the SHA256 hash of the specified input.
pub fn sha256(data: impl AsRef<[u8]>) -> [u8; 32] {