Skip to content

Commit

Permalink
zkp-sys: replace external-symbols feature with cfg flag
Browse files Browse the repository at this point in the history
In secp256k1-sys we replaced this feature with a cfg flag back in
rust-bitcoin/rust-secp256k1#263 ... here we got
rid of the feature but retained the feature-gate, making the
functionality useless.

While we are at it, whitelist the cfg flags that we _do_ use.
  • Loading branch information
apoelstra committed Jun 10, 2024
1 parent 1e6dd22 commit 1928710
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ getrandom = { version = "0.2", features = ["js"] }

[lib]
crate-type = ["cdylib", "rlib"]

[lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = [ "cfg(rust_secp_fuzz)" ] }
3 changes: 3 additions & 0 deletions secp256k1-zkp-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ default = ["std"]
recovery = ["secp256k1-sys/recovery"]
lowmemory = ["secp256k1-sys/lowmemory"]
std = []

[lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = [ "cfg(rust_secp_zkp_no_symbol_renaming)" ] }
6 changes: 3 additions & 3 deletions secp256k1-zkp-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ revision the default branch is pointing to.

## Linking to external symbols

For the more exotic use cases, this crate can be used with existing libsecp256k1-zkp
symbols by using the `external-symbols` feature. How to setup rustc to link
against those existing symbols is left as an exercise to the reader.
If you want to compile this library without using the bundled symbols (which may
be required for integration into other build systems), you can do so by adding
`--cfg=rust_secp_no_symbol_renaming'` to your `RUSTFLAGS` variable.

## Minimum Supported Rust Version

Expand Down
5 changes: 0 additions & 5 deletions secp256k1-zkp-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ extern crate cc;
use std::env;

fn main() {
if cfg!(feature = "external-symbols") {
println!("cargo:rustc-link-lib=static=secp256k1zkp");
return;
}

// Actual build
let mut base_config = cc::Build::new();
base_config
Expand Down
4 changes: 2 additions & 2 deletions secp256k1-zkp-sys/src/error_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use secp256k1_sys::types::{c_char, c_void};

#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
#[cfg(not(rust_secp_zkp_no_symbol_renaming))]
pub unsafe extern "C" fn rustsecp256k1zkp_v0_8_0_default_illegal_callback_fn(
_: *const c_char,
_data: *mut c_void,
Expand All @@ -17,7 +17,7 @@ pub unsafe extern "C" fn rustsecp256k1zkp_v0_8_0_default_illegal_callback_fn(
}

#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
#[cfg(not(rust_secp_zkp_no_symbol_renaming))]
pub unsafe extern "C" fn rustsecp256k1zkp_v0_8_0_default_error_callback_fn(
_: *const c_char,
_data: *mut c_void,
Expand Down
54 changes: 27 additions & 27 deletions secp256k1-zkp-sys/src/zkp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub const WHITELIST_MAX_N_KEYS: size_t = 255;

extern "C" {
#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_pedersen_commitment_parse"
)]
// Parse a 33-byte commitment into 64 byte internal commitment object
Expand All @@ -24,7 +24,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_pedersen_commitment_serialize"
)]
// Serialize a 64-byte commit object into a 33 byte serialized byte sequence
Expand All @@ -35,7 +35,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_pedersen_commit"
)]
// Generates a pedersen commitment: *commit = blind * G + value * G2.
Expand All @@ -49,7 +49,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_pedersen_blind_generator_blind_sum"
)]
/// Sets the final Pedersen blinding factor correctly when the generators themselves
Expand Down Expand Up @@ -91,7 +91,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_pedersen_verify_tally"
)]
// Takes two list of 64-byte commitments and sums the first set and
Expand All @@ -106,7 +106,7 @@ extern "C" {

#[cfg(feature = "std")]
#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_rangeproof_info"
)]
pub fn secp256k1_rangeproof_info(
Expand All @@ -121,7 +121,7 @@ extern "C" {

#[cfg(feature = "std")]
#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_rangeproof_rewind"
)]
pub fn secp256k1_rangeproof_rewind(
Expand All @@ -143,7 +143,7 @@ extern "C" {

#[cfg(feature = "std")]
#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_rangeproof_verify"
)]
pub fn secp256k1_rangeproof_verify(
Expand All @@ -160,7 +160,7 @@ extern "C" {

#[cfg(feature = "std")]
#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_rangeproof_sign"
)]
pub fn secp256k1_rangeproof_sign(
Expand All @@ -182,7 +182,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_surjectionproof_initialize"
)]
pub fn secp256k1_surjectionproof_initialize(
Expand All @@ -198,7 +198,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_surjectionproof_serialize"
)]
pub fn secp256k1_surjectionproof_serialize(
Expand All @@ -209,7 +209,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_surjectionproof_serialized_size"
)]
pub fn secp256k1_surjectionproof_serialized_size(
Expand All @@ -218,7 +218,7 @@ extern "C" {
) -> size_t;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_surjectionproof_parse"
)]
pub fn secp256k1_surjectionproof_parse(
Expand All @@ -229,7 +229,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_surjectionproof_generate"
)]
pub fn secp256k1_surjectionproof_generate(
Expand All @@ -244,7 +244,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_surjectionproof_verify"
)]
pub fn secp256k1_surjectionproof_verify(
Expand All @@ -256,7 +256,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_generator_generate_blinded"
)]
pub fn secp256k1_generator_generate_blinded(
Expand All @@ -267,7 +267,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_generator_serialize"
)]
pub fn secp256k1_generator_serialize(
Expand All @@ -277,7 +277,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_generator_parse"
)]
pub fn secp256k1_generator_parse(
Expand All @@ -287,13 +287,13 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_nonce_function_ecdsa_adaptor"
)]
pub static secp256k1_nonce_function_ecdsa_adaptor: EcdsaAdaptorNonceFn;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_ecdsa_adaptor_encrypt"
)]
pub fn secp256k1_ecdsa_adaptor_encrypt(
Expand All @@ -307,7 +307,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_ecdsa_adaptor_verify"
)]
pub fn secp256k1_ecdsa_adaptor_verify(
Expand All @@ -319,7 +319,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_ecdsa_adaptor_decrypt"
)]
pub fn secp256k1_ecdsa_adaptor_decrypt(
Expand All @@ -330,7 +330,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_ecdsa_adaptor_recover"
)]
pub fn secp256k1_ecdsa_adaptor_recover(
Expand All @@ -342,7 +342,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_whitelist_signature_parse"
)]
pub fn secp256k1_whitelist_signature_parse(
Expand All @@ -353,7 +353,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_whitelist_signature_serialize"
)]
pub fn secp256k1_whitelist_signature_serialize(
Expand All @@ -364,7 +364,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_whitelist_sign"
)]
pub fn secp256k1_whitelist_sign(
Expand All @@ -380,7 +380,7 @@ extern "C" {
) -> c_int;

#[cfg_attr(
not(feature = "external-symbols"),
not(rust_secp_zkp_no_symbol_renaming),
link_name = "rustsecp256k1zkp_v0_8_0_whitelist_verify"
)]
pub fn secp256k1_whitelist_verify(
Expand Down

0 comments on commit 1928710

Please sign in to comment.