Skip to content

Commit 86531e5

Browse files
committed
Use new feature to gate test vectors behind
To match the local signatures found in test vectors, we must make sure we don't use any additional randomess when generating signatures, as we'll arrive at a different signature otherwise.
1 parent 16edbd4 commit 86531e5

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

ci/ci-tests.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
3535
cargo test --verbose --color always --no-default-features --features no-std
3636
# check if there is a conflict between no-std and the default std feature
3737
cargo test --verbose --color always --features no-std
38-
# check that things still pass without grind_signatures
39-
# note that outbound_commitment_test only runs in this mode, because of hardcoded signature values
40-
cargo test --verbose --color always --no-default-features --features std
4138
# check if there is a conflict between no-std and the c_bindings cfg
4239
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std
4340
popd
4441
done
42+
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
43+
pushd lightning
44+
cargo test --verbose --color always --no-default-features --features=std,_test_vectors
45+
popd
4546
# This one only works for lightning-invoice
4647
pushd lightning-invoice
4748
# check that compile with no-std and serde works in lightning-invoice

lightning/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ max_level_trace = []
2929
# This is unsafe to use in production because it may result in the counterparty publishing taking our funds.
3030
unsafe_revoked_tx_signing = []
3131
_bench_unstable = []
32+
# Override signing to not include randomness when generating signatures for test vectors.
33+
_test_vectors = []
3234

3335
no-std = ["hashbrown", "bitcoin/no-std", "core2/alloc"]
3436
std = ["bitcoin/std"]

lightning/src/ln/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7516,7 +7516,7 @@ mod tests {
75167516
}
75177517
}
75187518

7519-
#[cfg(not(feature = "grind_signatures"))]
7519+
#[cfg(feature = "_test_vectors")]
75207520
#[test]
75217521
fn outbound_commitment_test() {
75227522
use bitcoin::util::sighash;

lightning/src/util/crypto.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ pub fn sign_with_aux_rand<C: Signing, ES: Deref>(
6262
break sig;
6363
}
6464
};
65-
#[cfg(not(feature = "grind_signatures"))]
65+
#[cfg(all(not(feature = "grind_signatures"), not(feature = "_test_vectors")))]
6666
let sig = ctx.sign_ecdsa_with_noncedata(msg, sk, &entropy_source.get_secure_random_bytes());
67+
#[cfg(all(not(feature = "grind_signatures"), feature = "_test_vectors"))]
68+
let sig = sign(ctx, msg, sk);
6769
sig
6870
}

0 commit comments

Comments
 (0)