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

Commit

Permalink
fixes from review #1
Browse files Browse the repository at this point in the history
  • Loading branch information
agryaznov committed Mar 24, 2022
1 parent 869cf84 commit c4b6a29
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 38 deletions.
29 changes: 0 additions & 29 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions frame/beefy-mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repository = "https://github.com/paritytech/substrate"
[dependencies]
hex = { version = "0.4", optional = true }
codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false, features = ["derive"] }
k256 = { version = "0.10.2", default-features = false, features = ["arithmetic"] }
log = { version = "0.4.13", default-features = false }
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", optional = true }
Expand Down Expand Up @@ -43,7 +42,6 @@ std = [
"frame-support/std",
"frame-system/std",
"hex",
"k256/std",
"log/std",
"pallet-beefy/std",
"pallet-mmr-primitives/std",
Expand Down
3 changes: 2 additions & 1 deletion primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ dyn-clonable = { version = "0.9.0", optional = true }
thiserror = { version = "1.0.30", optional = true }
bitflags = "1.3"
k256 = { version = "0.10.2", default-features = false, features = ["ecdsa"] }
sp-core-hashing = { version = "4.0.0", default-features = false, path = "./hashing" }

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

[dev-dependencies]
Expand Down Expand Up @@ -134,6 +134,7 @@ full_crypto = [
"hex",
"libsecp256k1",
"secp256k1",
"sp-core-hashing",
"sp-runtime-interface/disable_target_static_assertions",
"merlin",
]
7 changes: 3 additions & 4 deletions primitives/core/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ecds");
type Seed = [u8; 32];

/// The ECDSA compressed public key.
#[cfg_attr(feature = "full_crypto", derive(Hash))]
#[derive(
Clone,
Copy,
Expand All @@ -71,7 +72,6 @@ type Seed = [u8; 32];
PartialEq,
PartialOrd,
Ord,
Hash,
)]
pub struct Public(pub [u8; 33]);

Expand Down Expand Up @@ -103,16 +103,15 @@ impl Public {

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

PublicKey::from_sec1_bytes(self.as_slice())
.map(|pub_key| {
// uncompress the key
let uncompressed = pub_key.to_encoded_point(false);
// convert to ETH address
let res: [u8; 20] =
keccak_256(&uncompressed.as_bytes()[1..])[12..].try_into().unwrap();
sp_io::hashing::keccak_256(&uncompressed.as_bytes()[1..])[12..].try_into().unwrap();
res
})
.map_err(|_| ())
Expand Down
4 changes: 2 additions & 2 deletions primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub use sp_debug_derive::RuntimeDebug;
#[cfg(feature = "std")]
pub use impl_serde::serialize as bytes;

#[cfg(feature = "full_crypto")]
pub mod hashing;
pub use hashing::keccak_256;

#[cfg(feature = "full_crypto")]
pub use hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64};
pub use hashing::{blake2_128, blake2_256, keccak_256, twox_128, twox_256, twox_64};
pub mod crypto;
pub mod hexdisplay;

Expand Down

0 comments on commit c4b6a29

Please sign in to comment.