Skip to content

Followups to #716 (add musig2 API) #794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@ required-features = ["rand", "std"]
[workspace]
members = ["secp256k1-sys"]
exclude = ["no_std_test"]

[lints.clippy]
# Exclude lints we don't think are valuable.
large_enum_variant = "allow" # docs say "measure before paying attention to this"; why is it on by default??
similar_names = "allow" # Too many (subjectively) false positives.
uninlined_format_args = "allow" # This is a subjective style choice.
indexing_slicing = "allow" # Too many false positives ... would be cool though
match_bool = "allow" # Adds extra indentation and LOC.
match_same_arms = "allow" # Collapses things that are conceptually unrelated to each other.
must_use_candidate = "allow" # Useful for audit but many false positives.
Comment on lines +77 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this lints be whitelisted in the modules as needed rather than globally here.
Also if whitelisting locally (either in modules or specific code) I would advocate to using expect than allow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lints are bad and I would rather not use clippy than deal with them. Global whitelisting is the right approach.

Using expect would require I know whether or not they trigger.

6 changes: 3 additions & 3 deletions examples/musig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use secp256k1::musig::{
new_nonce_pair, AggregatedNonce, KeyAggCache, PartialSignature, PublicNonce, Session,
SessionSecretRand,
};
use secp256k1::{pubkey_sort, Keypair, Message, PublicKey, Scalar, Secp256k1, SecretKey};
use secp256k1::{Keypair, Message, PublicKey, Scalar, Secp256k1, SecretKey};

fn main() {
let secp = Secp256k1::new();
let mut rng = rand::thread_rng();
let mut rng = rand::rng();

let (seckey1, pubkey1) = secp.generate_keypair(&mut rng);

Expand All @@ -19,7 +19,7 @@ fn main() {
let mut pubkeys_ref: Vec<&PublicKey> = pubkeys.iter().collect();
let pubkeys_ref = pubkeys_ref.as_mut_slice();

pubkey_sort(&secp, pubkeys_ref);
secp.musig_sort_pubkeys(pubkeys_ref);

let mut musig_key_agg_cache = KeyAggCache::new(&secp, pubkeys_ref);

Expand Down
5 changes: 0 additions & 5 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Eventually this shoud be: ignore = []
ignore = [
"secp256k1-sys"
]

hard_tabs = false
tab_spaces = 4
newline_style = "Auto"
Expand Down
10 changes: 10 additions & 0 deletions secp256k1-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ alloc = []

[lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] }

[lints.clippy]
# Exclude lints we don't think are valuable.
large_enum_variant = "allow" # docs say "measure before paying attention to this"; why is it on by default??
similar_names = "allow" # Too many (subjectively) false positives.
uninlined_format_args = "allow" # This is a subjective style choice.
indexing_slicing = "allow" # Too many false positives ... would be cool though
match_bool = "allow" # Adds extra indentation and LOC.
match_same_arms = "allow" # Collapses things that are conceptually unrelated to each other.
must_use_candidate = "allow" # Useful for audit but many false positives.
Comment on lines +41 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this lints be whitelisted in the modules as needed rather than globally here.
Also if whitelisting locally (either in modules or specific code) I would advocate to using expect than allow.

44 changes: 22 additions & 22 deletions secp256k1-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ use std::env;
fn main() {
// Actual build
let mut base_config = cc::Build::new();
base_config.include("depend/secp256k1/")
.include("depend/secp256k1/include")
.include("depend/secp256k1/src")
.flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
.flag_if_supported("-Wno-unused-parameter") // patching out printf causes this warning
.define("SECP256K1_API", Some(""))
.define("ENABLE_MODULE_ECDH", Some("1"))
.define("ENABLE_MODULE_SCHNORRSIG", Some("1"))
.define("ENABLE_MODULE_EXTRAKEYS", Some("1"))
.define("ENABLE_MODULE_ELLSWIFT", Some("1"))
.define("ENABLE_MODULE_MUSIG", Some("1"))
// upstream sometimes introduces calls to printf, which we cannot compile
// with WASM due to its lack of libc. printf is never necessary and we can
// just #define it away.
.define("printf(...)", Some(""));
base_config
.include("depend/secp256k1/")
.include("depend/secp256k1/include")
.include("depend/secp256k1/src")
.flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
.flag_if_supported("-Wno-unused-parameter") // patching out printf causes this warning
.define("SECP256K1_API", Some(""))
.define("ENABLE_MODULE_ECDH", Some("1"))
.define("ENABLE_MODULE_SCHNORRSIG", Some("1"))
.define("ENABLE_MODULE_EXTRAKEYS", Some("1"))
.define("ENABLE_MODULE_ELLSWIFT", Some("1"))
.define("ENABLE_MODULE_MUSIG", Some("1"))
// upstream sometimes introduces calls to printf, which we cannot compile
// with WASM due to its lack of libc. printf is never necessary and we can
// just #define it away.
.define("printf(...)", Some(""));

if cfg!(feature = "lowmemory") {
base_config.define("ECMULT_WINDOW_SIZE", Some("4")); // A low-enough value to consume negligible memory
Expand All @@ -45,15 +46,15 @@ fn main() {

// WASM headers and size/align defines.
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "wasm32" {
base_config.include("wasm/wasm-sysroot")
.file("wasm/wasm.c");
base_config.include("wasm/wasm-sysroot").file("wasm/wasm.c");
}

// secp256k1
base_config.file("depend/secp256k1/contrib/lax_der_parsing.c")
.file("depend/secp256k1/src/precomputed_ecmult_gen.c")
.file("depend/secp256k1/src/precomputed_ecmult.c")
.file("depend/secp256k1/src/secp256k1.c");
base_config
.file("depend/secp256k1/contrib/lax_der_parsing.c")
.file("depend/secp256k1/src/precomputed_ecmult_gen.c")
.file("depend/secp256k1/src/precomputed_ecmult.c")
.file("depend/secp256k1/src/secp256k1.c");

if base_config.try_compile("libsecp256k1.a").is_err() {
// Some embedded platforms may not have, eg, string.h available, so if the build fails
Expand All @@ -63,4 +64,3 @@ fn main() {
base_config.compile("libsecp256k1.a");
}
}

Loading
Loading