From a96884d6700635aa5f3999d09c817a08fc7face2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 13 Jun 2024 23:19:49 +0200 Subject: [PATCH] chore(ecies): replace reth-primitives with alloy-primitives (#8812) --- Cargo.lock | 2 +- crates/net/ecies/Cargo.toml | 7 ++++--- crates/net/ecies/src/algorithm.rs | 10 +++++----- crates/net/ecies/src/codec.rs | 2 +- crates/net/ecies/src/lib.rs | 2 +- crates/net/ecies/src/mac.rs | 2 +- crates/net/ecies/src/stream.rs | 4 ++-- crates/net/ecies/src/util.rs | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f1f7ef611..39814f1669 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6834,6 +6834,7 @@ name = "reth-ecies" version = "1.0.0-rc.1" dependencies = [ "aes 0.8.4", + "alloy-primitives", "alloy-rlp", "block-padding", "byteorder", @@ -6847,7 +6848,6 @@ dependencies = [ "pin-project", "rand 0.8.5", "reth-network-peers", - "reth-primitives", "secp256k1 0.28.2", "sha2 0.10.8", "sha3", diff --git a/crates/net/ecies/Cargo.toml b/crates/net/ecies/Cargo.toml index 6e8670d894..eb2a0b023b 100644 --- a/crates/net/ecies/Cargo.toml +++ b/crates/net/ecies/Cargo.toml @@ -11,13 +11,14 @@ repository.workspace = true workspace = true [dependencies] -reth-primitives.workspace = true reth-network-peers = { workspace = true, features = ["secp256k1"] } -alloy-rlp = { workspace = true, features = ["derive"] } +alloy-primitives = { workspace = true, features = ["rand", "rlp"] } +alloy-rlp = { workspace = true, features = ["derive", "arrayvec"] } + futures.workspace = true thiserror.workspace = true -tokio = { workspace = true, features = ["full"] } +tokio = { workspace = true, features = ["time"] } tokio-stream.workspace = true tokio-util = { workspace = true, features = ["codec"] } pin-project.workspace = true diff --git a/crates/net/ecies/src/algorithm.rs b/crates/net/ecies/src/algorithm.rs index 5970e8405e..83dcc657bc 100644 --- a/crates/net/ecies/src/algorithm.rs +++ b/crates/net/ecies/src/algorithm.rs @@ -7,16 +7,16 @@ use crate::{ ECIESError, }; use aes::{cipher::StreamCipher, Aes128, Aes256}; +use alloy_primitives::{ + bytes::{BufMut, Bytes, BytesMut}, + 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 rand::{thread_rng, Rng}; use reth_network_peers::{id2pk, pk2id}; -use reth_primitives::{ - bytes::{BufMut, Bytes, BytesMut}, - B128, B256, B512 as PeerId, -}; use secp256k1::{ ecdsa::{RecoverableSignature, RecoveryId}, PublicKey, SecretKey, SECP256K1, @@ -735,7 +735,7 @@ impl ECIES { #[cfg(test)] mod tests { use super::*; - use reth_primitives::{b256, hex}; + use alloy_primitives::{b256, hex}; #[test] fn ecdh() { diff --git a/crates/net/ecies/src/codec.rs b/crates/net/ecies/src/codec.rs index 890113fd69..7ad30d38d0 100644 --- a/crates/net/ecies/src/codec.rs +++ b/crates/net/ecies/src/codec.rs @@ -1,5 +1,5 @@ use crate::{algorithm::ECIES, ECIESError, EgressECIESValue, IngressECIESValue}; -use reth_primitives::{BytesMut, B512 as PeerId}; +use alloy_primitives::{bytes::BytesMut, B512 as PeerId}; use secp256k1::SecretKey; use std::{fmt::Debug, io}; use tokio_util::codec::{Decoder, Encoder}; diff --git a/crates/net/ecies/src/lib.rs b/crates/net/ecies/src/lib.rs index 07fb044c5c..378398d6ba 100644 --- a/crates/net/ecies/src/lib.rs +++ b/crates/net/ecies/src/lib.rs @@ -18,7 +18,7 @@ pub use error::ECIESError; mod codec; -use reth_primitives::{ +use alloy_primitives::{ bytes::{Bytes, BytesMut}, B512 as PeerId, }; diff --git a/crates/net/ecies/src/mac.rs b/crates/net/ecies/src/mac.rs index 30baa298c9..03847d091e 100644 --- a/crates/net/ecies/src/mac.rs +++ b/crates/net/ecies/src/mac.rs @@ -10,11 +10,11 @@ //! 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 block_padding::NoPadding; use cipher::BlockEncrypt; use digest::KeyInit; use generic_array::GenericArray; -use reth_primitives::{B128, B256}; use sha3::{Digest, Keccak256}; use typenum::U16; diff --git a/crates/net/ecies/src/stream.rs b/crates/net/ecies/src/stream.rs index ca43fd4540..dbd7577a35 100644 --- a/crates/net/ecies/src/stream.rs +++ b/crates/net/ecies/src/stream.rs @@ -3,11 +3,11 @@ use crate::{ codec::ECIESCodec, error::ECIESErrorImpl, ECIESError, EgressECIESValue, IngressECIESValue, }; -use futures::{ready, Sink, SinkExt}; -use reth_primitives::{ +use alloy_primitives::{ bytes::{Bytes, BytesMut}, B512 as PeerId, }; +use futures::{ready, Sink, SinkExt}; use secp256k1::SecretKey; use std::{ fmt::Debug, diff --git a/crates/net/ecies/src/util.rs b/crates/net/ecies/src/util.rs index f6b30288a4..cffd1f19de 100644 --- a/crates/net/ecies/src/util.rs +++ b/crates/net/ecies/src/util.rs @@ -1,7 +1,7 @@ //! Utility functions for hashing and encoding. +use alloy_primitives::B256; use hmac::{Hmac, Mac}; -use reth_primitives::B256; use sha2::{Digest, Sha256}; /// Hashes the input data with SHA256.