From 8cf43a22f7794517c7649bffbd60ecb809326e64 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:19:53 -1100 Subject: [PATCH 01/45] ../secp256k1/src/ --- src/cc/cclib.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 625872483..df60833d2 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,9 +584,12 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -//#define USE_BASIC_CONFIG -//#include "../secp256k1/src/basic-config.h" +#define USE_BASIC_CONFIG +#include "../secp256k1/src/basic-config.h" //#include "../secp256k1/src/secp256k1.c" +#include "../secp256k1/src/modules/schnorrsig/main_impl.h" +#include "../secp256k1/src/modules/musig/main_impl.h" + #include "musig.cpp" #endif From 9d8ec78d880dce011f65bc67d680656a9d0a9322 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:21:49 -1100 Subject: [PATCH 02/45] ../secp256k1/src/ --- src/cc/cclib.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index df60833d2..2ccfcce46 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -586,6 +586,21 @@ uint256 juint256(cJSON *obj) #include "sudoku.cpp" #define USE_BASIC_CONFIG #include "../secp256k1/src/basic-config.h" +#include "../secp256k1/include/secp256k1.h" + +#include "../secp256k1/src/util.h" +#include "../secp256k1/src/num_impl.h" +#include "../secp256k1/src/field_impl.h" +#include "../secp256k1/src/scalar_impl.h" +#include "../secp256k1/src/group_impl.h" +#include "../secp256k1/src/ecmult_impl.h" +#include "../secp256k1/src/ecmult_const_impl.h" +#include "../secp256k1/src/ecmult_gen_impl.h" +#include "../secp256k1/src/ecdsa_impl.h" +#include "../secp256k1/src/eckey_impl.h" +#include "../secp256k1/src/hash_impl.h" +#include "../secp256k1/src/scratch_impl.h" + //#include "../secp256k1/src/secp256k1.c" #include "../secp256k1/src/modules/schnorrsig/main_impl.h" #include "../secp256k1/src/modules/musig/main_impl.h" From df9f4a10928e80e91fc83c01dc5c49767490398e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:22:54 -1100 Subject: [PATCH 03/45] ARG_CHECK --- src/cc/cclib.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 2ccfcce46..b6a79b32e 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -601,6 +601,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/hash_impl.h" #include "../secp256k1/src/scratch_impl.h" +#define ARG_CHECK(cond) do { \ +if (EXPECT(!(cond), 0)) { \ +secp256k1_callback_call(&ctx->illegal_callback, #cond); \ +return 0; \ +} \ +} while(0) + //#include "../secp256k1/src/secp256k1.c" #include "../secp256k1/src/modules/schnorrsig/main_impl.h" #include "../secp256k1/src/modules/musig/main_impl.h" From b9c1f3bc3d1e46f524abc207d9a5166bebd107a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:33:15 -1100 Subject: [PATCH 04/45] Ctx --- src/cc/cclib.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b6a79b32e..496005016 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -601,6 +601,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/hash_impl.h" #include "../secp256k1/src/scratch_impl.h" +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; + #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ secp256k1_callback_call(&ctx->illegal_callback, #cond); \ From 6d3246be8115432643197f91b6ae3000a2a08c0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:39:15 -1100 Subject: [PATCH 05/45] Declare --- src/cc/cclib.cpp | 5 +++++ src/secp256k1/src/ecmult.h | 2 +- src/secp256k1/src/scalar.h | 2 +- src/secp256k1/src/scalar_4x64_impl.h | 2 +- src/secp256k1/src/scalar_8x32_impl.h | 2 +- src/secp256k1/src/scalar_low_impl.h | 2 +- src/secp256k1/src/secp256k1.c | 4 ++-- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 496005016..da8829de6 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -608,6 +608,11 @@ struct secp256k1_context_struct { secp256k1_callback error_callback; }; +int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); +int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); + #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ secp256k1_callback_call(&ctx->illegal_callback, #cond); \ diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 4f12090a7..fbcf6a445 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -78,7 +78,7 @@ typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge * 0 if there is not enough scratch space for a single point or * callback returns 0 */ -static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #endif /* SECP256K1_ECMULT_H */ diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index 3213d302b..d83ccc22a 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -218,7 +218,7 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); /** Generate two scalars from a 32-byte seed and an integer using the chacha20 stream cipher */ -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); #endif /* SECP256K1_SCALAR_H */ #endif diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index b1b62ac1f..04f1da85d 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -1925,7 +1925,7 @@ c += d; b = ROTL32(b ^ c, 7); #define LE32(p) (p) #endif -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { size_t n; size_t over_count = 0; uint32_t seed32[8]; diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h index ff7bf5ee4..f1429b162 100644 --- a/src/secp256k1/src/scalar_8x32_impl.h +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -1471,7 +1471,7 @@ c += d; b = ROTL32(b ^ c, 7); #define LE32(p) (p) #endif -static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx) { size_t n; size_t over_count = 0; uint32_t seed32[8]; diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index c6c65ff5b..cc83eb8c7 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -230,7 +230,7 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const return *a == *b; } -SECP256K1_INLINE static void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { +SECP256K1_INLINE void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { *r1 = (seed[0] + n) % EXHAUSTIVE_TEST_ORDER; *r2 = (seed[1] + n) % EXHAUSTIVE_TEST_ORDER; } diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 657893d0d..1acb028d2 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. @@ -342,7 +342,7 @@ static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *m /* This nonce function is described in BIP-schnorr * (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki) */ -static int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { +int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { secp256k1_sha256 sha; (void) data; (void) counter; From 8ceea089ae28523f1cf1347adcf9c54893ca8aa4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:41:42 -1100 Subject: [PATCH 06/45] typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); --- src/cc/cclib.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index da8829de6..9f66e7022 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -608,6 +608,8 @@ struct secp256k1_context_struct { secp256k1_callback error_callback; }; +typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); + int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); From b81052aff00e17a4e659da9a4e8fd68812215fc1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:44:37 -1100 Subject: [PATCH 07/45] void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) --- src/cc/cclib.cpp | 2 +- src/secp256k1/src/ecmult_impl.h | 4 ++-- src/secp256k1/src/secp256k1.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 9f66e7022..1d7bedd82 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -609,7 +609,7 @@ struct secp256k1_context_struct { }; typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); - +void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 6c9a1daf2..6f2242d7c 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1497,7 +1497,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { /* Computes ecmult_multi by simply multiplying and adding each point. Does not * require a scratch space */ -static int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { + int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { size_t point_idx; secp256k1_scalar szero; secp256k1_gej tmpj; @@ -1522,7 +1522,7 @@ static int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); -static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { +int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 1acb028d2..2b219b589 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -134,7 +134,7 @@ int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const return 1; } -static void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { +void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { if (sizeof(secp256k1_ge_storage) == 64) { secp256k1_ge_storage s; secp256k1_ge_to_storage(&s, ge); From 82bacc85ff2d319c7fb8213e5e69796f5079f3c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:47:38 -1100 Subject: [PATCH 08/45] "C" --- src/cc/cclib.cpp | 2 +- src/secp256k1/src/secp256k1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 1d7bedd82..c63d03a38 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -611,7 +611,7 @@ struct secp256k1_context_struct { typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); -int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); +"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2b219b589..8be12059d 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. From da61c3f152361c5ba0b7f8a3684b59cc1be01c0d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:48:14 -1100 Subject: [PATCH 09/45] Extern "C" --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c63d03a38..7fb06259a 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -611,7 +611,7 @@ struct secp256k1_context_struct { typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); -"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); +extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); From bb264c86e12bc41f3688ae2a9b7f5fbda76ff42c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:49:07 -1100 Subject: [PATCH 10/45] "C" --- src/secp256k1/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 8be12059d..f39d373e3 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. From 85dfd9107105a311ce7a84cb28b7328fac6f5d19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:49:44 -1100 Subject: [PATCH 11/45] -"C" --- src/secp256k1/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index f39d373e3..2b219b589 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -115,7 +115,7 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co ctx->error_callback.data = data; } -"C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { +int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { if (sizeof(secp256k1_ge_storage) == 64) { /* When the secp256k1_ge_storage type is exactly 64 byte, use its * representation inside secp256k1_pubkey, as conversion is very fast. From 0e67be94c996dc2cdcfa6bbdd9374b59528aab1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 00:51:20 -1100 Subject: [PATCH 12/45] Extern "C" --- src/cc/cclib.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 7fb06259a..e6b405955 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -609,11 +609,11 @@ struct secp256k1_context_struct { }; typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); -void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); -int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); +extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); +extern "C" int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); -void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); -int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +extern "C" void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); +extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ From 991766db5f089befe038ff7b061d88c1c82af691 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:01:31 -1100 Subject: [PATCH 13/45] -ENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 2 +- src/secp256k1/src/secp256k1.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 089d3ee8e..7603cc626 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -73,7 +73,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DENABLE_MODULE_MUSIG -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) +libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2b219b589..4643ab903 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -601,8 +601,8 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif -#include "modules/schnorrsig/main_impl.h" -#include "modules/musig/main_impl.h" +//#include "modules/schnorrsig/main_impl.h" +//#include "modules/musig/main_impl.h" #ifdef ENABLE_MODULE_RECOVERY From db9f81504bca3e1f50f76e06fe0c9e3909c3e5cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:02:56 -1100 Subject: [PATCH 14/45] Revert --- src/secp256k1/src/secp256k1.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4643ab903..065ce72d4 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -17,7 +17,6 @@ #include "ecdsa_impl.h" #include "eckey_impl.h" #include "hash_impl.h" -#include "scratch_impl.h" #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ @@ -601,9 +600,6 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif -//#include "modules/schnorrsig/main_impl.h" -//#include "modules/musig/main_impl.h" - #ifdef ENABLE_MODULE_RECOVERY # include "modules/recovery/main_impl.h" From 340c8ba1ca2e30a7b182f282ff005264d020b3f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:04:53 -1100 Subject: [PATCH 15/45] -SCALAR_INLINE --- src/secp256k1/src/scalar_low_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index cc83eb8c7..956cccd04 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -230,7 +230,7 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const return *a == *b; } -SECP256K1_INLINE void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { +void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t n) { *r1 = (seed[0] + n) % EXHAUSTIVE_TEST_ORDER; *r2 = (seed[1] + n) % EXHAUSTIVE_TEST_ORDER; } From 1d47bd1cc7167d03c59b18b68453e69d8e03670b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:08:23 -1100 Subject: [PATCH 16/45] Pippenger --- src/secp256k1/src/ecmult_impl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 6f2242d7c..88a9cfae2 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1154,6 +1154,8 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { return skew; } +#endif /* SECP256K1_ECMULT_IMPL_H */ + struct secp256k1_pippenger_point_state { int skew_na; size_t input_pos; @@ -1497,7 +1499,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { /* Computes ecmult_multi by simply multiplying and adding each point. Does not * require a scratch space */ - int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { +int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { size_t point_idx; secp256k1_scalar szero; secp256k1_gej tmpj; @@ -1522,6 +1524,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); + int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; @@ -1576,7 +1579,5 @@ int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_sc return 1; } -#endif /* SECP256K1_ECMULT_IMPL_H */ - #endif From 0caedf0c8c60ea9536cc15c39bc4967bfec2c463 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:09:43 -1100 Subject: [PATCH 17/45] Move endif --- src/secp256k1/src/ecmult_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 88a9cfae2..48d8af8f4 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1155,6 +1155,8 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { } #endif /* SECP256K1_ECMULT_IMPL_H */ +#endif + struct secp256k1_pippenger_point_state { int skew_na; @@ -1579,5 +1581,4 @@ int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_sc return 1; } -#endif From 22e3b0b00ddebfdd56e97d378904a181829fb858 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:12:00 -1100 Subject: [PATCH 18/45] scratch.h --- src/secp256k1/src/ecmult_impl.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 48d8af8f4..c0d21f4ba 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1157,6 +1157,20 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { #endif /* SECP256K1_ECMULT_IMPL_H */ #endif +#include "../scratch.h" + +/* The number of objects allocated on the scratch space for ecmult_multi algorithms */ +#define PIPPENGER_SCRATCH_OBJECTS 6 +#define STRAUSS_SCRATCH_OBJECTS 6 + +#define PIPPENGER_MAX_BUCKET_WINDOW 12 + +/* Minimum number of points for which pippenger_wnaf is faster than strauss wnaf */ +#ifdef USE_ENDOMORPHISM +#define ECMULT_PIPPENGER_THRESHOLD 88 +#else +#define ECMULT_PIPPENGER_THRESHOLD 160 +#endif struct secp256k1_pippenger_point_state { int skew_na; From 061dde468e52ca35a5307c37b19942871dadd89c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:14:59 -1100 Subject: [PATCH 19/45] -.. --- src/secp256k1/src/ecmult_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index c0d21f4ba..2a0fac4e7 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1157,7 +1157,7 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { #endif /* SECP256K1_ECMULT_IMPL_H */ #endif -#include "../scratch.h" +#include "scratch.h" /* The number of objects allocated on the scratch space for ecmult_multi algorithms */ #define PIPPENGER_SCRATCH_OBJECTS 6 From f04c2097fb47546e6bdd3ccb10fae9d650f757b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:21:14 -1100 Subject: [PATCH 20/45] Test --- src/secp256k1/src/ecmult_impl.h | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 2a0fac4e7..bc596608e 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,4 +1,4 @@ -#ifndef ENABLE_MODULE_MUSIG +#ifdef always_do_ENABLE_MODULE_MUSIG /********************************************************************** @@ -1154,24 +1154,6 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) { return skew; } -#endif /* SECP256K1_ECMULT_IMPL_H */ -#endif - -#include "scratch.h" - -/* The number of objects allocated on the scratch space for ecmult_multi algorithms */ -#define PIPPENGER_SCRATCH_OBJECTS 6 -#define STRAUSS_SCRATCH_OBJECTS 6 - -#define PIPPENGER_MAX_BUCKET_WINDOW 12 - -/* Minimum number of points for which pippenger_wnaf is faster than strauss wnaf */ -#ifdef USE_ENDOMORPHISM -#define ECMULT_PIPPENGER_THRESHOLD 88 -#else -#define ECMULT_PIPPENGER_THRESHOLD 160 -#endif - struct secp256k1_pippenger_point_state { int skew_na; size_t input_pos; @@ -1515,7 +1497,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { /* Computes ecmult_multi by simply multiplying and adding each point. Does not * require a scratch space */ -int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { + int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) { size_t point_idx; secp256k1_scalar szero; secp256k1_gej tmpj; @@ -1540,7 +1522,6 @@ int secp256k1_ecmult_multi_var_simple(const secp256k1_ecmult_context *ctx, secp2 } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); - int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; @@ -1595,4 +1576,7 @@ int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_sc return 1; } +#endif /* SECP256K1_ECMULT_IMPL_H */ + +#endif From 75ffdd2e91b5779152c8a6eee1672ca9c29f62a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:25:39 -1100 Subject: [PATCH 21/45] -DENABLE_MODULE_MUSIG --- src/secp256k1/Makefile.am | 2 +- src/secp256k1/src/ecmult.h | 1 - src/secp256k1/src/ecmult_impl.h | 2 +- src/secp256k1/src/secp256k1.c | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am index 7603cc626..c5fa00fc5 100644 --- a/src/secp256k1/Makefile.am +++ b/src/secp256k1/Makefile.am @@ -73,7 +73,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) +libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -DENABLE_MODULE_MUSIG -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index fbcf6a445..88475791b 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -45,7 +45,6 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej #include "num.h" #include "group.h" #include "scalar.h" -#include "scratch.h" typedef struct { /* For accelerating the computation of a*P + b*G: */ diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index bc596608e..116a9f154 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,4 +1,4 @@ -#ifdef always_do_ENABLE_MODULE_MUSIG +#ifdef ENABLE_MODULE_MUSIG /********************************************************************** diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 065ce72d4..4225607ff 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -17,6 +17,7 @@ #include "ecdsa_impl.h" #include "eckey_impl.h" #include "hash_impl.h" +#include "scratch_impl.h" #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ From 5ee30cdd96d7fe085401b4b2bf7cc41c650f85e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:30:47 -1100 Subject: [PATCH 22/45] scratch.h --- src/secp256k1/src/ecmult.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 88475791b..fbcf6a445 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -45,6 +45,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej #include "num.h" #include "group.h" #include "scalar.h" +#include "scratch.h" typedef struct { /* For accelerating the computation of a*P + b*G: */ From 57ef97ca58085e6d5204860e8a3763020da71219 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:38:49 -1100 Subject: [PATCH 23/45] #include "util.h" --- src/secp256k1/src/secp256k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4225607ff..2f482803a 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -6,13 +6,13 @@ #include "../include/secp256k1.h" -#include "util.h" #include "num_impl.h" #include "field_impl.h" #include "scalar_impl.h" #include "group_impl.h" #include "ecmult_impl.h" #include "ecmult_const_impl.h" +#include "util.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" From 0a460a527382e5d59813d389bbc034df2ed7c07e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:41:57 -1100 Subject: [PATCH 24/45] Header order --- src/secp256k1/src/secp256k1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 2f482803a..e6af45df7 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -6,13 +6,13 @@ #include "../include/secp256k1.h" +#include "ecmult_impl.h" +#include "ecmult_const_impl.h" +#include "util.h" #include "num_impl.h" #include "field_impl.h" #include "scalar_impl.h" #include "group_impl.h" -#include "ecmult_impl.h" -#include "ecmult_const_impl.h" -#include "util.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" From d7e8e8d4b35c7dce5af8a60a5506515fdfe8e835 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:44:15 -1100 Subject: [PATCH 25/45] Fx --- src/cc/cclib.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e6b405955..e570be7d1 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,13 +588,14 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" + +#include "../secp256k1/src/ecmult_impl.h" +#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" #include "../secp256k1/src/group_impl.h" -#include "../secp256k1/src/ecmult_impl.h" -#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" From 99bf645bf19752c76f813a4164b3dbdcd8d01f73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:50:25 -1100 Subject: [PATCH 26/45] Revert --- src/cc/cclib.cpp | 5 ++--- src/secp256k1/src/secp256k1.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e570be7d1..e6b405955 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,14 +588,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" - -#include "../secp256k1/src/ecmult_impl.h" -#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" #include "../secp256k1/src/group_impl.h" +#include "../secp256k1/src/ecmult_impl.h" +#include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index e6af45df7..4225607ff 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -6,13 +6,13 @@ #include "../include/secp256k1.h" -#include "ecmult_impl.h" -#include "ecmult_const_impl.h" #include "util.h" #include "num_impl.h" #include "field_impl.h" #include "scalar_impl.h" #include "group_impl.h" +#include "ecmult_impl.h" +#include "ecmult_const_impl.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" From ba4917acf45ec4943a2dcec065596446a6f581af Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:55:28 -1100 Subject: [PATCH 27/45] WNAF_SIZE --- src/secp256k1/src/ecmult_const_impl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index d8697e0e9..410c4a6b6 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -14,12 +14,20 @@ #include "ecmult_const.h" #include "ecmult_impl.h" +#ifdef USE_ENDOMORPHISM +#define WNAF_BITS 128 +#else +#define WNAF_BITS 256 +#endif +#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) +#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) + #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else #define WNAF_BITS 256 #endif -#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) +//#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ From 4fab71d374a4c64bfe1214b3e9c688e6e4f95748 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 01:59:32 -1100 Subject: [PATCH 28/45] Define WNAF BITS --- src/secp256k1/src/ecmult_const_impl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index 410c4a6b6..d2eaa2368 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -14,6 +14,7 @@ #include "ecmult_const.h" #include "ecmult_impl.h" + #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else @@ -22,12 +23,13 @@ #define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) #define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) +/* #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else #define WNAF_BITS 256 #endif -//#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) +#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w))*/ /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ From 15fb6f16954f9c9a6b77330ac0ae641b4aa98343 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:03:12 -1100 Subject: [PATCH 29/45] ... --- src/secp256k1/src/ecmult_const_impl.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index d2eaa2368..28636290d 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -15,21 +15,12 @@ #include "ecmult_impl.h" -#ifdef USE_ENDOMORPHISM -#define WNAF_BITS 128 -#else -#define WNAF_BITS 256 -#endif -#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) -#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) - -/* #ifdef USE_ENDOMORPHISM #define WNAF_BITS 128 #else #define WNAF_BITS 256 #endif -#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w))*/ +#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ @@ -266,6 +257,14 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons #include "ecmult_const.h" #include "ecmult_impl.h" +#ifdef USE_ENDOMORPHISM +#define WNAF_BITS 128 +#else +#define WNAF_BITS 256 +#endif +#define WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) +#define WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) + /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ int m; \ From 1b9cfb04a9a4dab9d8405ee90617e7c498bfd68a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:08:02 -1100 Subject: [PATCH 30/45] Scratch --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e6b405955..4019bf422 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -600,6 +600,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/eckey_impl.h" #include "../secp256k1/src/hash_impl.h" #include "../secp256k1/src/scratch_impl.h" +#include "../secp256k1/src/scratch.h" struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; From 1b099fca7157e64ccd27bccbb359626d78f749bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:09:33 -1100 Subject: [PATCH 31/45] Reorder --- src/cc/cclib.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 4019bf422..9a2f9c3ab 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -593,14 +593,13 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" #include "../secp256k1/src/group_impl.h" +#include "../secp256k1/src/scratch_impl.h" #include "../secp256k1/src/ecmult_impl.h" #include "../secp256k1/src/ecmult_const_impl.h" #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" #include "../secp256k1/src/hash_impl.h" -#include "../secp256k1/src/scratch_impl.h" -#include "../secp256k1/src/scratch.h" struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; From 8c96abe167f9d9166a5eade2b16652dfdf1b4978 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:11:39 -1100 Subject: [PATCH 32/45] Enable --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 9a2f9c3ab..b02456b33 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -585,6 +585,7 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" #define USE_BASIC_CONFIG +#define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" From a244fe9cdc8abaaa2e510ecc8146ceb11229c890 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:14:20 -1100 Subject: [PATCH 33/45] removes --- src/cc/cclib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index b02456b33..4fc753b8c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -589,7 +589,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/src/util.h" +/*#include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" @@ -600,7 +600,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" -#include "../secp256k1/src/hash_impl.h" +#include "../secp256k1/src/hash_impl.h"*/ struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; From c95287714595b64b419d4af5c8e2ad31f9b9ee0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:16:57 -1100 Subject: [PATCH 34/45] Revert --- src/cc/cclib.cpp | 6 ++---- src/secp256k1/src/secp256k1.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 4fc753b8c..3c0baf856 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -600,14 +600,14 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/ecmult_gen_impl.h" #include "../secp256k1/src/ecdsa_impl.h" #include "../secp256k1/src/eckey_impl.h" -#include "../secp256k1/src/hash_impl.h"*/ +#include "../secp256k1/src/hash_impl.h" struct secp256k1_context_struct { secp256k1_ecmult_context ecmult_ctx; secp256k1_ecmult_gen_context ecmult_gen_ctx; secp256k1_callback illegal_callback; secp256k1_callback error_callback; -}; +};*/ typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); @@ -624,8 +624,6 @@ return 0; \ } while(0) //#include "../secp256k1/src/secp256k1.c" -#include "../secp256k1/src/modules/schnorrsig/main_impl.h" -#include "../secp256k1/src/modules/musig/main_impl.h" #include "musig.cpp" #endif diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 4225607ff..7861a5f79 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -601,6 +601,8 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * # include "modules/ecdh/main_impl.h" #endif +#include "../secp256k1/src/modules/schnorrsig/main_impl.h" +#include "../secp256k1/src/modules/musig/main_impl.h" #ifdef ENABLE_MODULE_RECOVERY # include "modules/recovery/main_impl.h" From ecdd65b56690b0471b783c53ccf18ed1f9cf7980 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:20:11 -1100 Subject: [PATCH 35/45] xx --- src/cc/cclib.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 3c0baf856..f7df312e7 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,12 +584,12 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -#define USE_BASIC_CONFIG +/*#define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" -/*#include "../secp256k1/src/util.h" +#include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" #include "../secp256k1/src/scalar_impl.h" @@ -607,7 +607,7 @@ struct secp256k1_context_struct { secp256k1_ecmult_gen_context ecmult_gen_ctx; secp256k1_callback illegal_callback; secp256k1_callback error_callback; -};*/ +}; typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); @@ -621,7 +621,7 @@ if (EXPECT(!(cond), 0)) { \ secp256k1_callback_call(&ctx->illegal_callback, #cond); \ return 0; \ } \ -} while(0) +} while(0)*/ //#include "../secp256k1/src/secp256k1.c" From 4c934237feb82112ee9a0bd0d721e8034d15ef1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:25:31 -1100 Subject: [PATCH 36/45] Almost --- src/cc/cclib.cpp | 4 +++- src/cc/musig.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f7df312e7..a83107234 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -614,7 +614,6 @@ extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge extern "C" int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter); extern "C" int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey); extern "C" void secp256k1_scalar_chacha20(secp256k1_scalar *r1, secp256k1_scalar *r2, const unsigned char *seed, uint64_t idx); -extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #define ARG_CHECK(cond) do { \ if (EXPECT(!(cond), 0)) { \ @@ -624,6 +623,9 @@ return 0; \ } while(0)*/ //#include "../secp256k1/src/secp256k1.c" +extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); +extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); +extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); #include "musig.cpp" #endif diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 5d56635aa..520234da1 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -15,9 +15,11 @@ #include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/include/secp256k1_schnorrsig.h" +//#include "../secp256k1/include/secp256k1_schnorrsig.h" #include "../secp256k1/include/secp256k1_musig.h" +typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; + #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 From d17ef9b3e264e7bac9cccc4d27de3b19ae7fc40d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:28:36 -1100 Subject: [PATCH 37/45] ees --- src/cc/cclib.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index a83107234..484be6191 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,10 +584,11 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" +#include "../secp256k1/include/secp256k1.h" +#include "../secp256k1/src/ecmult.h" /*#define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" -#include "../secp256k1/include/secp256k1.h" #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" @@ -602,12 +603,7 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/eckey_impl.h" #include "../secp256k1/src/hash_impl.h" -struct secp256k1_context_struct { - secp256k1_ecmult_context ecmult_ctx; - secp256k1_ecmult_gen_context ecmult_gen_ctx; - secp256k1_callback illegal_callback; - secp256k1_callback error_callback; -}; + typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); extern "C" void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge); @@ -623,6 +619,12 @@ return 0; \ } while(0)*/ //#include "../secp256k1/src/secp256k1.c" +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); From 7833fc5f4b1af8d19a49edb8dfd396da3ff2c995 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:29:47 -1100 Subject: [PATCH 38/45] Sss --- src/cc/cclib.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 484be6191..35a6362ec 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -584,12 +584,12 @@ uint256 juint256(cJSON *obj) #else #include "sudoku.cpp" -#include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/src/ecmult.h" -/*#define USE_BASIC_CONFIG +#define USE_BASIC_CONFIG #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" +#include "../secp256k1/include/secp256k1.h" +/* #include "../secp256k1/src/util.h" #include "../secp256k1/src/num_impl.h" #include "../secp256k1/src/field_impl.h" From 7573d3f815cca5c5d08e9e8a56c9a9b3f41c6c93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:31:15 -1100 Subject: [PATCH 39/45] Tes --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 35a6362ec..5681a380f 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,6 +588,7 @@ uint256 juint256(cJSON *obj) #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" +#include "../secp256k1/include/ecmult.h" /* #include "../secp256k1/src/util.h" From aec159bdc0bcbceb80f2ccb4d4e3bc479854cb2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:31:47 -1100 Subject: [PATCH 40/45] Src --- src/cc/cclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 5681a380f..8a96a81bf 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -588,7 +588,7 @@ uint256 juint256(cJSON *obj) #define ENABLE_MODULE_MUSIG #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" -#include "../secp256k1/include/ecmult.h" +#include "../secp256k1/src/ecmult.h" /* #include "../secp256k1/src/util.h" From 3106e5f0a83784a4dff7128920acfc2f44eba786 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:33:11 -1100 Subject: [PATCH 41/45] typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; --- src/cc/cclib.cpp | 3 +++ src/cc/musig.cpp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8a96a81bf..76d1dfa39 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -589,6 +589,9 @@ uint256 juint256(cJSON *obj) #include "../secp256k1/src/basic-config.h" #include "../secp256k1/include/secp256k1.h" #include "../secp256k1/src/ecmult.h" +#include "../secp256k1/src/ecmult_gen.h" + +typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; /* #include "../secp256k1/src/util.h" diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 520234da1..318cb7664 100755 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -18,7 +18,6 @@ //#include "../secp256k1/include/secp256k1_schnorrsig.h" #include "../secp256k1/include/secp256k1_musig.h" -typedef struct { unsigned char data[64]; } secp256k1_schnorrsig; #define MUSIG_PREVN 0 // for now, just use vout0 for the musig output #define MUSIG_TXFEE 10000 From 51ae3da5ec6a575c8d7b003f62e72af65a03949a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:38:45 -1100 Subject: [PATCH 42/45] #ifdef __cplusplus --- src/secp256k1/src/ecmult.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index fbcf6a445..3ed2e435a 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -78,6 +78,10 @@ typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge * 0 if there is not enough scratch space for a single point or * callback returns 0 */ + +#ifdef __cplusplus +extern "C" +#endif int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #endif /* SECP256K1_ECMULT_H */ From 4da533ffc5cb53f0ea28010601e09ec8effc46c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:42:25 -1100 Subject: [PATCH 43/45] Test --- src/cc/cclib.cpp | 1 + src/secp256k1/src/ecmult_impl.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 76d1dfa39..5d321bdae 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -629,6 +629,7 @@ struct secp256k1_context_struct { secp256k1_callback illegal_callback; secp256k1_callback error_callback; }; + extern "C" int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); extern "C" int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const secp256k1_schnorrsig *sig, const unsigned char *msg32, const secp256k1_pubkey *pk); extern "C" int secp256k1_schnorrsig_parse(const secp256k1_context* ctx, secp256k1_schnorrsig* sig, const unsigned char *in64); diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 116a9f154..6fd705ef4 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1522,6 +1522,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) { } typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t); + int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; From b09b0261aca1812eef070b5046aad2b4cbefebf7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:45:02 -1100 Subject: [PATCH 44/45] Test --- src/secp256k1/src/ecmult_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index 6fd705ef4..bea64ebcd 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1525,7 +1525,7 @@ typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; - + xxx int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); size_t max_points; size_t n_batches; From c44e7ae038a9b462b83f69dbb2f31d9fe1b5e97d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Feb 2019 02:48:05 -1100 Subject: [PATCH 45/45] Fix --- src/secp256k1/src/ecmult_impl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index bea64ebcd..b761304cf 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -1,4 +1,4 @@ -#ifdef ENABLE_MODULE_MUSIG +#ifndef ENABLE_MODULE_MUSIG /********************************************************************** @@ -1525,7 +1525,6 @@ typedef int (*secp256k1_ecmult_multi_func)(const secp256k1_ecmult_context*, secp int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) { size_t i; - xxx int (*f)(const secp256k1_ecmult_context*, secp256k1_scratch*, secp256k1_gej*, const secp256k1_scalar*, secp256k1_ecmult_multi_callback cb, void*, size_t, size_t); size_t max_points; size_t n_batches;