Merge bitcoin-core/secp256k1#963: "Schnorrsig API overhaul" fixups
90e83449b2ci: Add C++ test (Tim Ruffing)f698caaff6Use unsigned char consistently for byte arrays (Tim Ruffing)b5b8e7b719Don't declare constants twice (Tim Ruffing)769528f307Don't use string literals for char arrays without NUL termination (Tim Ruffing)2cc3cfa583Fix -Wmissing-braces warning in clang (Tim Ruffing) Pull request description: ACKs for top commit: jonasnick: ACK90e83449b2Tree-SHA512: c26ba3db7514399c502f6c5c6f6ce6703459d83d831765042e331b051aeee282641197c3ae881c614f51ca714a818c5528410d288aadbd3e92361c1e9c129afe
This commit is contained in:
20
.cirrus.yml
20
.cirrus.yml
@@ -320,3 +320,23 @@ task:
|
|||||||
- ./ci/cirrus.sh
|
- ./ci/cirrus.sh
|
||||||
<< : *CAT_LOGS
|
<< : *CAT_LOGS
|
||||||
|
|
||||||
|
task:
|
||||||
|
name: "C++ -fpermissive"
|
||||||
|
container:
|
||||||
|
dockerfile: ci/linux-debian.Dockerfile
|
||||||
|
cpu: 1
|
||||||
|
memory: 1G
|
||||||
|
env:
|
||||||
|
# ./configure correctly errors out when given CC=g++.
|
||||||
|
# We hack around this by passing CC=g++ only to make.
|
||||||
|
CC: gcc
|
||||||
|
MAKEFLAGS: -j2 CC=g++ CFLAGS=-fpermissive
|
||||||
|
WERROR_CFLAGS:
|
||||||
|
EXPERIMENTAL: yes
|
||||||
|
ECDH: yes
|
||||||
|
RECOVERY: yes
|
||||||
|
SCHNORRSIG: yes
|
||||||
|
<< : *MERGE_BASE
|
||||||
|
test_script:
|
||||||
|
- ./ci/cirrus.sh
|
||||||
|
<< : *CAT_LOGS
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \
|
|||||||
git ca-certificates \
|
git ca-certificates \
|
||||||
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
|
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
|
||||||
gcc clang llvm libc6-dbg \
|
gcc clang llvm libc6-dbg \
|
||||||
|
g++ \
|
||||||
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan5:i386 \
|
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan5:i386 \
|
||||||
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x \
|
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x \
|
||||||
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
|
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ typedef struct {
|
|||||||
void* ndata;
|
void* ndata;
|
||||||
} secp256k1_schnorrsig_extraparams;
|
} secp256k1_schnorrsig_extraparams;
|
||||||
|
|
||||||
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC "\xda\x6f\xb3\x8c"
|
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC { 0xda, 0x6f, 0xb3, 0x8c }
|
||||||
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT {\
|
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT {\
|
||||||
SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC,\
|
SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC,\
|
||||||
NULL,\
|
NULL,\
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ typedef struct {
|
|||||||
secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */
|
secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */
|
||||||
} secp256k1_ecmult_context;
|
} secp256k1_ecmult_context;
|
||||||
|
|
||||||
static const size_t SECP256K1_ECMULT_CONTEXT_PREALLOCATED_SIZE;
|
|
||||||
static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx);
|
static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx);
|
||||||
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void **prealloc);
|
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void **prealloc);
|
||||||
static void secp256k1_ecmult_context_finalize_memcpy(secp256k1_ecmult_context *dst, const secp256k1_ecmult_context *src);
|
static void secp256k1_ecmult_context_finalize_memcpy(secp256k1_ecmult_context *dst, const secp256k1_ecmult_context *src);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ typedef struct {
|
|||||||
secp256k1_gej initial;
|
secp256k1_gej initial;
|
||||||
} secp256k1_ecmult_gen_context;
|
} secp256k1_ecmult_gen_context;
|
||||||
|
|
||||||
static const size_t SECP256K1_ECMULT_GEN_CONTEXT_PREALLOCATED_SIZE;
|
|
||||||
static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx);
|
static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx);
|
||||||
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, void **prealloc);
|
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, void **prealloc);
|
||||||
static void secp256k1_ecmult_gen_context_finalize_memcpy(secp256k1_ecmult_gen_context *dst, const secp256k1_ecmult_gen_context* src);
|
static void secp256k1_ecmult_gen_context_finalize_memcpy(secp256k1_ecmult_gen_context *dst, const secp256k1_ecmult_gen_context* src);
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ static void secp256k1_nonce_function_bip340_sha256_tagged_aux(secp256k1_sha256 *
|
|||||||
* by using the correct tagged hash function. */
|
* by using the correct tagged hash function. */
|
||||||
static const unsigned char bip340_algo[13] = "BIP0340/nonce";
|
static const unsigned char bip340_algo[13] = "BIP0340/nonce";
|
||||||
|
|
||||||
|
static const unsigned char schnorrsig_extraparams_magic[4] = SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC;
|
||||||
|
|
||||||
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) {
|
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) {
|
||||||
secp256k1_sha256 sha;
|
secp256k1_sha256 sha;
|
||||||
unsigned char masked_key[32];
|
unsigned char masked_key[32];
|
||||||
@@ -194,7 +196,7 @@ int secp256k1_schnorrsig_sign_custom(const secp256k1_context* ctx, unsigned char
|
|||||||
|
|
||||||
if (extraparams != NULL) {
|
if (extraparams != NULL) {
|
||||||
ARG_CHECK(secp256k1_memcmp_var(extraparams->magic,
|
ARG_CHECK(secp256k1_memcmp_var(extraparams->magic,
|
||||||
SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC,
|
schnorrsig_extraparams_magic,
|
||||||
sizeof(extraparams->magic)) == 0);
|
sizeof(extraparams->magic)) == 0);
|
||||||
noncefp = extraparams->noncefp;
|
noncefp = extraparams->noncefp;
|
||||||
ndata = extraparams->ndata;
|
ndata = extraparams->ndata;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void test_schnorrsig_api(void) {
|
|||||||
secp256k1_xonly_pubkey zero_pk;
|
secp256k1_xonly_pubkey zero_pk;
|
||||||
unsigned char sig[64];
|
unsigned char sig[64];
|
||||||
secp256k1_schnorrsig_extraparams extraparams = SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT;
|
secp256k1_schnorrsig_extraparams extraparams = SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT;
|
||||||
secp256k1_schnorrsig_extraparams invalid_extraparams = { 0 };
|
secp256k1_schnorrsig_extraparams invalid_extraparams = {{ 0 }, NULL, NULL};
|
||||||
|
|
||||||
/** setup **/
|
/** setup **/
|
||||||
secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
|
secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
|
||||||
@@ -219,7 +219,7 @@ void test_schnorrsig_api(void) {
|
|||||||
/* Checks that hash initialized by secp256k1_schnorrsig_sha256_tagged has the
|
/* Checks that hash initialized by secp256k1_schnorrsig_sha256_tagged has the
|
||||||
* expected state. */
|
* expected state. */
|
||||||
void test_schnorrsig_sha256_tagged(void) {
|
void test_schnorrsig_sha256_tagged(void) {
|
||||||
char tag[17] = "BIP0340/challenge";
|
unsigned char tag[17] = "BIP0340/challenge";
|
||||||
secp256k1_sha256 sha;
|
secp256k1_sha256 sha;
|
||||||
secp256k1_sha256 sha_optimized;
|
secp256k1_sha256 sha_optimized;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user