Skip to content

Commit

Permalink
chore: bump tiny-keccak (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Oct 25, 2022
1 parent 77ea53b commit 0998fc3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
12 changes: 3 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ reth-codecs = { version = "0.1.0", path = "../codecs" }
# ethereum
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
parity-scale-codec = { version = "3.2.1", features = ["derive", "bytes"] }
tiny-keccak = "0.3"
tiny-keccak = { version = "2.0", features = ["sha3"] }

#used for forkid
crc = "1"
Expand Down
9 changes: 6 additions & 3 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ pub use __reexport::*;

/// Returns the keccak256 hash for the given data.
pub fn keccak256(data: impl AsRef<[u8]>) -> H256 {
let mut res: [u8; 32] = [0; 32];
tiny_keccak::keccak_256(data.as_ref(), &mut res);
res.into()
use tiny_keccak::{Hasher, Sha3};
let mut sha3 = Sha3::v256();
let mut output = [0; 32];
sha3.update(data.as_ref());
sha3.finalize(&mut output);
output.into()
}

0 comments on commit 0998fc3

Please sign in to comment.