Skip to content

Commit 5c7c76e

Browse files
committed
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`.
1 parent 4ded2c0 commit 5c7c76e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/key.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ impl SecretKey {
212212
SecretKey(sk)
213213
}
214214

215-
/// Serializes the secret key as byte value.
215+
/// Returns the secret key as a byte value.
216216
#[inline]
217-
pub fn serialize_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] {
217+
pub fn secret_bytes(&self) -> [u8; constants::SECRET_KEY_SIZE] {
218218
self.0
219219
}
220220

@@ -809,9 +809,9 @@ impl KeyPair {
809809
KeyPair::new(SECP256K1, rng)
810810
}
811811

812-
/// Serializes the key pair as a secret key byte value.
812+
/// Returns the secret bytes for this key pair.
813813
#[inline]
814-
pub fn serialize_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] {
814+
pub fn secret_bytes(&self) -> [u8; constants::SECRET_KEY_SIZE] {
815815
*SecretKey::from_keypair(self).as_ref()
816816
}
817817

@@ -926,7 +926,7 @@ impl ::serde::Serialize for KeyPair {
926926
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
927927
if s.is_human_readable() {
928928
let mut buf = [0u8; constants::SECRET_KEY_SIZE * 2];
929-
s.serialize_str(::to_hex(&self.serialize_secret(), &mut buf)
929+
s.serialize_str(::to_hex(&self.secret_bytes(), &mut buf)
930930
.expect("fixed-size hex serialization"))
931931
} else {
932932
s.serialize_bytes(&self.0[..])

src/secret.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ macro_rules! impl_display_secret {
3535

3636
hasher.write(DEBUG_HASH_TAG);
3737
hasher.write(DEBUG_HASH_TAG);
38-
hasher.write(&self.serialize_secret());
38+
hasher.write(&self.secret_bytes());
3939
let hash = hasher.finish();
4040

4141
f.debug_tuple(stringify!($thing))
@@ -55,7 +55,7 @@ macro_rules! impl_display_secret {
5555
let tag_hash = sha256::Hash::hash(tag.as_bytes());
5656
engine.input(&tag_hash[..]);
5757
engine.input(&tag_hash[..]);
58-
engine.input(&self.serialize_secret());
58+
engine.input(&self.secret_bytes());
5959
let hash = sha256::Hash::from_engine(engine);
6060

6161
f.debug_tuple(stringify!($thing))
@@ -139,7 +139,7 @@ impl SecretKey {
139139
/// ```
140140
#[inline]
141141
pub fn display_secret(&self) -> DisplaySecret {
142-
DisplaySecret { secret: self.serialize_secret() }
142+
DisplaySecret { secret: self.secret_bytes() }
143143
}
144144
}
145145

@@ -180,6 +180,6 @@ impl KeyPair {
180180
/// ```
181181
#[inline]
182182
pub fn display_secret(&self) -> DisplaySecret {
183-
DisplaySecret { secret: self.serialize_secret() }
183+
DisplaySecret { secret: self.secret_bytes() }
184184
}
185185
}

0 commit comments

Comments
 (0)