forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin-core/secp256k1#1042: Follow-ups to making all tables fu…
…lly static e05da9e Fix c++ build (Pieter Wuille) c45386d Cleanup preprocessor indentation in precompute{,d}_ecmult{,_gen} (Pieter Wuille) 19d96e1 Split off .c file from precomputed_ecmult.h (Pieter Wuille) 1a6691a Split off .c file from precomputed_ecmult_gen.h (Pieter Wuille) bb36331 Simplify precompute_ecmult_print_* (Pieter Wuille) 38cd84a Compute ecmult tables at runtime for tests_exhaustive (Pieter Wuille) e458ec2 Move ecmult table computation code to separate file (Pieter Wuille) fc1bf9f Split ecmult table computation and printing (Pieter Wuille) 31feab0 Rename function secp256k1_ecmult_gen_{create_prec -> compute}_table (Pieter Wuille) 725370c Rename ecmult_gen_prec -> ecmult_gen_compute_table (Pieter Wuille) 075252c Rename ecmult_static_pre_g -> precomputed_ecmult (Pieter Wuille) 7cf47f7 Rename ecmult_gen_static_prec_table -> precomputed_ecmult_gen (Pieter Wuille) f95b810 Rename gen_ecmult_static_pre_g -> precompute_ecmult (Pieter Wuille) bae7768 Rename gen_ecmult_gen_static_prec_table -> precompute_ecmult_gen (Pieter Wuille) Pull request description: This PR implements a number of changes to follow up after merging bitcoin#988: * Naming consistency: * All precomputed table files now have name `precomputed_*.*` * All source files related to the creation of the precomputed table files have name `precompute_*.*`. * All source files related to the computation of tables (whether they go in precomputed files or not) have name `*_compute_table.*`. * Make the tables for exhaustive tests be computed at runtime rather than compile time (this was already the case for ecmult_gen, but not ecmult). This is a preparation for the next point, as the alternative would be to have separate precomputed libraries for the exhaustive tests and other binaries. * Moves the actual tables to separate `precomputed_*.c` files, which are compiled only once as part of a new `libsecp256k1_precomputed.la`, included where relevant. The corresponding `precomputed_*.h` file are normal source files. Retry of bitcoin#1041. ACKs for top commit: real-or-random: ACK e05da9e jonasnick: ACK e05da9e Tree-SHA512: 71eadd66e30e511b786e910755e0eda53330dfa163b37e33602c3392f7b893569f56d3ca9870e85cbb3de83880fc5aef61ac3d55d759d7395086a69023f13f03
- Loading branch information
Showing
18 changed files
with
319 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
src/ecmult_static_pre_g.h linguist-generated | ||
src/ecmult_gen_static_prec_table.h linguist-generated | ||
src/precomputed_ecmult.c linguist-generated | ||
src/precomputed_ecmult_gen.c linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/***************************************************************************************************** | ||
* Copyright (c) 2013, 2014, 2017, 2021 Pieter Wuille, Andrew Poelstra, Jonas Nick, Russell O'Connor * | ||
* Distributed under the MIT software license, see the accompanying * | ||
* file COPYING or https://www.opensource.org/licenses/mit-license.php. * | ||
*****************************************************************************************************/ | ||
|
||
#ifndef SECP256K1_ECMULT_COMPUTE_TABLE_H | ||
#define SECP256K1_ECMULT_COMPUTE_TABLE_H | ||
|
||
/* Construct table of all odd multiples of gen in range 1..(2**(window_g-1)-1). */ | ||
static void secp256k1_ecmult_compute_table(secp256k1_ge_storage* table, int window_g, const secp256k1_gej* gen); | ||
|
||
/* Like secp256k1_ecmult_compute_table, but one for both gen and gen*2^128. */ | ||
static void secp256k1_ecmult_compute_two_tables(secp256k1_ge_storage* table, secp256k1_ge_storage* table_128, int window_g, const secp256k1_ge* gen); | ||
|
||
#endif /* SECP256K1_ECMULT_COMPUTE_TABLE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/***************************************************************************************************** | ||
* Copyright (c) 2013, 2014, 2017, 2021 Pieter Wuille, Andrew Poelstra, Jonas Nick, Russell O'Connor * | ||
* Distributed under the MIT software license, see the accompanying * | ||
* file COPYING or https://www.opensource.org/licenses/mit-license.php. * | ||
*****************************************************************************************************/ | ||
|
||
#ifndef SECP256K1_ECMULT_COMPUTE_TABLE_IMPL_H | ||
#define SECP256K1_ECMULT_COMPUTE_TABLE_IMPL_H | ||
|
||
#include "ecmult_compute_table.h" | ||
#include "group_impl.h" | ||
#include "field_impl.h" | ||
#include "ecmult.h" | ||
#include "util.h" | ||
|
||
static void secp256k1_ecmult_compute_table(secp256k1_ge_storage* table, int window_g, const secp256k1_gej* gen) { | ||
secp256k1_gej gj; | ||
secp256k1_ge ge, dgen; | ||
int j; | ||
|
||
gj = *gen; | ||
secp256k1_ge_set_gej_var(&ge, &gj); | ||
secp256k1_ge_to_storage(&table[0], &ge); | ||
|
||
secp256k1_gej_double_var(&gj, gen, NULL); | ||
secp256k1_ge_set_gej_var(&dgen, &gj); | ||
|
||
for (j = 1; j < ECMULT_TABLE_SIZE(window_g); ++j) { | ||
secp256k1_gej_set_ge(&gj, &ge); | ||
secp256k1_gej_add_ge_var(&gj, &gj, &dgen, NULL); | ||
secp256k1_ge_set_gej_var(&ge, &gj); | ||
secp256k1_ge_to_storage(&table[j], &ge); | ||
} | ||
} | ||
|
||
/* Like secp256k1_ecmult_compute_table, but one for both gen and gen*2^128. */ | ||
static void secp256k1_ecmult_compute_two_tables(secp256k1_ge_storage* table, secp256k1_ge_storage* table_128, int window_g, const secp256k1_ge* gen) { | ||
secp256k1_gej gj; | ||
int i; | ||
|
||
secp256k1_gej_set_ge(&gj, gen); | ||
secp256k1_ecmult_compute_table(table, window_g, &gj); | ||
for (i = 0; i < 128; ++i) { | ||
secp256k1_gej_double_var(&gj, &gj, NULL); | ||
} | ||
secp256k1_ecmult_compute_table(table_128, window_g, &gj); | ||
} | ||
|
||
#endif /* SECP256K1_ECMULT_COMPUTE_TABLE_IMPL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.