Skip to content

Commit

Permalink
fix: use correct hash function (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Oct 25, 2022
1 parent ee41dfa commit 2b67e75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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 = { version = "2.0", features = ["sha3"] }
tiny-keccak = { version = "2.0", features = ["keccak"] }

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

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

0 comments on commit 2b67e75

Please sign in to comment.