Skip to content

Commit

Permalink
chore: bump enr
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Mar 11, 2024
1 parent ce06a6a commit ae66165
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 49 deletions.
56 changes: 19 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pin-project = "1.0.12"
futures-util = "0.3.25"

# p2p
discv5 = "0.4"
discv5 = "0.4.1"
igd-next = "0.14.3"

# rpc
Expand All @@ -269,7 +269,7 @@ secp256k1 = { version = "0.28", default-features = false, features = [
"rand-std",
"recovery",
] }
enr = { version = "0.10", default-features = false, features = ["k256"] }
enr = { version = "0.10.1", default-features = false, features = ["k256"] }

# for eip-4844
c-kzg = "0.4.2"
Expand Down
13 changes: 5 additions & 8 deletions crates/net/ecies/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl ECIES {
let msg = x ^ self.nonce;
let (rec_id, sig) = SECP256K1
.sign_ecdsa_recoverable(
&secp256k1::Message::from_digest_slice(msg.as_slice()).unwrap(),
&secp256k1::Message::from_digest(msg.0),
&self.ephemeral_secret_key,
)
.serialize_compact();
Expand Down Expand Up @@ -324,13 +324,10 @@ impl ECIES {
self.remote_nonce = Some(data.get_next()?.ok_or(ECIESErrorImpl::InvalidAuthData)?);

let x = ecdh_x(&self.remote_public_key.unwrap(), &self.secret_key);
self.remote_ephemeral_public_key = Some(
SECP256K1.recover_ecdsa(
&secp256k1::Message::from_digest_slice((x ^ self.remote_nonce.unwrap()).as_ref())
.unwrap(),
&signature,
)?,
);
self.remote_ephemeral_public_key = Some(SECP256K1.recover_ecdsa(
&secp256k1::Message::from_digest((x ^ self.remote_nonce.unwrap()).0),
&signature,
)?);
self.ephemeral_shared_secret =
Some(ecdh_x(&self.remote_ephemeral_public_key.unwrap(), &self.ephemeral_secret_key));

Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/transaction/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ pub(crate) mod secp256k1 {
let sig =
RecoverableSignature::from_compact(&sig[0..64], RecoveryId::from_i32(sig[64] as i32)?)?;

let public = SECP256K1.recover_ecdsa(&Message::from_digest_slice(&msg[..32])?, &sig)?;
let public = SECP256K1.recover_ecdsa(&Message::from_digest(*msg), &sig)?;
Ok(public_key_to_address(public))
}

/// Signs message with the given secret key.
/// Returns the corresponding signature.
pub fn sign_message(secret: B256, message: B256) -> Result<Signature, secp256k1::Error> {
let sec = SecretKey::from_slice(secret.as_ref())?;
let s = SECP256K1.sign_ecdsa_recoverable(&Message::from_digest_slice(&message[..])?, &sec);
let s = SECP256K1.sign_ecdsa_recoverable(&Message::from_digest(message.0), &sec);
let (rec_id, data) = s.serialize_compact();

let signature = Signature {
Expand Down

0 comments on commit ae66165

Please sign in to comment.