Skip to content

Commit

Permalink
Merge #76: secp256k1-zkp-sys: remove not(fuzzing) gates on derives
Browse files Browse the repository at this point in the history
ee43b61 secp256k1-zkp-sys: remove not(fuzzing) gates on derives (Andrew Poelstra)

Pull request description:

  I'm not sure why these derives are gated on not(fuzzing); I believe that there used to be fuzzing-only manual implementations. These do not exist anymore (or maybe they only existed upstream), and as a result the library does not compile when fuzzing is enabled.

  Also, make sure that cfg(fuzzing) is replaced by cfg(rust_secp_fuzz) everywhere so that the user has the ability to disable fuzzing mode.

ACKs for top commit:
  delta1:
    utACK ee43b61
  RCasatta:
    ACK ee43b61

Tree-SHA512: be6ea9ceb0ae944f8662dd890ece1902770cb4364e543da68860c6378a266fd795f1ba94307c788bf988d645a978aca4d68d307639b18d18c5f96ac10e22a045
  • Loading branch information
apoelstra committed Jan 4, 2024
2 parents 89edfd4 + ee43b61 commit adb373a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions secp256k1-zkp-sys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.9.1 - 2023-01-03

- Many changes; restart CHANGELOG.

# 0.2.0 - 2021-01-06

- Completely replaced with https://github.com/comit-network/rust-secp256k1-zkp/ which has
Expand Down
2 changes: 1 addition & 1 deletion secp256k1-zkp-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "secp256k1-zkp-sys"
version = "0.9.0"
version = "0.9.1"
authors = [ "Dawid Ciężarkiewicz <[email protected]>",
"Andrew Poelstra <[email protected]>",
"Steven Roose <[email protected]>",
Expand Down
11 changes: 2 additions & 9 deletions secp256k1-zkp-sys/src/zkp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ impl RangeProof {
}

#[repr(C)]
#[derive(Copy, Clone)]
#[cfg_attr(not(fuzzing), derive(Eq, PartialEq, Hash, Ord, PartialOrd))]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Tag([c_uchar; 32]);
impl_array_newtype!(Tag, c_uchar, 32);
impl_raw_debug!(Tag);
Expand Down Expand Up @@ -533,8 +532,7 @@ impl From<Tag> for [u8; 32] {

// TODO: Replace this with ffi::PublicKey?
#[repr(C)]
#[derive(Copy, Clone)]
#[cfg_attr(not(fuzzing), derive(Ord, PartialOrd))]
#[derive(Copy, Clone, Ord, PartialOrd)]
pub struct PedersenCommitment([c_uchar; 64]);
impl_array_newtype!(PedersenCommitment, c_uchar, 64);
impl_raw_debug!(PedersenCommitment);
Expand All @@ -551,17 +549,14 @@ impl Default for PedersenCommitment {
}
}

#[cfg(not(fuzzing))]
impl PartialEq for PedersenCommitment {
fn eq(&self, other: &Self) -> bool {
self.0[..] == other.0[..]
}
}

#[cfg(not(fuzzing))]
impl Eq for PedersenCommitment {}

#[cfg(not(fuzzing))]
impl Hash for PedersenCommitment {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
Expand Down Expand Up @@ -647,12 +642,10 @@ impl EcdsaAdaptorSignature {
}
}

#[cfg(not(fuzzing))]
impl PartialEq for EcdsaAdaptorSignature {
fn eq(&self, other: &Self) -> bool {
self.0[..] == other.0[..]
}
}

#[cfg(not(fuzzing))]
impl Eq for EcdsaAdaptorSignature {}
3 changes: 1 addition & 2 deletions src/zkp/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use rand::Rng;
///
/// Contrary to a [`crate::SecretKey`], the value 0 is also a valid tweak.
/// Values outside secp curve order are invalid tweaks.
#[derive(Default, Copy, Clone)]
#[cfg_attr(not(fuzzing), derive(Eq, PartialEq, PartialOrd, Ord, Hash))]
#[derive(Default, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct Tweak([u8; constants::SECRET_KEY_SIZE]);
secp256k1_zkp_sys::impl_array_newtype!(Tweak, u8, constants::SECRET_KEY_SIZE);

Expand Down

0 comments on commit adb373a

Please sign in to comment.