Skip to content

Commit 288cc1e

Browse files
authored
Merge pull request #140 from laanwj/2019_08_lowmemory
build.rs: Add feature 'lowmemory' to reduce memory usage
2 parents b005089 + 62e5178 commit 288cc1e

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ script:
3030
- cargo build --verbose --no-default-features --features="rand"
3131
- cargo build --verbose --no-default-features --features="rand serde recovery endomorphism"
3232
- cargo build --verbose --no-default-features --features="fuzztarget recovery"
33+
- cargo build --verbose --no-default-features --features="lowmemory"
3334
- cargo build --verbose
3435
- cargo test --verbose
3536
- cargo build --release

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.15.2 - 2019-08-08
2+
3+
- Add feature `lowmemory` that reduces the EC mult window size to require
4+
significantly less memory for the validation context (~680B instead of
5+
~520kB), at the cost of slower validation. It does not affect the speed of
6+
signing, nor the size of the signing context.
7+
18
# 0.15.0 - 2019-07-25
29

310
* Implement hex human-readable serde for PublicKey

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "secp256k1"
4-
version = "0.15.1"
4+
version = "0.15.2"
55
authors = [ "Dawid Ciężarkiewicz <dpc@ucore.info>",
66
"Andrew Poelstra <apoelstra@wpsoftware.net>" ]
77
license = "CC0-1.0"
@@ -32,6 +32,7 @@ fuzztarget = []
3232
std = ["rand/std"]
3333
recovery = []
3434
endomorphism = []
35+
lowmemory = []
3536

3637
[dev-dependencies]
3738
rand = "0.6"

build.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ fn main() {
5353
.define("USE_FIELD_INV_BUILTIN", Some("1"))
5454
.define("USE_SCALAR_INV_BUILTIN", Some("1"))
5555
.define("ENABLE_MODULE_ECDH", Some("1"))
56-
.define("USE_EXTERNAL_DEFAULT_CALLBACKS", Some("1"))
57-
.define("ECMULT_WINDOW_SIZE", Some("15")); // This is the default in the configure file (`auto`)
56+
.define("USE_EXTERNAL_DEFAULT_CALLBACKS", Some("1"));
5857

58+
if cfg!(feature = "lowmemory") {
59+
base_config.define("ECMULT_WINDOW_SIZE", Some("4")); // A low-enough value to consume neglible memory
60+
} else {
61+
base_config.define("ECMULT_WINDOW_SIZE", Some("15")); // This is the default in the configure file (`auto`)
62+
}
5963
#[cfg(feature = "endomorphism")]
6064
base_config.define("USE_ENDOMORPHISM", Some("1"));
6165
#[cfg(feature = "recovery")]

0 commit comments

Comments
 (0)