Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit c4b6a29

Browse files
committed
fixes from review #1
1 parent 869cf84 commit c4b6a29

File tree

5 files changed

+7
-38
lines changed

5 files changed

+7
-38
lines changed

Cargo.lock

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frame/beefy-mmr/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repository = "https://github.com/paritytech/substrate"
1010
[dependencies]
1111
hex = { version = "0.4", optional = true }
1212
codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false, features = ["derive"] }
13-
k256 = { version = "0.10.2", default-features = false, features = ["arithmetic"] }
1413
log = { version = "0.4.13", default-features = false }
1514
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
1615
serde = { version = "1.0.136", optional = true }
@@ -43,7 +42,6 @@ std = [
4342
"frame-support/std",
4443
"frame-system/std",
4544
"hex",
46-
"k256/std",
4745
"log/std",
4846
"pallet-beefy/std",
4947
"pallet-mmr-primitives/std",

primitives/core/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ dyn-clonable = { version = "0.9.0", optional = true }
4646
thiserror = { version = "1.0.30", optional = true }
4747
bitflags = "1.3"
4848
k256 = { version = "0.10.2", default-features = false, features = ["ecdsa"] }
49-
sp-core-hashing = { version = "4.0.0", default-features = false, path = "./hashing" }
5049

5150
# full crypto
5251
ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend", "alloc"], optional = true }
@@ -60,6 +59,7 @@ libsecp256k1 = { version = "0.7", default-features = false, features = ["static-
6059
merlin = { version = "2.0", default-features = false, optional = true }
6160
secp256k1 = { version = "0.21.2", default-features = false, features = ["recovery", "alloc"], optional = true }
6261
ss58-registry = { version = "1.11.0", default-features = false }
62+
sp-core-hashing = { version = "4.0.0", path = "./hashing", default-features = false, optional = true }
6363
sp-runtime-interface = { version = "6.0.0", default-features = false, path = "../runtime-interface" }
6464

6565
[dev-dependencies]
@@ -134,6 +134,7 @@ full_crypto = [
134134
"hex",
135135
"libsecp256k1",
136136
"secp256k1",
137+
"sp-core-hashing",
137138
"sp-runtime-interface/disable_target_static_assertions",
138139
"merlin",
139140
]

primitives/core/src/ecdsa.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ecds");
5959
type Seed = [u8; 32];
6060

6161
/// The ECDSA compressed public key.
62+
#[cfg_attr(feature = "full_crypto", derive(Hash))]
6263
#[derive(
6364
Clone,
6465
Copy,
@@ -71,7 +72,6 @@ type Seed = [u8; 32];
7172
PartialEq,
7273
PartialOrd,
7374
Ord,
74-
Hash,
7575
)]
7676
pub struct Public(pub [u8; 33]);
7777

@@ -103,16 +103,15 @@ impl Public {
103103

104104
/// Converts self into Ethereum address
105105
pub fn to_eth_address(&self) -> Result<[u8; 20], ()> {
106-
use crate::hashing::keccak_256;
107-
use k256::{elliptic_curve::sec1::ToEncodedPoint, PublicKey};
106+
use k256::{elliptic_curve::sec1::ToEncodedPoint, PublicKey};
108107

109108
PublicKey::from_sec1_bytes(self.as_slice())
110109
.map(|pub_key| {
111110
// uncompress the key
112111
let uncompressed = pub_key.to_encoded_point(false);
113112
// convert to ETH address
114113
let res: [u8; 20] =
115-
keccak_256(&uncompressed.as_bytes()[1..])[12..].try_into().unwrap();
114+
sp_io::hashing::keccak_256(&uncompressed.as_bytes()[1..])[12..].try_into().unwrap();
116115
res
117116
})
118117
.map_err(|_| ())

primitives/core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ pub use sp_debug_derive::RuntimeDebug;
4848
#[cfg(feature = "std")]
4949
pub use impl_serde::serialize as bytes;
5050

51+
#[cfg(feature = "full_crypto")]
5152
pub mod hashing;
52-
pub use hashing::keccak_256;
5353

5454
#[cfg(feature = "full_crypto")]
55-
pub use hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64};
55+
pub use hashing::{blake2_128, blake2_256, keccak_256, twox_128, twox_256, twox_64};
5656
pub mod crypto;
5757
pub mod hexdisplay;
5858

0 commit comments

Comments
 (0)