Skip to content

Commit 7688a4f

Browse files
committed
Merge #963: "Schnorrsig API overhaul" fixups
90e8344 ci: Add C++ test (Tim Ruffing) f698caa Use unsigned char consistently for byte arrays (Tim Ruffing) b5b8e7b Don't declare constants twice (Tim Ruffing) 769528f Don't use string literals for char arrays without NUL termination (Tim Ruffing) 2cc3cfa Fix -Wmissing-braces warning in clang (Tim Ruffing) Pull request description: ACKs for top commit: jonasnick: ACK 90e8344 Tree-SHA512: c26ba3db7514399c502f6c5c6f6ce6703459d83d831765042e331b051aeee282641197c3ae881c614f51ca714a818c5528410d288aadbd3e92361c1e9c129afe
2 parents 0440945 + 90e8344 commit 7688a4f

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

.cirrus.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,23 @@ task:
320320
- ./ci/cirrus.sh
321321
<< : *CAT_LOGS
322322

323+
task:
324+
name: "C++ -fpermissive"
325+
container:
326+
dockerfile: ci/linux-debian.Dockerfile
327+
cpu: 1
328+
memory: 1G
329+
env:
330+
# ./configure correctly errors out when given CC=g++.
331+
# We hack around this by passing CC=g++ only to make.
332+
CC: gcc
333+
MAKEFLAGS: -j2 CC=g++ CFLAGS=-fpermissive
334+
WERROR_CFLAGS:
335+
EXPERIMENTAL: yes
336+
ECDH: yes
337+
RECOVERY: yes
338+
SCHNORRSIG: yes
339+
<< : *MERGE_BASE
340+
test_script:
341+
- ./ci/cirrus.sh
342+
<< : *CAT_LOGS

ci/linux-debian.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \
1313
git ca-certificates \
1414
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
1515
gcc clang llvm libc6-dbg \
16+
g++ \
1617
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan5:i386 \
1718
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x \
1819
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \

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/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/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/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/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)