Skip to content

Commit d9aadc6

Browse files
committed
Merge #648: Rename KeyPair to Keypair
33747bb Rename KeyPair to Keypair (Tobin C. Harding) Pull request description: We use "keypair" in identifiers (local vars and function names) but `KeyPair` - one of them is wrong. Elect to follow upstream and define keypair as a single word i.e., use `Keypair` for type name and `keypair` in identifiers. This patch can be reproduced mechanically by doing two search-and-replace operations on all files excluding the CHANGELOG - Replace "KeyPair" with "Keypair" - Replace "key_pair" with "keypair" Fix #647 ACKs for top commit: apoelstra: ACK 33747bb Tree-SHA512: 2cb67cde3a39c4681e0628b17b12724fe17d00bc71e985b4eb0b3ad58d574f4a372aa782fc9cb7221cd2032d8312c579195ad2230a3eeb4c550865fa36e42c0b
2 parents 1f9c01a + 33747bb commit d9aadc6

File tree

6 files changed

+140
-140
lines changed

6 files changed

+140
-140
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bench marks use: `RUSTFLAGS='--cfg=bench' cargo +nightly bench --features=recove
4949

5050
### A note on `non_secure_erase`
5151

52-
This crate's secret types (`SecretKey`, `KeyPair`, `SharedSecret`, `Scalar`, and `DisplaySecret`)
52+
This crate's secret types (`SecretKey`, `Keypair`, `SharedSecret`, `Scalar`, and `DisplaySecret`)
5353
have a method called `non_secure_erase` that *attempts* to overwrite the contained secret. This
5454
method is provided to assist other libraries in building secure secret erasure. However, this
5555
library makes no guarantees about the security of using `non_secure_erase`. In particular,

secp256k1-sys/src/lib.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,11 @@ impl core::hash::Hash for XOnlyPublicKey {
395395
#[repr(C)]
396396
#[derive(Copy, Clone)]
397397
#[cfg_attr(secp256k1_fuzz, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
398-
pub struct KeyPair([c_uchar; 96]);
399-
impl_array_newtype!(KeyPair, c_uchar, 96);
400-
impl_raw_debug!(KeyPair);
398+
pub struct Keypair([c_uchar; 96]);
399+
impl_array_newtype!(Keypair, c_uchar, 96);
400+
impl_raw_debug!(Keypair);
401401

402-
impl KeyPair {
402+
impl Keypair {
403403
/// Creates an "uninitialized" FFI keypair which is zeroed out
404404
///
405405
/// # Safety
@@ -421,7 +421,7 @@ impl KeyPair {
421421
/// that you obtained from the FFI interface of the same version of this
422422
/// library.
423423
pub unsafe fn from_array_unchecked(data: [c_uchar; 96]) -> Self {
424-
KeyPair(data)
424+
Keypair(data)
425425
}
426426

427427
/// Returns the underlying FFI opaque representation of the x-only public key
@@ -480,33 +480,33 @@ pub fn non_secure_erase_impl<T>(dst: &mut T, src: T) {
480480
}
481481

482482
#[cfg(not(secp256k1_fuzz))]
483-
impl PartialOrd for KeyPair {
484-
fn partial_cmp(&self, other: &KeyPair) -> Option<core::cmp::Ordering> {
483+
impl PartialOrd for Keypair {
484+
fn partial_cmp(&self, other: &Keypair) -> Option<core::cmp::Ordering> {
485485
Some(self.cmp(other))
486486
}
487487
}
488488

489489
#[cfg(not(secp256k1_fuzz))]
490-
impl Ord for KeyPair {
491-
fn cmp(&self, other: &KeyPair) -> core::cmp::Ordering {
490+
impl Ord for Keypair {
491+
fn cmp(&self, other: &Keypair) -> core::cmp::Ordering {
492492
let this = self.public_key();
493493
let that = other.public_key();
494494
this.cmp(&that)
495495
}
496496
}
497497

498498
#[cfg(not(secp256k1_fuzz))]
499-
impl PartialEq for KeyPair {
499+
impl PartialEq for Keypair {
500500
fn eq(&self, other: &Self) -> bool {
501501
self.cmp(other) == core::cmp::Ordering::Equal
502502
}
503503
}
504504

505505
#[cfg(not(secp256k1_fuzz))]
506-
impl Eq for KeyPair {}
506+
impl Eq for Keypair {}
507507

508508
#[cfg(not(secp256k1_fuzz))]
509-
impl core::hash::Hash for KeyPair {
509+
impl core::hash::Hash for Keypair {
510510
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
511511
// To hash the key pair we just hash the serialized public key. Since any change to the
512512
// secret key would also be a change to the public key this is a valid one way function from
@@ -592,13 +592,13 @@ extern "C" {
592592
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_keypair_sec")]
593593
pub fn secp256k1_keypair_sec(cx: *const Context,
594594
output_seckey: *mut c_uchar,
595-
keypair: *const KeyPair)
595+
keypair: *const Keypair)
596596
-> c_int;
597597

598598
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_keypair_pub")]
599599
pub fn secp256k1_keypair_pub(cx: *const Context,
600600
output_pubkey: *mut PublicKey,
601-
keypair: *const KeyPair)
601+
keypair: *const Keypair)
602602
-> c_int;
603603
}
604604

@@ -702,7 +702,7 @@ extern "C" {
702702
cx: *const Context,
703703
sig: *mut c_uchar,
704704
msg32: *const c_uchar,
705-
keypair: *const KeyPair,
705+
keypair: *const Keypair,
706706
aux_rand32: *const c_uchar
707707
) -> c_int;
708708

@@ -713,7 +713,7 @@ extern "C" {
713713
sig: *mut c_uchar,
714714
msg: *const c_uchar,
715715
msg_len: size_t,
716-
keypair: *const KeyPair,
716+
keypair: *const Keypair,
717717
extra_params: *const SchnorrSigExtraParams,
718718
) -> c_int;
719719

@@ -730,7 +730,7 @@ extern "C" {
730730
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_keypair_create")]
731731
pub fn secp256k1_keypair_create(
732732
cx: *const Context,
733-
keypair: *mut KeyPair,
733+
keypair: *mut Keypair,
734734
seckey: *const c_uchar,
735735
) -> c_int;
736736

@@ -776,13 +776,13 @@ extern "C" {
776776
cx: *const Context,
777777
pubkey: *mut XOnlyPublicKey,
778778
pk_parity: *mut c_int,
779-
keypair: *const KeyPair
779+
keypair: *const Keypair
780780
) -> c_int;
781781

782782
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_keypair_xonly_tweak_add")]
783783
pub fn secp256k1_keypair_xonly_tweak_add(
784784
cx: *const Context,
785-
keypair: *mut KeyPair,
785+
keypair: *mut Keypair,
786786
tweak32: *const c_uchar,
787787
) -> c_int;
788788

@@ -1316,12 +1316,12 @@ mod fuzz_dummy {
13161316
cx: *const Context,
13171317
sig64: *mut c_uchar,
13181318
msg32: *const c_uchar,
1319-
keypair: *const KeyPair,
1319+
keypair: *const Keypair,
13201320
_aux_rand32: *const c_uchar
13211321
) -> c_int {
13221322
check_context_flags(cx, SECP256K1_START_SIGN);
13231323
// Check context is built for signing
1324-
let mut new_kp = KeyPair::new();
1324+
let mut new_kp = Keypair::new();
13251325
if secp256k1_keypair_create(cx, &mut new_kp, (*keypair).0.as_ptr()) != 1 {
13261326
return 0;
13271327
}
@@ -1341,7 +1341,7 @@ mod fuzz_dummy {
13411341
sig: *mut c_uchar,
13421342
msg: *const c_uchar,
13431343
_msg_len: size_t,
1344-
keypair: *const KeyPair,
1344+
keypair: *const Keypair,
13451345
_extra_params: *const SchnorrSigExtraParams,
13461346
) -> c_int {
13471347
secp256k1_schnorrsig_sign(cx, sig, msg, keypair, ptr::null())
@@ -1350,7 +1350,7 @@ mod fuzz_dummy {
13501350
// Extra keys
13511351
pub unsafe fn secp256k1_keypair_create(
13521352
cx: *const Context,
1353-
keypair: *mut KeyPair,
1353+
keypair: *mut Keypair,
13541354
seckey: *const c_uchar,
13551355
) -> c_int {
13561356
check_context_flags(cx, SECP256K1_START_SIGN);
@@ -1419,7 +1419,7 @@ mod fuzz_dummy {
14191419
cx: *const Context,
14201420
pubkey: *mut XOnlyPublicKey,
14211421
pk_parity: *mut c_int,
1422-
keypair: *const KeyPair
1422+
keypair: *const Keypair
14231423
) -> c_int {
14241424
check_context_flags(cx, 0);
14251425
if !pk_parity.is_null() {
@@ -1431,7 +1431,7 @@ mod fuzz_dummy {
14311431

14321432
pub unsafe fn secp256k1_keypair_xonly_tweak_add(
14331433
cx: *const Context,
1434-
keypair: *mut KeyPair,
1434+
keypair: *mut Keypair,
14351435
tweak32: *const c_uchar,
14361436
) -> c_int {
14371437
check_context_flags(cx, SECP256K1_START_VERIFY);

0 commit comments

Comments
 (0)