Skip to content

Commit 79b2e67

Browse files
committed
[secp256k1] Backport "'Schnorrsig API overhaul' fixups"
Summary: Bitcoin Core added some later fixups, which make sense to be backported after we added D16958. This is a backport of [[bitcoin-core/secp256k1#963 | secp256k1#963]]. Test Plan: `ninja check-secp256k1` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D16968
1 parent a34a9e5 commit 79b2e67

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

src/secp256k1/.cirrus.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,24 @@ task:
190190
- ./ci/build_autotools.sh
191191
- ./ci/build_cmake.sh
192192
<< : *CAT_LOGS
193+
194+
task:
195+
name: "C++ -fpermissive"
196+
container:
197+
dockerfile: ci/linux-debian.Dockerfile
198+
cpu: 1
199+
memory: 1G
200+
env:
201+
# ./configure correctly errors out when given CC=g++.
202+
# We hack around this by passing CC=g++ only to make.
203+
CC: gcc
204+
MAKEFLAGS: -j2 CC=g++ CFLAGS=-fpermissive
205+
WERROR_CFLAGS:
206+
EXPERIMENTAL: yes
207+
ECDH: yes
208+
RECOVERY: yes
209+
SCHNORRSIG: yes
210+
<< : *MERGE_BASE
211+
test_script:
212+
- ./ci/cirrus.sh
213+
<< : *CAT_LOGS

src/secp256k1/ci/linux-debian.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ RUN apt-get update
99
RUN apt-get install --no-install-recommends --no-upgrade -y \
1010
automake cmake default-jdk dpkg-dev libssl-dev libtool make ninja-build pkg-config python3 qemu-user valgrind \
1111
gcc clang llvm libc6-dbg \
12+
g++ \
1213
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan6:i386 \
1314
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x

src/secp256k1/include/secp256k1_schnorrsig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef struct {
8585
void* ndata;
8686
} secp256k1_schnorrsig_extraparams;
8787

88-
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC "\xda\x6f\xb3\x8c"
88+
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC { 0xda, 0x6f, 0xb3, 0x8c }
8989
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT {\
9090
SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC,\
9191
NULL,\

src/secp256k1/src/ecmult.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ typedef struct {
1717
secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */
1818
} secp256k1_ecmult_context;
1919

20-
static const size_t SECP256K1_ECMULT_CONTEXT_PREALLOCATED_SIZE;
2120
static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx);
2221
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void **prealloc);
2322
static void secp256k1_ecmult_context_finalize_memcpy(secp256k1_ecmult_context *dst, const secp256k1_ecmult_context *src);

src/secp256k1/src/ecmult_gen.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ typedef struct {
3535
secp256k1_gej initial;
3636
} secp256k1_ecmult_gen_context;
3737

38-
static const size_t SECP256K1_ECMULT_GEN_CONTEXT_PREALLOCATED_SIZE;
3938
static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx);
4039
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, void **prealloc);
4140
static void secp256k1_ecmult_gen_context_finalize_memcpy(secp256k1_ecmult_gen_context *dst, const secp256k1_ecmult_gen_context* src);

src/secp256k1/src/modules/schnorrsig/main_impl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ static void secp256k1_nonce_function_bip340_sha256_tagged_aux(secp256k1_sha256 *
4747
* by using the correct tagged hash function. */
4848
static const unsigned char bip340_algo[13] = "BIP0340/nonce";
4949

50+
static const unsigned char schnorrsig_extraparams_magic[4] = SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC;
51+
5052
static int nonce_function_bip340(unsigned char *nonce32, const unsigned char *msg, size_t msglen, const unsigned char *key32, const unsigned char *xonly_pk32, const unsigned char *algo, size_t algolen, void *data) {
5153
secp256k1_sha256 sha;
5254
unsigned char masked_key[32];
@@ -194,7 +196,7 @@ int secp256k1_schnorrsig_sign_custom(const secp256k1_context* ctx, unsigned char
194196

195197
if (extraparams != NULL) {
196198
ARG_CHECK(secp256k1_memcmp_var(extraparams->magic,
197-
SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC,
199+
schnorrsig_extraparams_magic,
198200
sizeof(extraparams->magic)) == 0);
199201
noncefp = extraparams->noncefp;
200202
ndata = extraparams->ndata;

src/secp256k1/src/modules/schnorrsig/tests_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void test_schnorrsig_api(void) {
122122
secp256k1_xonly_pubkey zero_pk;
123123
unsigned char sig[64];
124124
secp256k1_schnorrsig_extraparams extraparams = SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT;
125-
secp256k1_schnorrsig_extraparams invalid_extraparams = { 0 };
125+
secp256k1_schnorrsig_extraparams invalid_extraparams = {{ 0 }, NULL, NULL};
126126

127127
/** setup **/
128128
secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
@@ -219,7 +219,7 @@ void test_schnorrsig_api(void) {
219219
/* Checks that hash initialized by secp256k1_schnorrsig_sha256_tagged has the
220220
* expected state. */
221221
void test_schnorrsig_sha256_tagged(void) {
222-
char tag[17] = "BIP0340/challenge";
222+
unsigned char tag[17] = "BIP0340/challenge";
223223
secp256k1_sha256 sha;
224224
secp256k1_sha256 sha_optimized;
225225

0 commit comments

Comments
 (0)