Merge rust-bitcoin/rust-secp256k1#608: change --cfg=fuzzing to --cfg=secp256k1_fuzzing
9bdab89562
change --cfg=fuzzing to --cfg=secp256k1_fuzz (Andrew Poelstra) Pull request description: Companion PR to https://github.com/rust-bitcoin/rust-bitcoin/pull/1821 ACKs for top commit: sanket1729: ACK9bdab89562
Tree-SHA512: 9ff5ce4cae99089f85a73a845cd5dca7b7d0ad9e73c0ee180e73fd9a55c6b92f21ad0192c8c0976e2e590be9d5d899b113b8b2006a3c53e0146a3ce5ba1450ec
This commit is contained in:
commit
be2999ad58
|
@ -54,7 +54,9 @@ If you want to fuzz this library, or any library which depends on it, you will
|
||||||
probably want to disable the actual cryptography, since fuzzers are unable to
|
probably want to disable the actual cryptography, since fuzzers are unable to
|
||||||
forge signatures and therefore won't test many interesting codepaths. To instead
|
forge signatures and therefore won't test many interesting codepaths. To instead
|
||||||
use a trivially-broken but fuzzer-accessible signature scheme, compile with
|
use a trivially-broken but fuzzer-accessible signature scheme, compile with
|
||||||
`--cfg=fuzzing` in your `RUSTFLAGS` variable.
|
`--cfg=secp256k1_fuzz` in your `RUSTFLAGS` variable.
|
||||||
|
|
||||||
Note that `cargo hfuzz` sets this config flag automatically.
|
Note that `cargo hfuzz` does **not** set this config flag automatically. In 0.27.0
|
||||||
|
and earlier versions, we used the `--cfg=fuzzing` which honggfuzz does set, but we
|
||||||
|
changed this because there was no way to override it.
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
|
||||||
cargo test --all --no-default-features --features="std,$feature"
|
cargo test --all --no-default-features --features="std,$feature"
|
||||||
done
|
done
|
||||||
# Other combos
|
# Other combos
|
||||||
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS='--cfg=fuzzing' cargo test --all
|
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all
|
||||||
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS='--cfg=fuzzing' cargo test --all --features="$FEATURES"
|
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --features="$FEATURES"
|
||||||
cargo test --all --features="rand serde"
|
cargo test --all --features="rand serde"
|
||||||
|
|
||||||
if [ "$NIGHTLY" = true ]; then
|
if [ "$NIGHTLY" = true ]; then
|
||||||
cargo test --all --all-features
|
cargo test --all --all-features
|
||||||
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS='--cfg=fuzzing' cargo test --all --all-features
|
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --all-features
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern crate core;
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
const THIS_UNUSED_CONSTANT_IS_YOUR_WARNING_THAT_ALL_THE_CRYPTO_IN_THIS_LIB_IS_DISABLED_FOR_FUZZING: usize = 0;
|
const THIS_UNUSED_CONSTANT_IS_YOUR_WARNING_THAT_ALL_THE_CRYPTO_IN_THIS_LIB_IS_DISABLED_FOR_FUZZING: usize = 0;
|
||||||
|
|
||||||
mod macros;
|
mod macros;
|
||||||
|
@ -133,7 +133,7 @@ impl SchnorrSigExtraParams {
|
||||||
/// Library-internal representation of a Secp256k1 public key
|
/// Library-internal representation of a Secp256k1 public key
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
#[cfg_attr(secp256k1_fuzz, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||||
pub struct PublicKey([c_uchar; 64]);
|
pub struct PublicKey([c_uchar; 64]);
|
||||||
impl_array_newtype!(PublicKey, c_uchar, 64);
|
impl_array_newtype!(PublicKey, c_uchar, 64);
|
||||||
impl_raw_debug!(PublicKey);
|
impl_raw_debug!(PublicKey);
|
||||||
|
@ -190,14 +190,14 @@ impl PublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialOrd for PublicKey {
|
impl PartialOrd for PublicKey {
|
||||||
fn partial_cmp(&self, other: &PublicKey) -> Option<core::cmp::Ordering> {
|
fn partial_cmp(&self, other: &PublicKey) -> Option<core::cmp::Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Ord for PublicKey {
|
impl Ord for PublicKey {
|
||||||
fn cmp(&self, other: &PublicKey) -> core::cmp::Ordering {
|
fn cmp(&self, other: &PublicKey) -> core::cmp::Ordering {
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
|
@ -207,17 +207,17 @@ impl Ord for PublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialEq for PublicKey {
|
impl PartialEq for PublicKey {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.cmp(other) == core::cmp::Ordering::Equal
|
self.cmp(other) == core::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Eq for PublicKey {}
|
impl Eq for PublicKey {}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl core::hash::Hash for PublicKey {
|
impl core::hash::Hash for PublicKey {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
let ser = self.serialize();
|
let ser = self.serialize();
|
||||||
|
@ -228,7 +228,7 @@ impl core::hash::Hash for PublicKey {
|
||||||
/// Library-internal representation of a Secp256k1 signature
|
/// Library-internal representation of a Secp256k1 signature
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
#[cfg_attr(secp256k1_fuzz, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||||
pub struct Signature([c_uchar; 64]);
|
pub struct Signature([c_uchar; 64]);
|
||||||
impl_array_newtype!(Signature, c_uchar, 64);
|
impl_array_newtype!(Signature, c_uchar, 64);
|
||||||
impl_raw_debug!(Signature);
|
impl_raw_debug!(Signature);
|
||||||
|
@ -281,14 +281,14 @@ impl Signature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialOrd for Signature {
|
impl PartialOrd for Signature {
|
||||||
fn partial_cmp(&self, other: &Signature) -> Option<core::cmp::Ordering> {
|
fn partial_cmp(&self, other: &Signature) -> Option<core::cmp::Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Ord for Signature {
|
impl Ord for Signature {
|
||||||
fn cmp(&self, other: &Signature) -> core::cmp::Ordering {
|
fn cmp(&self, other: &Signature) -> core::cmp::Ordering {
|
||||||
let this = self.serialize();
|
let this = self.serialize();
|
||||||
|
@ -297,17 +297,17 @@ impl Ord for Signature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialEq for Signature {
|
impl PartialEq for Signature {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.cmp(other) == core::cmp::Ordering::Equal
|
self.cmp(other) == core::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Eq for Signature {}
|
impl Eq for Signature {}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl core::hash::Hash for Signature {
|
impl core::hash::Hash for Signature {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
let ser = self.serialize();
|
let ser = self.serialize();
|
||||||
|
@ -317,7 +317,7 @@ impl core::hash::Hash for Signature {
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
#[cfg_attr(secp256k1_fuzz, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||||
pub struct XOnlyPublicKey([c_uchar; 64]);
|
pub struct XOnlyPublicKey([c_uchar; 64]);
|
||||||
impl_array_newtype!(XOnlyPublicKey, c_uchar, 64);
|
impl_array_newtype!(XOnlyPublicKey, c_uchar, 64);
|
||||||
impl_raw_debug!(XOnlyPublicKey);
|
impl_raw_debug!(XOnlyPublicKey);
|
||||||
|
@ -370,14 +370,14 @@ impl XOnlyPublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialOrd for XOnlyPublicKey {
|
impl PartialOrd for XOnlyPublicKey {
|
||||||
fn partial_cmp(&self, other: &XOnlyPublicKey) -> Option<core::cmp::Ordering> {
|
fn partial_cmp(&self, other: &XOnlyPublicKey) -> Option<core::cmp::Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Ord for XOnlyPublicKey {
|
impl Ord for XOnlyPublicKey {
|
||||||
fn cmp(&self, other: &XOnlyPublicKey) -> core::cmp::Ordering {
|
fn cmp(&self, other: &XOnlyPublicKey) -> core::cmp::Ordering {
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
|
@ -387,17 +387,17 @@ impl Ord for XOnlyPublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialEq for XOnlyPublicKey {
|
impl PartialEq for XOnlyPublicKey {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.cmp(other) == core::cmp::Ordering::Equal
|
self.cmp(other) == core::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Eq for XOnlyPublicKey {}
|
impl Eq for XOnlyPublicKey {}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl core::hash::Hash for XOnlyPublicKey {
|
impl core::hash::Hash for XOnlyPublicKey {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
let ser = self.serialize();
|
let ser = self.serialize();
|
||||||
|
@ -407,7 +407,7 @@ impl core::hash::Hash for XOnlyPublicKey {
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
#[cfg_attr(secp256k1_fuzz, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||||
pub struct KeyPair([c_uchar; 96]);
|
pub struct KeyPair([c_uchar; 96]);
|
||||||
impl_array_newtype!(KeyPair, c_uchar, 96);
|
impl_array_newtype!(KeyPair, c_uchar, 96);
|
||||||
impl_raw_debug!(KeyPair);
|
impl_raw_debug!(KeyPair);
|
||||||
|
@ -492,14 +492,14 @@ pub fn non_secure_erase_impl<T>(dst: &mut T, src: T) {
|
||||||
atomic::compiler_fence(atomic::Ordering::SeqCst);
|
atomic::compiler_fence(atomic::Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialOrd for KeyPair {
|
impl PartialOrd for KeyPair {
|
||||||
fn partial_cmp(&self, other: &KeyPair) -> Option<core::cmp::Ordering> {
|
fn partial_cmp(&self, other: &KeyPair) -> Option<core::cmp::Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Ord for KeyPair {
|
impl Ord for KeyPair {
|
||||||
fn cmp(&self, other: &KeyPair) -> core::cmp::Ordering {
|
fn cmp(&self, other: &KeyPair) -> core::cmp::Ordering {
|
||||||
let this = self.public_key();
|
let this = self.public_key();
|
||||||
|
@ -508,17 +508,17 @@ impl Ord for KeyPair {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialEq for KeyPair {
|
impl PartialEq for KeyPair {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.cmp(other) == core::cmp::Ordering::Equal
|
self.cmp(other) == core::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Eq for KeyPair {}
|
impl Eq for KeyPair {}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl core::hash::Hash for KeyPair {
|
impl core::hash::Hash for KeyPair {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
// To hash the key pair we just hash the serialized public key. Since any change to the
|
// To hash the key pair we just hash the serialized public key. Since any change to the
|
||||||
|
@ -615,7 +615,7 @@ extern "C" {
|
||||||
-> c_int;
|
-> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// Contexts
|
// Contexts
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_context_preallocated_size")]
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_context_preallocated_size")]
|
||||||
|
@ -996,7 +996,7 @@ impl<T> CPtr for [T] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
mod fuzz_dummy {
|
mod fuzz_dummy {
|
||||||
use super::*;
|
use super::*;
|
||||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
@ -1482,7 +1482,7 @@ mod fuzz_dummy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
pub use self::fuzz_dummy::*;
|
pub use self::fuzz_dummy::*;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -22,7 +22,7 @@ use core::fmt;
|
||||||
/// Library-internal representation of a Secp256k1 signature + recovery ID
|
/// Library-internal representation of a Secp256k1 signature + recovery ID
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
#[cfg_attr(secp256k1_fuzz, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||||
pub struct RecoverableSignature([c_uchar; 65]);
|
pub struct RecoverableSignature([c_uchar; 65]);
|
||||||
impl_array_newtype!(RecoverableSignature, c_uchar, 65);
|
impl_array_newtype!(RecoverableSignature, c_uchar, 65);
|
||||||
|
|
||||||
|
@ -78,14 +78,14 @@ impl fmt::Debug for RecoverableSignature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialOrd for RecoverableSignature {
|
impl PartialOrd for RecoverableSignature {
|
||||||
fn partial_cmp(&self, other: &RecoverableSignature) -> Option<core::cmp::Ordering> {
|
fn partial_cmp(&self, other: &RecoverableSignature) -> Option<core::cmp::Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Ord for RecoverableSignature {
|
impl Ord for RecoverableSignature {
|
||||||
fn cmp(&self, other: &RecoverableSignature) -> core::cmp::Ordering {
|
fn cmp(&self, other: &RecoverableSignature) -> core::cmp::Ordering {
|
||||||
let this = self.serialize();
|
let this = self.serialize();
|
||||||
|
@ -94,17 +94,17 @@ impl Ord for RecoverableSignature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl PartialEq for RecoverableSignature {
|
impl PartialEq for RecoverableSignature {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.cmp(other) == core::cmp::Ordering::Equal
|
self.cmp(other) == core::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl Eq for RecoverableSignature {}
|
impl Eq for RecoverableSignature {}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
impl core::hash::Hash for RecoverableSignature {
|
impl core::hash::Hash for RecoverableSignature {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
let ser = self.serialize();
|
let ser = self.serialize();
|
||||||
|
@ -129,7 +129,7 @@ extern "C" {
|
||||||
-> c_int;
|
-> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_ecdsa_sign_recoverable")]
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_8_1_ecdsa_sign_recoverable")]
|
||||||
pub fn secp256k1_ecdsa_sign_recoverable(cx: *const Context,
|
pub fn secp256k1_ecdsa_sign_recoverable(cx: *const Context,
|
||||||
|
@ -149,7 +149,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
mod fuzz_dummy {
|
mod fuzz_dummy {
|
||||||
use core::slice;
|
use core::slice;
|
||||||
|
|
||||||
|
@ -221,5 +221,5 @@ mod fuzz_dummy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
pub use self::fuzz_dummy::*;
|
pub use self::fuzz_dummy::*;
|
||||||
|
|
|
@ -238,7 +238,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
#[cfg(all(feature = "bitcoin-hashes-std", feature = "rand-std"))]
|
#[cfg(all(feature = "bitcoin-hashes-std", feature = "rand-std"))]
|
||||||
fn bitcoin_hashes_and_sys_generate_same_secret() {
|
fn bitcoin_hashes_and_sys_generate_same_secret() {
|
||||||
use bitcoin_hashes::{sha256, Hash, HashEngine};
|
use bitcoin_hashes::{sha256, Hash, HashEngine};
|
||||||
|
|
|
@ -326,7 +326,7 @@ impl<C: Signing> Secp256k1<C> {
|
||||||
entropy_p = extra_entropy.as_c_ptr().cast::<ffi::types::c_void>();
|
entropy_p = extra_entropy.as_c_ptr().cast::<ffi::types::c_void>();
|
||||||
|
|
||||||
// When fuzzing, these checks will usually spinloop forever, so just short-circuit them.
|
// When fuzzing, these checks will usually spinloop forever, so just short-circuit them.
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
return Signature::from(ret);
|
return Signature::from(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
#[cfg(feature = "rand-std")]
|
#[cfg(feature = "rand-std")]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn sign() {
|
fn sign() {
|
||||||
|
@ -289,7 +289,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
#[cfg(feature = "rand-std")]
|
#[cfg(feature = "rand-std")]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn sign_with_noncedata() {
|
fn sign_with_noncedata() {
|
||||||
|
|
50
src/key.rs
50
src/key.rs
|
@ -1564,7 +1564,7 @@ mod test {
|
||||||
use crate::Error::{InvalidPublicKey, InvalidSecretKey};
|
use crate::Error::{InvalidPublicKey, InvalidSecretKey};
|
||||||
use crate::{constants, from_hex, to_hex, Scalar};
|
use crate::{constants, from_hex, to_hex, Scalar};
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
macro_rules! hex {
|
macro_rules! hex {
|
||||||
($hex:expr) => {{
|
($hex:expr) => {{
|
||||||
let mut result = vec![0; $hex.len() / 2];
|
let mut result = vec![0; $hex.len() / 2];
|
||||||
|
@ -1614,7 +1614,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(feature = "std", not(fuzzing)))]
|
#[cfg(all(feature = "std", not(secp256k1_fuzz)))]
|
||||||
fn erased_keypair_is_valid() {
|
fn erased_keypair_is_valid() {
|
||||||
let s = Secp256k1::new();
|
let s = Secp256k1::new();
|
||||||
let kp = KeyPair::from_seckey_slice(&s, &[1u8; constants::SECRET_KEY_SIZE])
|
let kp = KeyPair::from_seckey_slice(&s, &[1u8; constants::SECRET_KEY_SIZE])
|
||||||
|
@ -1764,15 +1764,15 @@ mod test {
|
||||||
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
|
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
|
||||||
];
|
];
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
let s = Secp256k1::signing_only();
|
let s = Secp256k1::signing_only();
|
||||||
let sk = SecretKey::from_slice(&SK_BYTES).expect("sk");
|
let sk = SecretKey::from_slice(&SK_BYTES).expect("sk");
|
||||||
|
|
||||||
// In fuzzing mode secret->public key derivation is different, so
|
// In fuzzing mode secret->public key derivation is different, so
|
||||||
// hard-code the expected result.
|
// hard-code the expected result.
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
let pk = PublicKey::from_secret_key(&s, &sk);
|
let pk = PublicKey::from_secret_key(&s, &sk);
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
let pk = PublicKey::from_slice(&[
|
let pk = PublicKey::from_slice(&[
|
||||||
0x02, 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30,
|
0x02, 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30,
|
||||||
0x92, 0x06, 0x7d, 0x06, 0x83, 0x7f, 0x30, 0xaa, 0x0c, 0xd0, 0x54, 0x4a, 0xc8, 0x87,
|
0x92, 0x06, 0x7d, 0x06, 0x83, 0x7f, 0x30, 0xaa, 0x0c, 0xd0, 0x54, 0x4a, 0xc8, 0x87,
|
||||||
|
@ -1859,7 +1859,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
// In fuzzing mode the Y coordinate is expected to match the X, so this
|
// In fuzzing mode the Y coordinate is expected to match the X, so this
|
||||||
// test uses invalid public keys.
|
// test uses invalid public keys.
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
#[cfg(all(feature = "alloc", feature = "rand"))]
|
#[cfg(all(feature = "alloc", feature = "rand"))]
|
||||||
fn test_pubkey_serialize() {
|
fn test_pubkey_serialize() {
|
||||||
let s = Secp256k1::new();
|
let s = Secp256k1::new();
|
||||||
|
@ -1993,7 +1993,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
fn pubkey_combine() {
|
fn pubkey_combine() {
|
||||||
let compressed1 = PublicKey::from_slice(&hex!(
|
let compressed1 = PublicKey::from_slice(&hex!(
|
||||||
"0241cc121c419921942add6db6482fb36243faf83317c866d2a28d8c6d7089f7ba"
|
"0241cc121c419921942add6db6482fb36243faf83317c866d2a28d8c6d7089f7ba"
|
||||||
|
@ -2017,7 +2017,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
fn pubkey_combine_keys() {
|
fn pubkey_combine_keys() {
|
||||||
let compressed1 = PublicKey::from_slice(&hex!(
|
let compressed1 = PublicKey::from_slice(&hex!(
|
||||||
"0241cc121c419921942add6db6482fb36243faf83317c866d2a28d8c6d7089f7ba"
|
"0241cc121c419921942add6db6482fb36243faf83317c866d2a28d8c6d7089f7ba"
|
||||||
|
@ -2045,7 +2045,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
fn pubkey_combine_keys_empty_slice() {
|
fn pubkey_combine_keys_empty_slice() {
|
||||||
assert!(PublicKey::combine_keys(&[]).is_err());
|
assert!(PublicKey::combine_keys(&[]).is_err());
|
||||||
}
|
}
|
||||||
|
@ -2069,7 +2069,7 @@ mod test {
|
||||||
assert_eq!(Ok(sksum), sum1);
|
assert_eq!(Ok(sksum), sum1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(clippy::nonminimal_bool)]
|
#[allow(clippy::nonminimal_bool)]
|
||||||
fn pubkey_equal() {
|
fn pubkey_equal() {
|
||||||
|
@ -2108,7 +2108,7 @@ mod test {
|
||||||
];
|
];
|
||||||
static SK_STR: &str = "01010101010101010001020304050607ffff0000ffff00006363636363636363";
|
static SK_STR: &str = "01010101010101010001020304050607ffff0000ffff00006363636363636363";
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
static PK_BYTES: [u8; 33] = [
|
static PK_BYTES: [u8; 33] = [
|
||||||
0x02,
|
0x02,
|
||||||
|
@ -2119,15 +2119,15 @@ mod test {
|
||||||
];
|
];
|
||||||
static PK_STR: &str = "0218845781f631c48f1c9709e23092067d06837f30aa0cd0544ac887fe91ddd166";
|
static PK_STR: &str = "0218845781f631c48f1c9709e23092067d06837f30aa0cd0544ac887fe91ddd166";
|
||||||
|
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
let s = Secp256k1::new();
|
let s = Secp256k1::new();
|
||||||
let sk = SecretKey::from_slice(&SK_BYTES).unwrap();
|
let sk = SecretKey::from_slice(&SK_BYTES).unwrap();
|
||||||
|
|
||||||
// In fuzzing mode secret->public key derivation is different, so
|
// In fuzzing mode secret->public key derivation is different, so
|
||||||
// hard-code the expected result.
|
// hard-code the expected result.
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
let pk = PublicKey::from_secret_key(&s, &sk);
|
let pk = PublicKey::from_secret_key(&s, &sk);
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
let pk = PublicKey::from_slice(&PK_BYTES).expect("pk");
|
let pk = PublicKey::from_slice(&PK_BYTES).expect("pk");
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
@ -2237,7 +2237,7 @@ mod test {
|
||||||
assert_tokens(&sk.readable(), &[Token::String(SK_STR)]);
|
assert_tokens(&sk.readable(), &[Token::String(SK_STR)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn keys() -> (SecretKey, PublicKey, KeyPair, XOnlyPublicKey) {
|
fn keys() -> (SecretKey, PublicKey, KeyPair, XOnlyPublicKey) {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
|
||||||
|
@ -2270,7 +2270,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn convert_public_key_to_xonly_public_key() {
|
fn convert_public_key_to_xonly_public_key() {
|
||||||
let (_sk, pk, _kp, want) = keys();
|
let (_sk, pk, _kp, want) = keys();
|
||||||
let (got, parity) = pk.x_only_public_key();
|
let (got, parity) = pk.x_only_public_key();
|
||||||
|
@ -2280,7 +2280,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn convert_secret_key_to_public_key() {
|
fn convert_secret_key_to_public_key() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
|
||||||
|
@ -2291,7 +2291,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn convert_secret_key_to_x_only_public_key() {
|
fn convert_secret_key_to_x_only_public_key() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
|
||||||
|
@ -2303,7 +2303,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn convert_keypair_to_public_key() {
|
fn convert_keypair_to_public_key() {
|
||||||
let (_sk, want, kp, _xonly) = keys();
|
let (_sk, want, kp, _xonly) = keys();
|
||||||
let got = kp.public_key();
|
let got = kp.public_key();
|
||||||
|
@ -2312,7 +2312,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn convert_keypair_to_x_only_public_key() {
|
fn convert_keypair_to_x_only_public_key() {
|
||||||
let (_sk, _pk, kp, want) = keys();
|
let (_sk, _pk, kp, want) = keys();
|
||||||
let (got, parity) = kp.x_only_public_key();
|
let (got, parity) = kp.x_only_public_key();
|
||||||
|
@ -2323,7 +2323,7 @@ mod test {
|
||||||
|
|
||||||
// SecretKey -> KeyPair -> SecretKey
|
// SecretKey -> KeyPair -> SecretKey
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn roundtrip_secret_key_via_keypair() {
|
fn roundtrip_secret_key_via_keypair() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
let (sk, _pk, _kp, _xonly) = keys();
|
let (sk, _pk, _kp, _xonly) = keys();
|
||||||
|
@ -2336,7 +2336,7 @@ mod test {
|
||||||
|
|
||||||
// KeyPair -> SecretKey -> KeyPair
|
// KeyPair -> SecretKey -> KeyPair
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn roundtrip_keypair_via_secret_key() {
|
fn roundtrip_keypair_via_secret_key() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
let (_sk, _pk, kp, _xonly) = keys();
|
let (_sk, _pk, kp, _xonly) = keys();
|
||||||
|
@ -2349,7 +2349,7 @@ mod test {
|
||||||
|
|
||||||
// XOnlyPublicKey -> PublicKey -> XOnlyPublicKey
|
// XOnlyPublicKey -> PublicKey -> XOnlyPublicKey
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn roundtrip_x_only_public_key_via_public_key() {
|
fn roundtrip_x_only_public_key_via_public_key() {
|
||||||
let (_sk, _pk, _kp, xonly) = keys();
|
let (_sk, _pk, _kp, xonly) = keys();
|
||||||
|
|
||||||
|
@ -2362,7 +2362,7 @@ mod test {
|
||||||
|
|
||||||
// PublicKey -> XOnlyPublicKey -> PublicKey
|
// PublicKey -> XOnlyPublicKey -> PublicKey
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
fn roundtrip_public_key_via_x_only_public_key() {
|
fn roundtrip_public_key_via_x_only_public_key() {
|
||||||
let (_sk, pk, _kp, _xonly) = keys();
|
let (_sk, pk, _kp, _xonly) = keys();
|
||||||
|
|
||||||
|
@ -2386,7 +2386,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
#[cfg(all(feature = "global-context", feature = "serde"))]
|
#[cfg(all(feature = "global-context", feature = "serde"))]
|
||||||
fn test_serde_x_only_pubkey() {
|
fn test_serde_x_only_pubkey() {
|
||||||
use serde_test::{assert_tokens, Configure, Token};
|
use serde_test::{assert_tokens, Configure, Token};
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -124,7 +124,7 @@
|
||||||
//! 0xc9, 0x42, 0x8f, 0xca, 0x69, 0xc1, 0x32, 0xa2,
|
//! 0xc9, 0x42, 0x8f, 0xca, 0x69, 0xc1, 0x32, 0xa2,
|
||||||
//! ]).expect("compact signatures are 64 bytes; DER signatures are 68-72 bytes");
|
//! ]).expect("compact signatures are 64 bytes; DER signatures are 68-72 bytes");
|
||||||
//!
|
//!
|
||||||
//! # #[cfg(not(fuzzing))]
|
//! # #[cfg(not(secp256k1_fuzz))]
|
||||||
//! assert!(secp.verify_ecdsa(&message, &sig, &public_key).is_ok());
|
//! assert!(secp.verify_ecdsa(&message, &sig, &public_key).is_ok());
|
||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -796,12 +796,12 @@ mod tests {
|
||||||
if compact[0] < 0x80 {
|
if compact[0] < 0x80 {
|
||||||
assert_eq!(sig, low_r_sig);
|
assert_eq!(sig, low_r_sig);
|
||||||
} else {
|
} else {
|
||||||
#[cfg(not(fuzzing))] // mocked sig generation doesn't produce low-R sigs
|
#[cfg(not(secp256k1_fuzz))] // mocked sig generation doesn't produce low-R sigs
|
||||||
assert_ne!(sig, low_r_sig);
|
assert_ne!(sig, low_r_sig);
|
||||||
}
|
}
|
||||||
#[cfg(not(fuzzing))] // mocked sig generation doesn't produce low-R sigs
|
#[cfg(not(secp256k1_fuzz))] // mocked sig generation doesn't produce low-R sigs
|
||||||
assert!(ecdsa::compact_sig_has_zero_first_bit(&low_r_sig.0));
|
assert!(ecdsa::compact_sig_has_zero_first_bit(&low_r_sig.0));
|
||||||
#[cfg(not(fuzzing))] // mocked sig generation doesn't produce low-R sigs
|
#[cfg(not(secp256k1_fuzz))] // mocked sig generation doesn't produce low-R sigs
|
||||||
assert!(ecdsa::der_length_check(&grind_r_sig.0, 70));
|
assert!(ecdsa::der_length_check(&grind_r_sig.0, 70));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fuzz-sigs have fixed size/format
|
#[cfg(not(secp256k1_fuzz))] // fuzz-sigs have fixed size/format
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
fn test_noncedata() {
|
fn test_noncedata() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
@ -931,7 +931,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
fn test_low_s() {
|
fn test_low_s() {
|
||||||
// nb this is a transaction on testnet
|
// nb this is a transaction on testnet
|
||||||
|
@ -954,7 +954,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fuzz-sigs have fixed size/format
|
#[cfg(not(secp256k1_fuzz))] // fuzz-sigs have fixed size/format
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
fn test_low_r() {
|
fn test_low_r() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
@ -972,7 +972,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fuzz-sigs have fixed size/format
|
#[cfg(not(secp256k1_fuzz))] // fuzz-sigs have fixed size/format
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
fn test_grind_r() {
|
fn test_grind_r() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
@ -989,7 +989,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serde() {
|
fn test_serde() {
|
||||||
|
|
|
@ -199,7 +199,7 @@ mod tests {
|
||||||
use crate::Error::InvalidPublicKey;
|
use crate::Error::InvalidPublicKey;
|
||||||
use crate::{constants, from_hex, Message, Secp256k1, SecretKey};
|
use crate::{constants, from_hex, Message, Secp256k1, SecretKey};
|
||||||
|
|
||||||
#[cfg(all(not(fuzzing), feature = "alloc"))]
|
#[cfg(all(not(secp256k1_fuzz), feature = "alloc"))]
|
||||||
macro_rules! hex_32 {
|
macro_rules! hex_32 {
|
||||||
($hex:expr) => {{
|
($hex:expr) => {{
|
||||||
let mut result = [0u8; 32];
|
let mut result = [0u8; 32];
|
||||||
|
@ -255,7 +255,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
fn schnorr_sign() {
|
fn schnorr_sign() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
fn schnorr_verify() {
|
fn schnorr_verify() {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
|
@ -349,7 +349,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
// In fuzzing mode restrictions on public key validity are much more
|
// In fuzzing mode restrictions on public key validity are much more
|
||||||
// relaxed, thus the invalid check below is expected to fail.
|
// relaxed, thus the invalid check below is expected to fail.
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
XOnlyPublicKey::from_slice(&[0x55; constants::SCHNORR_PUBLIC_KEY_SIZE]),
|
XOnlyPublicKey::from_slice(&[0x55; constants::SCHNORR_PUBLIC_KEY_SIZE]),
|
||||||
Err(InvalidPublicKey)
|
Err(InvalidPublicKey)
|
||||||
|
@ -360,7 +360,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
fn test_pubkey_display_output() {
|
fn test_pubkey_display_output() {
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
let pk = {
|
let pk = {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
static SK_BYTES: [u8; 32] = [
|
static SK_BYTES: [u8; 32] = [
|
||||||
|
@ -376,7 +376,7 @@ mod tests {
|
||||||
let (pk, _parity) = kp.x_only_public_key();
|
let (pk, _parity) = kp.x_only_public_key();
|
||||||
pk
|
pk
|
||||||
};
|
};
|
||||||
#[cfg(fuzzing)]
|
#[cfg(secp256k1_fuzz)]
|
||||||
let pk = XOnlyPublicKey::from_slice(&[
|
let pk = XOnlyPublicKey::from_slice(&[
|
||||||
0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92,
|
0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92,
|
||||||
0x06, 0x7d, 0x06, 0x83, 0x7f, 0x30, 0xaa, 0x0c, 0xd0, 0x54, 0x4a, 0xc8, 0x87, 0xfe,
|
0x06, 0x7d, 0x06, 0x83, 0x7f, 0x30, 0xaa, 0x0c, 0xd0, 0x54, 0x4a, 0xc8, 0x87, 0xfe,
|
||||||
|
@ -424,7 +424,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
// In fuzzing mode secret->public key derivation is different, so
|
// In fuzzing mode secret->public key derivation is different, so
|
||||||
// this test will never correctly derive the static pubkey.
|
// this test will never correctly derive the static pubkey.
|
||||||
#[cfg(not(fuzzing))]
|
#[cfg(not(secp256k1_fuzz))]
|
||||||
#[cfg(all(feature = "rand", feature = "alloc"))]
|
#[cfg(all(feature = "rand", feature = "alloc"))]
|
||||||
fn test_pubkey_serialize() {
|
fn test_pubkey_serialize() {
|
||||||
use rand::rngs::mock::StepRng;
|
use rand::rngs::mock::StepRng;
|
||||||
|
@ -440,7 +440,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
|
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(feature = "serde", feature = "alloc"))]
|
#[cfg(all(feature = "serde", feature = "alloc"))]
|
||||||
fn test_serde() {
|
fn test_serde() {
|
||||||
|
|
|
@ -183,7 +183,7 @@ impl SharedSecret {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # #[cfg(not(fuzzing))]
|
/// # #[cfg(not(secp256k1_fuzz))]
|
||||||
/// # #[cfg(feature = "std")] {
|
/// # #[cfg(feature = "std")] {
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// use secp256k1::{SecretKey, PublicKey};
|
/// use secp256k1::{SecretKey, PublicKey};
|
||||||
|
|
Loading…
Reference in New Issue