From 515fd597f31fe0f78cce7988c07a481580730d82 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 12 Jan 2026 11:21:27 +0000 Subject: [PATCH] perf(net): use alloy_primitives::Keccak256 (#20957) --- Cargo.lock | 1 - crates/net/ecies/Cargo.toml | 1 - crates/net/ecies/src/algorithm.rs | 5 ++--- crates/net/ecies/src/mac.rs | 3 +-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b60b4a4b6..e5bf946f89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8338,7 +8338,6 @@ dependencies = [ "reth-network-peers", "secp256k1 0.30.0", "sha2", - "sha3", "thiserror 2.0.17", "tokio", "tokio-stream", diff --git a/crates/net/ecies/Cargo.toml b/crates/net/ecies/Cargo.toml index 75a4bc7897..a094cfa15b 100644 --- a/crates/net/ecies/Cargo.toml +++ b/crates/net/ecies/Cargo.toml @@ -34,7 +34,6 @@ secp256k1 = { workspace = true, features = ["global-context", "std", "recovery", rand_08.workspace = true concat-kdf.workspace = true sha2.workspace = true -sha3.workspace = true aes.workspace = true hmac.workspace = true block-padding.workspace = true diff --git a/crates/net/ecies/src/algorithm.rs b/crates/net/ecies/src/algorithm.rs index 8d31fc9e10..5d2663df63 100644 --- a/crates/net/ecies/src/algorithm.rs +++ b/crates/net/ecies/src/algorithm.rs @@ -9,12 +9,12 @@ use crate::{ use aes::{cipher::StreamCipher, Aes128, Aes256}; use alloy_primitives::{ bytes::{BufMut, Bytes, BytesMut}, - B128, B256, B512 as PeerId, + Keccak256, B128, B256, B512 as PeerId, }; use alloy_rlp::{Encodable, Rlp, RlpEncodable, RlpMaxEncodedLen}; use byteorder::{BigEndian, ByteOrder, ReadBytesExt}; use ctr::Ctr64BE; -use digest::{crypto_common::KeyIvInit, Digest}; +use digest::crypto_common::KeyIvInit; use rand_08::{thread_rng as rng, Rng}; use reth_network_peers::{id2pk, pk2id}; use secp256k1::{ @@ -22,7 +22,6 @@ use secp256k1::{ PublicKey, SecretKey, SECP256K1, }; use sha2::Sha256; -use sha3::Keccak256; const PROTOCOL_VERSION: usize = 4; diff --git a/crates/net/ecies/src/mac.rs b/crates/net/ecies/src/mac.rs index 5d25c214c0..e16eedbd06 100644 --- a/crates/net/ecies/src/mac.rs +++ b/crates/net/ecies/src/mac.rs @@ -10,11 +10,10 @@ //! For more information, refer to the [Ethereum MAC specification](https://github.com/ethereum/devp2p/blob/master/rlpx.md#mac). use aes::Aes256Enc; -use alloy_primitives::{B128, B256}; +use alloy_primitives::{Keccak256, B128, B256}; use block_padding::NoPadding; use cipher::BlockEncrypt; use digest::KeyInit; -use sha3::{Digest, Keccak256}; /// [`Ethereum MAC`](https://github.com/ethereum/devp2p/blob/master/rlpx.md#mac) state. ///