From 087ef43a0d0823bbabfda45387ff109c527a1ee9 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Tue, 16 Oct 2018 21:48:13 +1300 Subject: [PATCH] Call wally_init(0) on startup to enabled assembly-optimised SHA-256 We probably also want to call secp_randomise/wally_secp_randomize here too, and since these calls all call setup_tmpctx, it probably makes sense to have a helper function to do all that. Until thats done, I modified the tests so grepping will show the places where the sequence of calls is repeated. Signed-off-by: Jon Griffiths --- channeld/test/run-full_channel.c | 1 + common/daemon.c | 1 + common/test/run-bolt11.c | 1 + common/test/run-derive_basepoints.c | 1 + common/test/run-features.c | 1 + wallet/test/run-wallet.c | 1 + 6 files changed, 6 insertions(+) diff --git a/channeld/test/run-full_channel.c b/channeld/test/run-full_channel.c index f8098acf1..9f067e3a6 100644 --- a/channeld/test/run-full_channel.c +++ b/channeld/test/run-full_channel.c @@ -338,6 +338,7 @@ int main(void) size_t i; const struct chainparams *chainparams = chainparams_for_network("bitcoin"); + wally_init(0); secp256k1_ctx = wally_get_secp_context(); setup_tmpctx(); diff --git a/common/daemon.c b/common/daemon.c index 8ffe4b59d..69d1f5762 100644 --- a/common/daemon.c +++ b/common/daemon.c @@ -128,6 +128,7 @@ void daemon_setup(const char *argv0, /* We handle write returning errors! */ signal(SIGPIPE, SIG_IGN); + wally_init(0); secp256k1_ctx = wally_get_secp_context(); setup_tmpctx(); diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c index 0863b8300..302bc3a89 100644 --- a/common/test/run-bolt11.c +++ b/common/test/run-bolt11.c @@ -123,6 +123,7 @@ int main(void) u64 msatoshi; const char *badstr; + wally_init(0); secp256k1_ctx = wally_get_secp_context(); setup_tmpctx(); diff --git a/common/test/run-derive_basepoints.c b/common/test/run-derive_basepoints.c index 543c2cb1d..0a4d8a0b3 100644 --- a/common/test/run-derive_basepoints.c +++ b/common/test/run-derive_basepoints.c @@ -54,6 +54,7 @@ int main(void) const tal_t *ctx = tal(NULL, char); struct info *baseline, *info; + wally_init(0); secp256k1_ctx = wally_get_secp_context(); baseline = new_info(ctx); assert(derive_basepoints(&baseline->seed, &baseline->funding_pubkey, diff --git a/common/test/run-features.c b/common/test/run-features.c index 6202b4db3..8c33f4b80 100644 --- a/common/test/run-features.c +++ b/common/test/run-features.c @@ -14,6 +14,7 @@ int main(void) u8 *bits, *lf, *gf; setup_locale(); + wally_init(0); secp256k1_ctx = wally_get_secp_context(); setup_tmpctx(); diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 909eefe69..2a85b753e 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -1085,6 +1085,7 @@ int main(void) struct lightningd *ld; setup_tmpctx(); + wally_init(0); secp256k1_ctx = wally_get_secp_context(); ld = tal(tmpctx, struct lightningd);