Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

deps: bump crypto deps #1465

Merged
merged 2 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 112 additions & 162 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ethers-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ arrayvec = { version = "0.7.2", default-features = false }
rlp-derive = { version = "0.1.0", default-features = false }

# crypto
elliptic-curve = { version = "0.11.12", default-features = false }
elliptic-curve = { version = "0.12.2", default-features = false }
generic-array = { version = "0.14.5", default-features = false }
k256 = { version = "0.10.4", default-features = false, features = ["keccak256", "ecdsa", "std"] }
k256 = { version = "0.11", default-features = false, features = ["keccak256", "ecdsa", "std"] }
rand = { version = "0.8.5", default-features = false }
tiny-keccak = { version = "2.0.2", default-features = false }

Expand Down
15 changes: 6 additions & 9 deletions ethers-core/src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ use crate::{
types::{Address, H256, U256},
utils::hash_message,
};

use fastrlp::Decodable;
use serde::{Deserialize, Serialize};
use std::{convert::TryFrom, fmt, str::FromStr};

use thiserror::Error;

use elliptic_curve::{consts::U32, sec1::ToEncodedPoint};
use fastrlp::Decodable;
use generic_array::GenericArray;
use k256::{
ecdsa::{
Expand All @@ -19,6 +13,9 @@ use k256::{
},
PublicKey as K256PublicKey,
};
use serde::{Deserialize, Serialize};
use std::{convert::TryFrom, fmt, str::FromStr};
use thiserror::Error;

/// An error involving a signature.
#[derive(Debug, Error)]
Expand Down Expand Up @@ -103,8 +100,8 @@ impl Signature {
};

let (recoverable_sig, _recovery_id) = self.as_signature()?;
let verify_key =
recoverable_sig.recover_verify_key_from_digest_bytes(message_hash.as_ref().into())?;
let verify_key = recoverable_sig
.recover_verifying_key_from_digest_bytes(message_hash.as_ref().into())?;

let public_key = K256PublicKey::from(&verify_key);
let public_key = public_key.to_encoded_point(/* compress = */ false);
Expand Down
16 changes: 8 additions & 8 deletions ethers-signers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
ethers-core = { version = "^0.13.0", path = "../ethers-core", features = ["eip712"]}
thiserror = { version = "1.0.31", default-features = false }
coins-bip32 = "0.6.0"
coins-bip39 = "0.6.0"
coins-ledger = { version = "0.6.1", default-features = false, optional = true }
coins-bip32 = "0.7.0"
coins-bip39 = "0.7.0"
coins-ledger = { version = "0.7.0", default-features = false, optional = true }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
async-trait = { version = "0.1.50", default-features = false }
elliptic-curve = { version = "0.11.12", default-features = false }
sha2 = { version = "0.9.8", default-features = false }
elliptic-curve = { version = "0.12.2", default-features = false }
sha2 = { version = "0.10.2", default-features = false }
rand = { version = "0.8.5", default-features = false }
yubihsm = { version = "0.40.0", features = ["secp256k1", "http", "usb"], optional = true }
yubihsm = { version = "0.41.0-pre", features = ["secp256k1", "http", "usb"], optional = true }
futures-util = { version = "^0.3", optional = true }
futures-executor = { version = "^0.3", optional = true }
semver = { version = "1.0.12", optional = true }
Expand All @@ -45,10 +45,10 @@ ethers-contract = { version = "^0.13.0", path = "../ethers-contract", features =
ethers-derive-eip712 = { version = "^0.13.0", path = "../ethers-core/ethers-derive-eip712" }
serde_json = { version = "1.0.64" }
tracing-subscriber = "0.3.11"
yubihsm = { version = "0.40.0", features = ["secp256k1", "usb", "mockhsm"] }
yubihsm = { version = "0.41.0-pre", features = ["secp256k1", "usb", "mockhsm"] }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
yubihsm = { version = "0.40.0", features = ["secp256k1", "usb", "mockhsm"] }
yubihsm = { version = "0.41.0-pre", features = ["secp256k1", "usb", "mockhsm"] }
tokio = { version = "1.18", default-features = false, features = ["macros", "rt"] }
tempfile = "3.3.0"

Expand Down
2 changes: 1 addition & 1 deletion ethers-signers/src/aws/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(super) fn rsig_to_ethsig(sig: &RSig) -> EthSig {
/// Makes a trial recovery to check whether an RSig corresponds to a known
/// `VerifyingKey`
fn check_candidate(sig: &RSig, digest: [u8; 32], vk: &VerifyingKey) -> bool {
if let Ok(key) = sig.recover_verify_key_from_digest_bytes(digest.as_ref().into()) {
if let Ok(key) = sig.recover_verifying_key_from_digest_bytes(digest.as_ref().into()) {
key == *vk
} else {
false
Expand Down
35 changes: 13 additions & 22 deletions ethers-signers/src/wallet/hash.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! This is a helper module used to pass the pre-hashed message for signing to the
//! `sign_digest` methods of K256.
use elliptic_curve::consts::U64;
use ethers_core::{
k256::ecdsa::signature::digest::{
generic_array::GenericArray, BlockInput, Digest, FixedOutput, Output, Reset, Update,
generic_array::GenericArray, Digest, FixedOutput, FixedOutputReset, HashMarker, Output,
OutputSizeUser, Reset, Update,
},
types::H256,
};
Expand All @@ -18,7 +18,7 @@ pub enum ProxyDigest<D: Digest> {

impl<D: Digest + Clone> From<H256> for ProxyDigest<D>
where
GenericArray<u8, <D as Digest>::OutputSize>: Copy,
GenericArray<u8, <D as OutputSizeUser>::OutputSize>: Copy,
{
fn from(src: H256) -> Self {
ProxyDigest::Proxy(*GenericArray::from_slice(src.as_bytes()))
Expand All @@ -33,7 +33,7 @@ impl<D: Digest> Default for ProxyDigest<D> {

impl<D: Digest> Update for ProxyDigest<D> {
// we update only if we are digest
fn update(&mut self, data: impl AsRef<[u8]>) {
fn update(&mut self, data: &[u8]) {
match self {
ProxyDigest::Digest(ref mut d) => {
d.update(data);
Expand All @@ -43,34 +43,23 @@ impl<D: Digest> Update for ProxyDigest<D> {
}
}
}

// we chain only if we are digest
fn chain(self, data: impl AsRef<[u8]>) -> Self {
match self {
ProxyDigest::Digest(d) => ProxyDigest::Digest(d.chain(data)),
ProxyDigest::Proxy(..) => {
unreachable!("can not update if we are proxy");
}
}
}
}

impl<D: Digest> HashMarker for ProxyDigest<D> {}

impl<D: Digest> Reset for ProxyDigest<D> {
// make new one
fn reset(&mut self) {
*self = Self::default();
}
}

// Use Sha256 with 512 bit blocks
impl<D: Digest> BlockInput for ProxyDigest<D> {
type BlockSize = U64;
impl<D: Digest> OutputSizeUser for ProxyDigest<D> {
// we default to the output of the original digest
type OutputSize = <D as OutputSizeUser>::OutputSize;
}

impl<D: Digest> FixedOutput for ProxyDigest<D> {
// we default to the output of the original digest
type OutputSize = D::OutputSize;

fn finalize_into(self, out: &mut GenericArray<u8, Self::OutputSize>) {
match self {
ProxyDigest::Digest(d) => {
Expand All @@ -81,9 +70,11 @@ impl<D: Digest> FixedOutput for ProxyDigest<D> {
}
}
}
}

fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>) {
impl<D: Digest> FixedOutputReset for ProxyDigest<D> {
fn finalize_into_reset(&mut self, out: &mut Output<Self>) {
let s = std::mem::take(self);
s.finalize_into(out);
Digest::finalize_into(s, out)
}
}
2 changes: 1 addition & 1 deletion ethers-signers/src/wallet/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Clone for Wallet<SigningKey> {
fn clone(&self) -> Self {
Self {
// TODO: Can we have a better way to clone here?
signer: SigningKey::from_bytes(&*self.signer.to_bytes()).unwrap(),
signer: SigningKey::from_bytes(&self.signer.to_bytes()).unwrap(),
address: self.address,
chain_id: self.chain_id,
}
Expand Down
2 changes: 1 addition & 1 deletion ethers-solc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ num_cpus = "1.13.1"
tiny-keccak = { version = "2.0.2", default-features = false }
tempfile = { version = "3.3.0", optional = true }
fs_extra = { version = "1.2.0", optional = true }
sha2 = { version = "0.9.8", default-features = false, optional = true }
sha2 = { version = "0.10.2", default-features = false, optional = true }
dunce = "1.0.2"
solang-parser = { default-features = false, version = "=0.1.16" }
rayon = "1.5.3"
Expand Down