Skip to content

Commit 1e32413

Browse files
committed
Squashed 'src/secp256k1/' changes from ee99f12..763484a1e5
763484a1e5 f fix undefined behavior when shifting an int 31 places 5af66e7f79 f expose nonce_function_bipschnorr 594e3abb69 f hash noncedata into nonce in nonce_function_bipschnorr 318d55155c f make helper functions static d65adc82f8 Add schnorrsig module which implements BIP-schnorr [0] compatible signing, verification and batch verification. f4153a29ab add chacha20 function REVERT: ee99f12 Merge bitcoin#599: Switch x86_64 asm to use "i" instead of "n" for immediate values. REVERT: d58bc93 Switch x86_64 asm to use "i" instead of "n" for immediate values. REVERT: 05362ee Merge bitcoin#597: Add $(COMMON_LIB) to exhaustive tests to fix ARM asm build REVERT: 8348386 Add $(COMMON_LIB) to exhaustive tests to fix ARM asm build REVERT: aa15154 Merge bitcoin#568: Fix integer overflow in ecmult_multi_var when n is large REVERT: 2277af5 Fix integer overflow in ecmult_multi_var when n is large REVERT: 85d0e1b Merge bitcoin#591: Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing. REVERT: 1419637 Merge bitcoin#580: Add trivial ecmult_multi algorithm which does not require a scratch space REVERT: a697d82 Add trivial ecmult_multi to the benchmark tool REVERT: bade617 Add trivial ecmult_multi algorithm. It is selected when no scratch space is given and just multiplies and adds the points. REVERT: 5545e13 Merge bitcoin#584: configure: Use CFLAGS_FOR_BUILD when checking native compiler REVERT: 20c5869 Merge bitcoin#516: improvements to random seed in src/tests.c REVERT: b76e45d Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing. REVERT: 870a977 Merge bitcoin#562: Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse REVERT: be40c4d Fixup for C90 mixed declarations. REVERT: c71dd2c Merge bitcoin#509: Fix algorithm selection in bench_ecmult REVERT: 6492bf8 Merge bitcoin#518: Summarize build options after running configure REVERT: 0e9ada1 Merge bitcoin#567: Correct order of libs returned on pkg-config --libs --static libsecp2… REVERT: e96901a Merge bitcoin#587: Make randomization of a non-signing context a noop REVERT: 58df8d0 Merge bitcoin#511: Portability fix for the configure scripts generated REVERT: 2ebdad7 Merge bitcoin#552: Make constants static: REVERT: 1c131af Merge bitcoin#551: secp256k1_fe_sqrt: Verify that the arguments don't alias. REVERT: ba698f8 Merge bitcoin#539: Assorted minor corrections REVERT: 949e85b Merge bitcoin#550: Optimize secp256k1_fe_normalize_weak calls. REVERT: a34bcaa Actually pass CFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD to linker REVERT: 2d5f4ce configure: Use CFLAGS_FOR_BUILD when checking native compiler REVERT: b408c6a Merge bitcoin#579: Use __GNUC_PREREQ for detecting __builtin_expect REVERT: 6198375 Make randomization of a non-signing context a noop REVERT: c663397 Use __GNUC_PREREQ for detecting __builtin_expect REVERT: e34ceb3 Merge bitcoin#557: Eliminate scratch memory used when generating contexts REVERT: b3bf5f9 ecmult_impl: expand comment to explain how effective affine interacts with everything REVERT: efa783f Store z-ratios in the 'x' coord they'll recover REVERT: ffd3b34 add `secp256k1_ge_set_all_gej_var` test which deals with many infinite points REVERT: 84740ac ecmult_impl: save one fe_inv_var REVERT: 4704527 ecmult_impl: eliminate scratch memory used when generating context REVERT: 7f7a2ed ecmult_gen_impl: eliminate scratch memory used when generating context REVERT: 314a61d Merge bitcoin#553: add static context object which has no capabilities REVERT: 89a20a8 Correct order of libs returned on pkg-config --libs --static libsecp256k1 call. REVERT: d3cb1f9 Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse REVERT: 40fde61 prevent attempts to modify `secp256k1_context_no_precomp` REVERT: ed7c084 add static context object which has no capabilities REVERT: 496c5b4 Make constants static: static const secp256k1_ge secp256k1_ge_const_g; static const int CURVE_B; REVERT: bf8b86c secp256k1_fe_sqrt: Verify that the arguments don't alias. REVERT: 9bd89c8 Optimize secp256k1_fe_normalize_weak calls. Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead. REVERT: 52ab96f clean dependendies in field_*_impl.h REVERT: deff5ed Correct math typos in field_*.h REVERT: 4efb3f8 Add check that restrict pointers don't alias with all parameters. REVERT: 3965027 Summarize build options in configure script REVERT: 0f05173 Fix algorithm selection in bench_ecmult REVERT: 8b3841c fix bug in fread() failure check REVERT: cddef0c tests: add warning message when /dev/urandom fails REVERT: 270f6c8 Portability fix for the configure scripts generated git-subtree-dir: src/secp256k1 git-subtree-split: 763484a1e5bed2b8b990e71c2f66129ae1038d59
1 parent cc05fa9 commit 1e32413

