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 <jon_p_griffiths@yahoo.com>
This commit is contained in:
Jon Griffiths 2018-10-16 21:48:13 +13:00 committed by Rusty Russell
parent d3bfc9f260
commit 087ef43a0d
6 changed files with 6 additions and 0 deletions

View File

@ -338,6 +338,7 @@ int main(void)
size_t i; size_t i;
const struct chainparams *chainparams = chainparams_for_network("bitcoin"); const struct chainparams *chainparams = chainparams_for_network("bitcoin");
wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
setup_tmpctx(); setup_tmpctx();

View File

@ -128,6 +128,7 @@ void daemon_setup(const char *argv0,
/* We handle write returning errors! */ /* We handle write returning errors! */
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
setup_tmpctx(); setup_tmpctx();

View File

@ -123,6 +123,7 @@ int main(void)
u64 msatoshi; u64 msatoshi;
const char *badstr; const char *badstr;
wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
setup_tmpctx(); setup_tmpctx();

View File

@ -54,6 +54,7 @@ int main(void)
const tal_t *ctx = tal(NULL, char); const tal_t *ctx = tal(NULL, char);
struct info *baseline, *info; struct info *baseline, *info;
wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
baseline = new_info(ctx); baseline = new_info(ctx);
assert(derive_basepoints(&baseline->seed, &baseline->funding_pubkey, assert(derive_basepoints(&baseline->seed, &baseline->funding_pubkey,

View File

@ -14,6 +14,7 @@ int main(void)
u8 *bits, *lf, *gf; u8 *bits, *lf, *gf;
setup_locale(); setup_locale();
wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
setup_tmpctx(); setup_tmpctx();

View File

@ -1085,6 +1085,7 @@ int main(void)
struct lightningd *ld; struct lightningd *ld;
setup_tmpctx(); setup_tmpctx();
wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
ld = tal(tmpctx, struct lightningd); ld = tal(tmpctx, struct lightningd);