Borrow secret key
`SecretKey` implements `Copy` and it is fine to take owneship of it; we have multiple methods called `from_secret_key` and they all borrow the secret key parameter. Favour consistency over perfection. Borrow secret key parameter as is done in other `from_secret_key` methods.
This commit is contained in:
parent
e4fb575590
commit
c612130864
|
@ -674,7 +674,7 @@ impl Ord for PublicKey {
|
|||
///
|
||||
/// let secp = Secp256k1::new();
|
||||
/// let (secret_key, public_key) = secp.generate_keypair(&mut rand::thread_rng());
|
||||
/// let key_pair = KeyPair::from_secret_key(&secp, secret_key);
|
||||
/// let key_pair = KeyPair::from_secret_key(&secp, &secret_key);
|
||||
/// # }
|
||||
/// ```
|
||||
/// [`Deserialize`]: serde::Deserialize
|
||||
|
@ -706,7 +706,7 @@ impl KeyPair {
|
|||
#[inline]
|
||||
pub fn from_secret_key<C: Signing>(
|
||||
secp: &Secp256k1<C>,
|
||||
sk: SecretKey,
|
||||
sk: &SecretKey,
|
||||
) -> KeyPair {
|
||||
unsafe {
|
||||
let mut kp = ffi::KeyPair::new();
|
||||
|
@ -1426,7 +1426,7 @@ pub mod serde_keypair {
|
|||
|
||||
Ok(KeyPair::from_secret_key(
|
||||
&::SECP256K1,
|
||||
secret_key,
|
||||
&secret_key,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ impl KeyPair {
|
|||
///
|
||||
/// let secp = Secp256k1::new();
|
||||
/// let key = ONE_KEY;
|
||||
/// let key = KeyPair::from_secret_key(&secp, key);
|
||||
/// let key = KeyPair::from_secret_key(&secp, &key);
|
||||
/// // Here we explicitly display the secret value:
|
||||
/// assert_eq!(
|
||||
/// "0000000000000000000000000000000000000000000000000000000000000001",
|
||||
|
|
Loading…
Reference in New Issue