Rename serialize_secret -> secret_bytes
The `serialize_secret` method is a getter method, it does not do any serialisation. However we use the method on secret keys and key types so in order for the name to be uniform use the descriptive name `secret_bytes`. Rename `serialize_secret` to be `secret_bytes`.
This commit is contained in:
parent
4ded2c0478
commit
5c7c76eb74
10
src/key.rs
10
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<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
||||
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[..])
|
||||
|
|
|
@ -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() }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue