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

Commit d8a3640

Browse files
committed
Move Pair struct next to its implementations
1 parent 595f18e commit d8a3640

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

core/primitives/src/ed25519.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,6 @@ type Seed = [u8; 32];
4545
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)]
4646
pub struct Public(pub [u8; 32]);
4747

48-
/// A key pair.
49-
#[cfg(feature = "std")]
50-
pub struct Pair(ed25519_dalek::Keypair);
51-
52-
#[cfg(feature = "std")]
53-
impl Clone for Pair {
54-
fn clone(&self) -> Self {
55-
Pair(ed25519_dalek::Keypair {
56-
public: self.0.public.clone(),
57-
secret: ed25519_dalek::SecretKey::from_bytes(self.0.secret.as_bytes())
58-
.expect("key is always the correct size; qed")
59-
})
60-
}
61-
}
62-
6348
impl AsRef<[u8; 32]> for Public {
6449
fn as_ref(&self) -> &[u8; 32] {
6550
&self.0
@@ -353,6 +338,21 @@ pub enum DeriveError {
353338
SoftKeyInPath,
354339
}
355340

341+
/// A key pair.
342+
#[cfg(feature = "std")]
343+
pub struct Pair(ed25519_dalek::Keypair);
344+
345+
#[cfg(feature = "std")]
346+
impl Clone for Pair {
347+
fn clone(&self) -> Self {
348+
Pair(ed25519_dalek::Keypair {
349+
public: self.0.public.clone(),
350+
secret: ed25519_dalek::SecretKey::from_bytes(self.0.secret.as_bytes())
351+
.expect("key is always the correct size; qed")
352+
})
353+
}
354+
}
355+
356356
#[cfg(feature = "std")]
357357
impl TraitPair for Pair {
358358
type Public = Public;

core/primitives/src/sr25519.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,6 @@ const SIGNING_CTX: &[u8] = b"substrate";
5151
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)]
5252
pub struct Public(pub [u8; 32]);
5353

54-
/// An Schnorrkel/Ristretto x25519 ("sr25519") key pair.
55-
#[cfg(feature = "std")]
56-
pub struct Pair(Keypair);
57-
58-
#[cfg(feature = "std")]
59-
impl Clone for Pair {
60-
fn clone(&self) -> Self {
61-
Pair(schnorrkel::Keypair {
62-
public: self.0.public,
63-
secret: schnorrkel::SecretKey::from_bytes(&self.0.secret.to_bytes()[..])
64-
.expect("key is always the correct size; qed")
65-
})
66-
}
67-
}
68-
6954
impl AsRef<[u8; 32]> for Public {
7055
fn as_ref(&self) -> &[u8; 32] {
7156
&self.0
@@ -348,6 +333,21 @@ impl TraitPublic for Public {
348333
}
349334
}
350335

336+
/// An Schnorrkel/Ristretto x25519 ("sr25519") key pair.
337+
#[cfg(feature = "std")]
338+
pub struct Pair(Keypair);
339+
340+
#[cfg(feature = "std")]
341+
impl Clone for Pair {
342+
fn clone(&self) -> Self {
343+
Pair(schnorrkel::Keypair {
344+
public: self.0.public,
345+
secret: schnorrkel::SecretKey::from_bytes(&self.0.secret.to_bytes()[..])
346+
.expect("key is always the correct size; qed")
347+
})
348+
}
349+
}
350+
351351
#[cfg(feature = "std")]
352352
impl From<MiniSecretKey> for Pair {
353353
fn from(sec: MiniSecretKey) -> Pair {

0 commit comments

Comments
 (0)