diff --git a/Cargo.lock b/Cargo.lock index 69b75886b..efa8ad189 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -895,7 +895,7 @@ dependencies = [ "impl-rlp", "impl-serde", "scale-info", - "tiny-keccak", + "tiny-keccak 2.0.2", ] [[package]] @@ -936,7 +936,7 @@ dependencies = [ "serde_json", "strum", "thiserror", - "tiny-keccak", + "tiny-keccak 2.0.2", "unicode-xid", ] @@ -2536,6 +2536,7 @@ dependencies = [ "serde", "serde_json", "thiserror", + "tiny-keccak 0.3.0", ] [[package]] @@ -3366,6 +3367,12 @@ dependencies = [ "syn", ] +[[package]] +name = "tiny-keccak" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cd8183d45872feda10001dfacfebf7e163e159922582cd919bed08732447c4" + [[package]] name = "tiny-keccak" version = "2.0.2" diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index e2d18c20b..439bff159 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -8,19 +8,24 @@ readme = "README.md" description = "Commonly used types in reth." [dependencies] -ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -bytes = "1.2" - -serde = "1.0" -thiserror = "1" +# reth reth-rlp = { path = "../common/rlp", features = ["std", "derive", "ethereum-types"]} -parity-scale-codec = { version = "3.2.1", features = ["derive", "bytes"] } 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" + #used for forkid crc = "1" maplit = "1" +# misc +bytes = "1.2" +serde = "1.0" +thiserror = "1" + [dev-dependencies] serde_json = "1.0" hex-literal = "0.3" \ No newline at end of file diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index ded31ad8f..f04122385 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -49,3 +49,18 @@ pub use ethers_core::{ types as rpc, types::{Bloom, Bytes, H128, H160, H256, H512, H64, U128, U256, U64}, }; + +#[doc(hidden)] +mod __reexport { + pub use tiny_keccak; +} + +// Useful reexports +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() +}