Skip to content
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "secp256k1-sys/depend/secp256k1"]
path = secp256k1-sys/depend/secp256k1
url = https://github.com/mimblewimble/secp256k1-zkp.git
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ global-context = ["std", "rand-std"]
secp256k1-sys = { version = "0.4.0", default-features = false, path = "./secp256k1-sys" }
bitcoin_hashes = { version = "0.9", optional = true }
rand = { version = "0.6", default-features = false, optional = true }
rand_core = "0.4"
serde = { version = "1.0", default-features = false, optional = true }


[dev-dependencies]
chrono = "0.4"
rand = "0.6"
rand_core = "0.4"
serde_test = "1.0"
Expand Down
43 changes: 43 additions & 0 deletions secp256k1-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,38 @@ use std::env;

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

// Check whether we can use 64-bit compilation
let use_64bit_compilation = if env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "64" {
let check = cc::Build::new().file("depend/check_uint128_t.c")
.cargo_metadata(false)
.try_compile("check_uint128_t")
.is_ok();
if !check {
println!("cargo:warning=Compiling in 32-bit mode on a 64-bit architecture due to lack of uint128_t support.");
}
check
} else {
false
};

// 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
.define("SECP256K1_BUILD", Some("1"))
.define("ENABLE_MODULE_ECDH", Some("1"))
.define("ENABLE_MODULE_GENERATOR", Some("1"))
.define("ENABLE_MODULE_RECOVERY", Some("1"))
.define("ENABLE_MODULE_RANGEPROOF", Some("1"))
.define("ENABLE_MODULE_BULLETPROOF", Some("1"))
.define("ENABLE_MODULE_AGGSIG", Some("1"))
.define("ENABLE_MODULE_SCHNORRSIG", Some("1"))
.define("ENABLE_MODULE_EXTRAKEYS", Some("1"))
.define("ECMULT_GEN_PREC_BITS", Some("4"))
Expand All @@ -47,6 +72,14 @@ fn main() {
} else {
base_config.define("ECMULT_WINDOW_SIZE", Some("15")); // This is the default in the configure file (`auto`)
}


if let Ok(target_endian) = env::var("CARGO_CFG_TARGET_ENDIAN") {
if target_endian == "big" {
base_config.define("WORDS_BIGENDIAN", Some("1"));
}
}

base_config.define("USE_EXTERNAL_DEFAULT_CALLBACKS", Some("1"));
#[cfg(feature = "recovery")]
base_config.define("ENABLE_MODULE_RECOVERY", Some("1"));
Expand All @@ -57,6 +90,16 @@ fn main() {
_ => {},
}


if use_64bit_compilation {
base_config.define("USE_FIELD_5X52", Some("1"))
.define("USE_SCALAR_4X64", Some("1"))
.define("HAVE___INT128", Some("1"));
} else {
base_config.define("USE_FIELD_10X26", Some("1"))
.define("USE_SCALAR_8X32", Some("1"));
}

// secp256k1
base_config.file("depend/secp256k1/contrib/lax_der_parsing.c")
.file("depend/secp256k1/src/secp256k1.c")
Expand Down
1 change: 1 addition & 0 deletions secp256k1-sys/depend/secp256k1
Submodule secp256k1 added at 7da428
53 changes: 0 additions & 53 deletions secp256k1-sys/depend/secp256k1/.gitignore

This file was deleted.

109 changes: 0 additions & 109 deletions secp256k1-sys/depend/secp256k1/.travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions secp256k1-sys/depend/secp256k1/COPYING

This file was deleted.

Loading