31 files changed

+1824
-423
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
bench_inv
22
bench_ecdh
33
bench_ecmult
4+
bench_schnorrsig
45
bench_sign
56
bench_verify
6-
bench_schnorr_verify
77
bench_recover
88
bench_internal
99
tests

Makefile.am

+7-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ exhaustive_tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src $(SECP_INCLUDE
114114
if !ENABLE_COVERAGE
115115
exhaustive_tests_CPPFLAGS += -DVERIFY
116116
endif
117-
exhaustive_tests_LDADD = $(SECP_LIBS) $(COMMON_LIB)
117+
exhaustive_tests_LDADD = $(SECP_LIBS)
118118
exhaustive_tests_LDFLAGS = -static
119119
TESTS += exhaustive_tests
120120
endif
@@ -151,14 +151,15 @@ endif
151151

152152
if USE_ECMULT_STATIC_PRECOMPUTATION
153153
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir)
154+
CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function
154155

155156
gen_context_OBJECTS = gen_context.o
156157
gen_context_BIN = gen_context$(BUILD_EXEEXT)
157158
gen_%.o: src/gen_%.c
158159
$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@
159160

160161
$(gen_context_BIN): $(gen_context_OBJECTS)
161-
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@
162+
$(CC_FOR_BUILD) $^ -o $@
162163

163164
$(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h
164165
$(tests_OBJECTS): src/ecmult_static_context.h
@@ -177,6 +178,10 @@ if ENABLE_MODULE_ECDH
177178
include src/modules/ecdh/Makefile.am.include
178179
endif
179180

181+
if ENABLE_MODULE_SCHNORRSIG
182+
include src/modules/schnorrsig/Makefile.am.include
183+
endif
184+
180185
if ENABLE_MODULE_RECOVERY
181186
include src/modules/recovery/Makefile.am.include
182187
endif

configure.ac

+40-56
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ AC_ARG_ENABLE(module_ecdh,
129129
[enable_module_ecdh=$enableval],
130130
[enable_module_ecdh=no])
131131

132+
AC_ARG_ENABLE(module_schnorrsig,
133+
AS_HELP_STRING([--enable-module-schnorrsig],[enable schnorrsig module (experimental)]),
134+
[enable_module_schnorrsig=$enableval],
135+
[enable_module_schnorrsig=no])
136+
132137
AC_ARG_ENABLE(module_recovery,
133138
AS_HELP_STRING([--enable-module-recovery],[enable ECDSA pubkey recovery module (default is no)]),
134139
[enable_module_recovery=$enableval],
@@ -153,6 +158,12 @@ AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm|no|auto]
153158

154159
AC_CHECK_TYPES([__int128])
155160

161+
AC_MSG_CHECKING([for __builtin_expect])
162+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
163+
[ AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_BUILTIN_EXPECT,1,[Define this symbol if __builtin_expect is available]) ],
164+
[ AC_MSG_RESULT([no])
165+
])
166+
156167
if test x"$enable_coverage" = x"yes"; then
157168
AC_DEFINE(COVERAGE, 1, [Define this symbol to compile out all VERIFY code])
158169
CFLAGS="$CFLAGS -O0 --coverage"
@@ -162,54 +173,27 @@ else
162173
fi
163174

