diff --git a/profile/src/wallet_kit_common/types/hex_32bytes.rs b/profile/src/wallet_kit_common/types/hex_32bytes.rs index c6e85e07..398c3d77 100644 --- a/profile/src/wallet_kit_common/types/hex_32bytes.rs +++ b/profile/src/wallet_kit_common/types/hex_32bytes.rs @@ -23,12 +23,6 @@ pub struct Hex32Bytes { bytes: Vec, // FIXME: We REALLY want `[u8; 32]` - but that does not work in UniFFI land with `uniffi::Record` - so we should write an UniffiCustomTypeConverter for this (yet another one...) } -impl Default for Hex32Bytes { - fn default() -> Self { - Self::new() - } -} - impl Hex32Bytes { /// Instantiates a new `Hex32Bytes` from bytes generated by /// a CSPRNG. @@ -36,11 +30,6 @@ impl Hex32Bytes { Hex32Bytes::from_vec(generate_32_bytes()) .expect("Should be able to generate 32 bytes.") } - - /// Just an alias for `Self::generate()` - pub fn new() -> Self { - Self::generate() - } } impl Hex32Bytes { @@ -257,7 +246,7 @@ mod tests { let mut set: HashSet> = HashSet::new(); let n = 100; for _ in 0..n { - let bytes = Hex32Bytes::new(); + let bytes = Hex32Bytes::generate(); set.insert(bytes.to_vec()); } assert_eq!(set.len(), n); diff --git a/profile/src/wallet_kit_common/types/keys/ed25519/private_key.rs b/profile/src/wallet_kit_common/types/keys/ed25519/private_key.rs index eb7974fb..6a05904e 100644 --- a/profile/src/wallet_kit_common/types/keys/ed25519/private_key.rs +++ b/profile/src/wallet_kit_common/types/keys/ed25519/private_key.rs @@ -11,12 +11,6 @@ use transaction::signing::ed25519::{ #[debug("{}", self.to_hex())] pub struct Ed25519PrivateKey(EngineEd25519PrivateKey); -impl Default for Ed25519PrivateKey { - fn default() -> Self { - Self::new() - } -} - impl Ed25519PrivateKey { /// Generates a new `Ed25519PrivateKey` from random bytes /// generated by a CSRNG, note that this is typically never @@ -26,12 +20,6 @@ impl Ed25519PrivateKey { Self::from_hex32_bytes(Hex32Bytes::generate()) .expect("Should be able to generate 32 bytes") } - - /// Just an alias for `Self::generate()`, generating a new - /// key from random bytes. - pub fn new() -> Self { - Self::generate() - } } impl PartialEq for Ed25519PrivateKey { @@ -289,7 +277,7 @@ mod tests { let mut set: HashSet> = HashSet::new(); let n = 100; for _ in 0..n { - let key = Ed25519PrivateKey::new(); + let key = Ed25519PrivateKey::generate(); let bytes = key.to_bytes(); assert_eq!(bytes.len(), 32); set.insert(bytes); diff --git a/profile/src/wallet_kit_common/types/keys/private_key.rs b/profile/src/wallet_kit_common/types/keys/private_key.rs index 23fe3326..bff748e2 100644 --- a/profile/src/wallet_kit_common/types/keys/private_key.rs +++ b/profile/src/wallet_kit_common/types/keys/private_key.rs @@ -18,7 +18,7 @@ impl From for PrivateKey { /// extern crate profile; /// use profile::prelude::*; /// - /// let key: PublicKey = Ed25519PrivateKey::new().public_key().into(); + /// let key: PublicKey = Ed25519PrivateKey::generate().public_key().into(); /// ``` fn from(value: Ed25519PrivateKey) -> Self { Self::Ed25519(value) @@ -32,25 +32,14 @@ impl From for PrivateKey { /// extern crate profile; /// use profile::prelude::*; /// - /// let key: PublicKey = Secp256k1PrivateKey::new().public_key().into(); + /// let key: PublicKey = Secp256k1PrivateKey::generate().public_key().into(); /// ``` fn from(value: Secp256k1PrivateKey) -> Self { Self::Secp256k1(value) } } -impl Default for PrivateKey { - fn default() -> Self { - Self::new() - } -} - impl PrivateKey { - /// Generates a new `PrivateKey` over Curve25519. - pub fn new() -> Self { - Ed25519PrivateKey::generate().into() - } - /// Calculates the public key of the inner `PrivateKey` and wraps it /// in the `PublicKey` tagged union. pub fn public_key(&self) -> PublicKey { @@ -137,7 +126,7 @@ mod tests { let mut set: HashSet> = HashSet::new(); let n = 100; for _ in 0..n { - let key = PrivateKey::new(); + let key: PrivateKey = Ed25519PrivateKey::generate().into(); let bytes = key.to_bytes(); assert_eq!(bytes.len(), 32); set.insert(bytes); diff --git a/profile/src/wallet_kit_common/types/keys/public_key.rs b/profile/src/wallet_kit_common/types/keys/public_key.rs index 67be92d4..879e541b 100644 --- a/profile/src/wallet_kit_common/types/keys/public_key.rs +++ b/profile/src/wallet_kit_common/types/keys/public_key.rs @@ -30,7 +30,7 @@ impl From for PublicKey { /// extern crate profile; /// use profile::prelude::*; /// - /// let key: PublicKey = Ed25519PrivateKey::new().public_key().into(); + /// let key: PublicKey = Ed25519PrivateKey::generate().public_key().into(); /// ``` fn from(value: Ed25519PublicKey) -> Self { Self::Ed25519 { value } @@ -44,7 +44,7 @@ impl From for PublicKey { /// extern crate profile; /// use profile::prelude::*; /// - /// let key: PublicKey = Secp256k1PrivateKey::new().public_key().into(); + /// let key: PublicKey = Secp256k1PrivateKey::generate().public_key().into(); /// ``` fn from(value: Secp256k1PublicKey) -> Self { Self::Secp256k1 { value } diff --git a/profile/src/wallet_kit_common/types/keys/secp256k1/private_key.rs b/profile/src/wallet_kit_common/types/keys/secp256k1/private_key.rs index 25e22468..52b7452c 100644 --- a/profile/src/wallet_kit_common/types/keys/secp256k1/private_key.rs +++ b/profile/src/wallet_kit_common/types/keys/secp256k1/private_key.rs @@ -11,12 +11,6 @@ use transaction::signing::secp256k1::{ #[debug("{}", self.to_hex())] pub struct Secp256k1PrivateKey(EngineSecp256k1PrivateKey); -impl Default for Secp256k1PrivateKey { - fn default() -> Self { - Self::new() - } -} - impl Secp256k1PrivateKey { /// Generates a new `Secp256k1PrivateKey` from random bytes /// generated by a CSRNG, note that this is typically never @@ -26,12 +20,6 @@ impl Secp256k1PrivateKey { Self::from_hex32_bytes(Hex32Bytes::generate()) .expect("Should be able to generate 32 bytes") } - - /// Just an alias for `Self::generate()`, generating a new - /// key from random bytes. - pub fn new() -> Self { - Self::generate() - } } impl PartialEq for Secp256k1PrivateKey { @@ -306,7 +294,7 @@ mod tests { let mut set: HashSet> = HashSet::new(); let n = 100; for _ in 0..n { - let key = Secp256k1PrivateKey::new(); + let key = Secp256k1PrivateKey::generate(); let bytes = key.to_bytes(); assert_eq!(bytes.len(), 32); set.insert(bytes);