diff --git a/src/key.rs b/src/key.rs index 6ec8618..80acaf6 100644 --- a/src/key.rs +++ b/src/key.rs @@ -212,9 +212,9 @@ impl SecretKey { SecretKey(sk) } - /// Serializes the secret key as byte value. + /// Returns the secret key as a byte value. #[inline] - pub fn serialize_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] { + pub fn secret_bytes(&self) -> [u8; constants::SECRET_KEY_SIZE] { self.0 } @@ -809,9 +809,9 @@ impl KeyPair { KeyPair::new(SECP256K1, rng) } - /// Serializes the key pair as a secret key byte value. + /// Returns the secret bytes for this key pair. #[inline] - pub fn serialize_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] { + pub fn secret_bytes(&self) -> [u8; constants::SECRET_KEY_SIZE] { *SecretKey::from_keypair(self).as_ref() } @@ -926,7 +926,7 @@ impl ::serde::Serialize for KeyPair { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { let mut buf = [0u8; constants::SECRET_KEY_SIZE * 2]; - s.serialize_str(::to_hex(&self.serialize_secret(), &mut buf) + s.serialize_str(::to_hex(&self.secret_bytes(), &mut buf) .expect("fixed-size hex serialization")) } else { s.serialize_bytes(&self.0[..]) diff --git a/src/secret.rs b/src/secret.rs index 2ef766b..b9eaba0 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -35,7 +35,7 @@ macro_rules! impl_display_secret { hasher.write(DEBUG_HASH_TAG); hasher.write(DEBUG_HASH_TAG); - hasher.write(&self.serialize_secret()); + hasher.write(&self.secret_bytes()); let hash = hasher.finish(); f.debug_tuple(stringify!($thing)) @@ -55,7 +55,7 @@ macro_rules! impl_display_secret { let tag_hash = sha256::Hash::hash(tag.as_bytes()); engine.input(&tag_hash[..]); engine.input(&tag_hash[..]); - engine.input(&self.serialize_secret()); + engine.input(&self.secret_bytes()); let hash = sha256::Hash::from_engine(engine); f.debug_tuple(stringify!($thing)) @@ -139,7 +139,7 @@ impl SecretKey { /// ``` #[inline] pub fn display_secret(&self) -> DisplaySecret { - DisplaySecret { secret: self.serialize_secret() } + DisplaySecret { secret: self.secret_bytes() } } } @@ -180,6 +180,6 @@ impl KeyPair { /// ``` #[inline] pub fn display_secret(&self) -> DisplaySecret { - DisplaySecret { secret: self.serialize_secret() } + DisplaySecret { secret: self.secret_bytes() } } }