164175
if test x"$use_ecmult_static_precomputation" != x"no"; then
165-
# Temporarily switch to an environment for the native compiler
166176
save_cross_compiling=$cross_compiling
167177
cross_compiling=no
168-
SAVE_CC="$CC"
178+
TEMP_CC="$CC"
169179
CC="$CC_FOR_BUILD"
170-
SAVE_CFLAGS="$CFLAGS"
171-
CFLAGS="$CFLAGS_FOR_BUILD"
172-
SAVE_CPPFLAGS="$CPPFLAGS"
173-
CPPFLAGS="$CPPFLAGS_FOR_BUILD"
174-
SAVE_LDFLAGS="$LDFLAGS"
175-
LDFLAGS="$LDFLAGS_FOR_BUILD"
176-
177-
warn_CFLAGS_FOR_BUILD="-Wall -Wextra -Wno-unused-function"
178-
saved_CFLAGS="$CFLAGS"
179-
CFLAGS="$CFLAGS $warn_CFLAGS_FOR_BUILD"
180-
AC_MSG_CHECKING([if native ${CC_FOR_BUILD} supports ${warn_CFLAGS_FOR_BUILD}])
181-
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
182-
[ AC_MSG_RESULT([yes]) ],
183-
[ AC_MSG_RESULT([no])
184-
CFLAGS="$saved_CFLAGS"
185-
])
186-
187-
AC_MSG_CHECKING([for working native compiler: ${CC_FOR_BUILD}])
180+
AC_MSG_CHECKING([native compiler: ${CC_FOR_BUILD}])
188181
AC_RUN_IFELSE(
189-
[AC_LANG_PROGRAM([], [])],
182+
[AC_LANG_PROGRAM([], [return 0])],
190183
[working_native_cc=yes],
191184
[working_native_cc=no],[dnl])
192-
193-
CFLAGS_FOR_BUILD="$CFLAGS"
194-
195-
# Restore the environment
185+
CC="$TEMP_CC"
196186
cross_compiling=$save_cross_compiling
197-
CC="$SAVE_CC"
198-
CFLAGS="$SAVE_CFLAGS"
199-
CPPFLAGS="$SAVE_CPPFLAGS"
200-
LDFLAGS="$SAVE_LDFLAGS"
201187

202188
if test x"$working_native_cc" = x"no"; then
203-
AC_MSG_RESULT([no])
204189
set_precomp=no
205-
m4_define([please_set_for_build], [Please set CC_FOR_BUILD, CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD, and/or LDFLAGS_FOR_BUILD.])
206190
if test x"$use_ecmult_static_precomputation" = x"yes"; then
207-
AC_MSG_ERROR([native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build])
191+
AC_MSG_ERROR([${CC_FOR_BUILD} does not produce working binaries. Please set CC_FOR_BUILD])
208192
else
209-
AC_MSG_WARN([Disabling statically generated ecmult table because the native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build])
193+
AC_MSG_RESULT([${CC_FOR_BUILD} does not produce working binaries. Please set CC_FOR_BUILD])
210194
fi
211195
else
212-
AC_MSG_RESULT([yes])
196+
AC_MSG_RESULT([ok])
213197
set_precomp=yes
214198
fi
215199
else
@@ -452,6 +436,10 @@ if test x"$enable_module_ecdh" = x"yes"; then
452436
AC_DEFINE(ENABLE_MODULE_ECDH, 1, [Define this symbol to enable the ECDH module])
453437
fi
454438

