chore: remove educe dependency (#8810)

This commit is contained in:
Matthias Seitz
2024-06-13 22:45:49 +02:00
committed by GitHub
parent d4bd1c8f5d
commit 8bb1270d54
3 changed files with 21 additions and 34 deletions

View File

@ -23,7 +23,6 @@ tokio-stream.workspace = true
tokio-util = { workspace = true, features = ["codec"] }
pin-project.workspace = true
educe = "0.4.19"
tracing.workspace = true
# HeaderBytes

View File

@ -11,7 +11,6 @@ use alloy_rlp::{Encodable, Rlp, RlpEncodable, RlpMaxEncodedLen};
use byteorder::{BigEndian, ByteOrder, ReadBytesExt};
use ctr::Ctr64BE;
use digest::{crypto_common::KeyIvInit, Digest};
use educe::Educe;
use rand::{thread_rng, Rng};
use reth_network_peers::{id2pk, pk2id};
use reth_primitives::{
@ -51,17 +50,13 @@ fn kdf(secret: B256, s1: &[u8], dest: &mut [u8]) {
concat_kdf::derive_key_into::<Sha256>(secret.as_slice(), s1, dest).unwrap();
}
#[derive(Educe)]
#[educe(Debug)]
pub struct ECIES {
#[educe(Debug(ignore))]
secret_key: SecretKey,
public_key: PublicKey,
remote_public_key: Option<PublicKey>,
pub(crate) remote_id: Option<PeerId>,
#[educe(Debug(ignore))]
ephemeral_secret_key: SecretKey,
ephemeral_public_key: PublicKey,
ephemeral_shared_secret: Option<B256>,
@ -70,9 +65,7 @@ pub struct ECIES {
nonce: B256,
remote_nonce: Option<B256>,
#[educe(Debug(ignore))]
ingress_aes: Option<Ctr64BE<Aes256>>,
#[educe(Debug(ignore))]
egress_aes: Option<Ctr64BE<Aes256>>,
ingress_mac: Option<MAC>,
egress_mac: Option<MAC>,
@ -83,6 +76,27 @@ pub struct ECIES {
body_size: Option<usize>,
}
impl core::fmt::Debug for ECIES {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("ECIES")
.field("public_key", &self.public_key)
.field("remote_public_key", &self.remote_public_key)
.field("remote_id", &self.remote_id)
.field("ephemeral_public_key", &self.ephemeral_public_key)
.field("ephemeral_shared_secret", &self.ephemeral_shared_secret)
.field("remote_ephemeral_public_key", &self.remote_ephemeral_public_key)
.field("nonce", &self.nonce)
.field("remote_nonce", &self.remote_nonce)
.field("ingress_mac", &self.ingress_mac)
.field("egress_mac", &self.egress_mac)
.field("init_msg", &self.init_msg)
.field("remote_init_msg", &self.remote_init_msg)
.field("body_size", &self.body_size)
.finish()
}
}
fn split_at_mut<T>(arr: &mut [T], idx: usize) -> Result<(&mut [T], &mut [T]), ECIESError> {
if idx > arr.len() {
return Err(ECIESErrorImpl::OutOfBounds { idx, len: arr.len() }.into())