Skip to content

Commit

Permalink
Making key comparison non-fuzziable
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Aug 9, 2021
1 parent 3f063c7 commit 7476c6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
25 changes: 13 additions & 12 deletions secp256k1-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,6 @@ extern "C" {
tweak: *const c_uchar)
-> c_int;

#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_ec_pubkey_cmp")]
pub fn secp256k1_ec_pubkey_cmp(cx: *const Context,
pubkey1: *const PublicKey,
pubkey2: *const PublicKey)
-> c_int;

#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_keypair_sec")]
pub fn secp256k1_keypair_sec(cx: *const Context,
output_seckey: *mut c_uchar,
Expand All @@ -366,12 +360,6 @@ extern "C" {
output_pubkey: *mut PublicKey,
keypair: *const KeyPair)
-> c_int;

#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_xonly_pubkey_cmp")]
pub fn secp256k1_xonly_pubkey_cmp(cx: *const Context,
pubkey1: *const XOnlyPublicKey,
pubkey2: *const XOnlyPublicKey)
-> c_int;
}

#[cfg(not(fuzzing))]
Expand Down Expand Up @@ -416,6 +404,12 @@ extern "C" {
pk: *mut PublicKey) -> c_int;


#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_ec_pubkey_cmp")]
pub fn secp256k1_ec_pubkey_cmp(cx: *const Context,
pubkey1: *const PublicKey,
pubkey2: *const PublicKey)
-> c_int;

#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_ec_pubkey_tweak_add")]
pub fn secp256k1_ec_pubkey_tweak_add(cx: *const Context,
pk: *mut PublicKey,
Expand Down Expand Up @@ -511,6 +505,13 @@ extern "C" {
pubkey: *const PublicKey,
) -> c_int;

#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_xonly_pubkey_cmp")]
pub fn secp256k1_xonly_pubkey_cmp(
cx: *const Context,
pubkey1: *const XOnlyPublicKey,
pubkey2: *const XOnlyPublicKey
) -> c_int;

#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_xonly_pubkey_tweak_add")]
pub fn secp256k1_xonly_pubkey_tweak_add(
cx: *const Context,
Expand Down
2 changes: 2 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,14 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey {
}
}

#[cfg(not(fuzzing))]
impl PartialOrd for PublicKey {
fn partial_cmp(&self, other: &PublicKey) -> Option<::core::cmp::Ordering> {
Some(self.cmp(other))
}
}

#[cfg(not(fuzzing))]
impl Ord for PublicKey {
fn cmp(&self, other: &PublicKey) -> ::core::cmp::Ordering {
let ret = unsafe {
Expand Down
2 changes: 2 additions & 0 deletions src/schnorrsig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ impl str::FromStr for PublicKey {
}
}

#[cfg(not(fuzzing))]
impl PartialOrd for PublicKey {
fn partial_cmp(&self, other: &PublicKey) -> Option<::core::cmp::Ordering> {
Some(self.cmp(other))
}
}

#[cfg(not(fuzzing))]
impl Ord for PublicKey {
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
let ret = unsafe {
Expand Down

0 comments on commit 7476c6a

Please sign in to comment.