439+
if test x"$enable_module_schnorrsig" = x"yes"; then
440+
AC_DEFINE(ENABLE_MODULE_SCHNORRSIG, 1, [Define this symbol to enable the schnorrsig module])
441+
fi
442+
455443
if test x"$enable_module_recovery" = x"yes"; then
456444
AC_DEFINE(ENABLE_MODULE_RECOVERY, 1, [Define this symbol to enable the ECDSA pubkey recovery module])
457445
fi
@@ -462,16 +450,32 @@ if test x"$use_external_asm" = x"yes"; then
462450
AC_DEFINE(USE_EXTERNAL_ASM, 1, [Define this symbol if an external (non-inline) assembly implementation is used])
463451
fi
464452

453+
AC_MSG_NOTICE([Using static precomputation: $set_precomp])
454+
AC_MSG_NOTICE([Using assembly optimizations: $set_asm])
455+
AC_MSG_NOTICE([Using field implementation: $set_field])
456+
AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
457+
AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
458+
AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
459+
AC_MSG_NOTICE([Building benchmarks: $use_benchmark])
460+
AC_MSG_NOTICE([Building for coverage analysis: $enable_coverage])
461+
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
462+
AC_MSG_NOTICE([Building ECDSA pubkey recovery module: $enable_module_recovery])
463+
AC_MSG_NOTICE([Using jni: $use_jni])
464+
465465
if test x"$enable_experimental" = x"yes"; then
466466
AC_MSG_NOTICE([******])
467467
AC_MSG_NOTICE([WARNING: experimental build])
468468
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
469469
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
470+
AC_MSG_NOTICE([Building schnorrsig module: $enable_module_schnorrsig])
470471
AC_MSG_NOTICE([******])
471472
else
472473
if test x"$enable_module_ecdh" = x"yes"; then
473474
AC_MSG_ERROR([ECDH module is experimental. Use --enable-experimental to allow.])
474475
fi
476+
if test x"$enable_module_schnorrsig" = x"yes"; then
477+
AC_MSG_ERROR([schnorrsig module is experimental. Use --enable-experimental to allow.])
478+
fi
475479
if test x"$set_asm" = x"arm"; then
476480
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
477481
fi
@@ -490,8 +494,9 @@ AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
490494
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
491495
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
492496
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
497+
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
493498
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
494-
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" = x"yes"])
499+
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"])
495500
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
496501
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
497502

@@ -501,24 +506,3 @@ unset PKG_CONFIG_PATH
501506
PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
502507

503508
AC_OUTPUT
504-
505-
echo
506-
echo "Build Options:"
507-
echo " with endomorphism = $use_endomorphism"
508-
echo " with ecmult precomp = $set_precomp"
509-
echo " with jni = $use_jni"
510-
echo " with benchmarks = $use_benchmark"
511-
echo " with coverage = $enable_coverage"
512-
echo " module ecdh = $enable_module_ecdh"
513-
echo " module recovery = $enable_module_recovery"
514-
echo
515-
echo " asm = $set_asm"
516-
echo " bignum = $set_bignum"
517-
echo " field = $set_field"
518-
echo " scalar = $set_scalar"
519-
echo
520-
echo " CC = $CC"
521-
echo " CFLAGS = $CFLAGS"
522-
echo " CPPFLAGS = $CPPFLAGS"
523-
echo " LDFLAGS = $LDFLAGS"
524-
echo

include/secp256k1.h

