Skip to content

Commit 62b9f06

Browse files
committed
build.rs: Add feature 'lowmemory' to reduce memory usage
Currently, this only set `ECMULT_WINDOW_SIZE` to 4 instead of 15. Fixes #139. fixup
1 parent b005089 commit 62b9f06

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
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.1 - ????-??-??
2+
3+
- Add feature `lowmemory` that reduces the EC mult window size to require
4+
significantly less memory for the validation context (~340B instead of
5+
~520kB), at the cost of slower validation. It does not affect signing, nor
6+
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)