-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow-ups to making all tables fully static #1042
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bae7768
Rename gen_ecmult_gen_static_prec_table -> precompute_ecmult_gen
sipa f95b810
Rename gen_ecmult_static_pre_g -> precompute_ecmult
sipa 7cf47f7
Rename ecmult_gen_static_prec_table -> precomputed_ecmult_gen
sipa 075252c
Rename ecmult_static_pre_g -> precomputed_ecmult
sipa 725370c
Rename ecmult_gen_prec -> ecmult_gen_compute_table
sipa 31feab0
Rename function secp256k1_ecmult_gen_{create_prec -> compute}_table
sipa fc1bf9f
Split ecmult table computation and printing
sipa e458ec2
Move ecmult table computation code to separate file
sipa 38cd84a
Compute ecmult tables at runtime for tests_exhaustive
sipa bb36331
Simplify precompute_ecmult_print_*
sipa 1a6691a
Split off .c file from precomputed_ecmult_gen.h
sipa 19d96e1
Split off .c file from precomputed_ecmult.h
sipa c45386d
Cleanup preprocessor indentation in precompute{,d}_ecmult{,_gen}
sipa e05da9e
Fix c++ build
sipa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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). */ | ||
jonasnick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hebasto This is because we now have a separate compilation unit for the precomputed tables. So Core needs to tell MSVC to build
libsecp256k1_precomputed
separately and link it to the library.But I have no idea about the required changes to https://github.com/bitcoin/bitcoin/blob/master/build_msvc/libsecp256k1/libsecp256k1.vcxproj that would be equivalent to this automake snippet.
If this is anyway maintained within the Bitcoin Core org, maybe we should move the vcxproj file to this repo in the future. This will help us add MSVC builds to the CI here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sipsorcery
Could you look into this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hebasto inlcuding the new precompute
.c
files in thelibsecp25k1.vcxproj
got the build working for me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sipsorcery
Thanks! It works flawlessly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sipsorcery That works but it's too much: You don't need the
precompute_
files, theprecomputed
files should be enough.Also, this will then recompile the
precomputed_
files every time, which makes recompilation somewhat slower than what we have in our Makefile. (This was the reason why we introduced thelibsecp256k1_precomputed
as a separate object.) But yeah, this only affects compilation time, so it's probably not worth to optimize thevcxproj
for this.edit: Oh, now I see that @sipa already replied in bitcoin/bitcoin#23432 (comment).