+7-13
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ typedef int (*secp256k1_nonce_function)(
179179
#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN 0x06
180180
#define SECP256K1_TAG_PUBKEY_HYBRID_ODD 0x07
181181

182-
/** A simple secp256k1 context object with no precomputed tables. These are useful for
183-
* type serialization/parsing functions which require a context object to maintain
184-
* API consistency, but currently do not require expensive precomputations or dynamic
185-
* allocations.
186-
*/
187-
SECP256K1_API extern const secp256k1_context *secp256k1_context_no_precomp;
188-
189182
/** Create a secp256k1 context object.
190183
*
191184
* Returns: a newly created context object.
@@ -482,6 +475,12 @@ SECP256K1_API int secp256k1_ecdsa_signature_normalize(
482475
*/
483476
SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_rfc6979;
484477

478+
/** An implementation of the nonce generation function as defined in BIP-schnorr.
479+
* If a data pointer is passed, it is assumed to be a pointer to 32 bytes of
480+
* extra entropy.
481+
*/
482+
SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_bipschnorr;
483+
485484
/** A default safe nonce generation function (currently equal to secp256k1_nonce_function_rfc6979). */
486485
SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_default;
487486

@@ -615,7 +614,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(
615614
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
616615

617616
/** Updates the context randomization to protect against side-channel leakage.
618-
* Returns: 1: randomization successfully updated or nothing to randomize
617+
* Returns: 1: randomization successfully updated
619618
* 0: error
620619
* Args: ctx: pointer to a context object (cannot be NULL)
621620
* In: seed32: pointer to a 32-byte random seed (NULL resets to initial state)
@@ -630,11 +629,6 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(
630629
* that it does not affect function results, but shields against attacks which
631630
* rely on any input-dependent behaviour.
632631
*
633-
* This function has currently an effect only on contexts initialized for signing
634-
* because randomization is currently used only for signing. However, this is not
635-
* guaranteed and may change in the future. It is safe to call this function on
636-
* contexts not initialized for signing; then it will have no effect and return 1.
637-
*
638632
* You should call this after secp256k1_context_create or
639633
* secp256k1_context_clone, and may call this repeatedly afterwards.
640634
*/

include/secp256k1_schnorrsig.h

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#ifndef SECP256K1_SCHNORRSIG_H
2+
#define SECP256K1_SCHNORRSIG_H
3+
4+
/** This module implements a variant of Schnorr signatures compliant with
5+
* BIP-schnorr
6+
* (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki).
7+
*/
8+
9+
/** Opaque data structure that holds a parsed Schnorr signature.
10+
*
11+
* The exact representation of data inside is implementation defined and not
12+
* guaranteed to be portable between different platforms or versions. It is
13+
* however guaranteed to be 64 bytes in size, and can be safely copied/moved.
14+
* If you need to convert to a format suitable for storage, transmission, or
15+
* comparison, use the `secp256k1_schnorrsig_serialize` and
16+
* `secp256k1_schnorrsig_parse` functions.
17+
*/
18+
typedef struct {
19+
unsigned char data[64];
20+
} secp256k1_schnorrsig;
21+
22+
/** Serialize a Schnorr signature.
23+
*
24+
* Returns: 1
25+
* Args: ctx: a secp256k1 context object
26+
* Out: out64: pointer to a 64-byte array to store the serialized signature
27+
* In: sig: pointer to the signature
28+
*
29+
* See secp256k1_schnorrsig_parse for details about the encoding.
30+
*/
31+
SECP256K1_API int secp256k1_schnorrsig_serialize(
32+
const secp256k1_context* ctx,
33+
unsigned char *out64,
34+
const secp256k1_schnorrsig* sig
35+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
36+
37+
/** Parse a Schnorr signature.
38+
*
39+
* Returns: 1 when the signature could be parsed, 0 otherwise.
40+
* Args: ctx: a secp256k1 context object
41+
* Out: sig: pointer to a signature object
42+
* In: in64: pointer to the 64-byte signature to be parsed
43+
*
44+
* The signature is serialized in the form R||s, where R is a 32-byte public
45+
* key (x-coordinate only; the y-coordinate is considered to be the unique
46+
* y-coordinate satisfying the curve equation that is a quadratic residue)
47+
* and s is a 32-byte big-endian scalar.
48+
*
49+
* After the call, sig will always be initialized. If parsing failed or the
50+
* encoded numbers are out of range, signature validation with it is
51+
* guaranteed to fail for every message and public key.
52+
*/
53+
SECP256K1_API int secp256k1_schnorrsig_parse(
54+
const secp256k1_context* ctx,
55+
secp256k1_schnorrsig* sig,
56+
const unsigned char *in64
57+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
58+
59+
/** Create a Schnorr signature.
60+
*
61+
* Returns 1 on success, 0 on failure.
62+
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL)
63+
* Out: sig: pointer to the returned signature (cannot be NULL)
64+
* nonce_is_negated: a pointer to an integer indicates if signing algorithm negated the
65+
* nonce (can be NULL)
66+
* In: msg32: the 32-byte message hash being signed (cannot be NULL)
67+
* seckey: pointer to a 32-byte secret key (cannot be NULL)
68+
* noncefp: pointer to a nonce generation function. If NULL, secp256k1_nonce_function_bipschnorr is used
69+
* ndata: pointer to arbitrary data used by the nonce generation function (can be NULL)
70+
*/
71+
SECP256K1_API int secp256k1_schnorrsig_sign(
72+
const secp256k1_context* ctx,
73+
secp256k1_schnorrsig *sig,
74+
int *nonce_is_negated,
75+
const unsigned char *msg32,
76+
const unsigned char *seckey,
77+
secp256k1_nonce_function noncefp,
78+
void *ndata
79+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5);
80+
81+
/** Verify a Schnorr signature.
82+
*
83+
* Returns: 1: correct signature
84+
* 0: incorrect or unparseable signature
85+
* Args: ctx: a secp256k1 context object, initialized for verification.
86+
* In: sig: the signature being verified (cannot be NULL)
87+
* msg32: the 32-byte message hash being verified (cannot be NULL)
88+
* pubkey: pointer to a public key to verify with (cannot be NULL)
89+
*/
90+
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify(
91+
const secp256k1_context* ctx,
92+
const secp256k1_schnorrsig *sig,
93+
const unsigned char *msg32,
94+
const secp256k1_pubkey *pubkey
95+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
96+
97+
/** Verifies a set of Schnorr signatures.
98+
*
99+
* Returns 1 if all succeeded, 0 otherwise. In particular, returns 1 if n_sigs is 0.
100+
*
101+
* Args: ctx: a secp256k1 context object, initialized for verification.
102+
* scratch: scratch space used for the multiexponentiation
103+
* In: sig: array of signatures, or NULL if there are no signatures
104+
* msg32: array of messages, or NULL if there are no signatures
105+
* pk: array of public keys, or NULL if there are no signatures
106+
* n_sigs: number of signatures in above arrays. Must be smaller than
107+
* 2^31 and smaller than half the maximum size_t value. Must be 0
108+
* if above arrays are NULL.
109+
*/
110+
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify_batch(
111+
const secp256k1_context* ctx,
112+
secp256k1_scratch_space *scratch,
113+
const secp256k1_schnorrsig *const *sig,
114+
const unsigned char *const *msg32,
115+
const secp256k1_pubkey *const *pk,
116+
size_t n_sigs
117+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2);
118+
#endif

libsecp256k1.pc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Description: Optimized C library for EC operations on curve secp256k1
88
URL: https://github.com/bitcoin-core/secp256k1
99
Version: @PACKAGE_VERSION@
1010
Cflags: -I${includedir}
11-
Libs: -L${libdir} -lsecp256k1
1211
Libs.private: @SECP_LIBS@
12+
Libs: -L${libdir} -lsecp256k1
1313

0 commit comments

Comments
 (0)