Skip to content

Commit 60a5e36

Browse files
committed
Merge #670: fix incorrect FFI binding for pubkey_combine
3373cc9 secp256k1-sys: update all symbols from 0.9.1 to 0.9.2 (Andrew Poelstra) 484e5d8 fix incorrect FFI binding for pubkey_combine (Andrew Poelstra) Pull request description: Fixes #669. Needs backport. ACKs for top commit: Kixunil: ACK 3373cc9 Tree-SHA512: 602a5baa8095cc744a341d64e300185bce26c8c56e7a538d3b17c7ca4c98cb3244217cd34169e1e69dc904a9f9f28ed75fe096ffa95ea42d1ad3456d395f7ce5
2 parents 97dade5 + 3373cc9 commit 60a5e36

File tree

119 files changed

+6791
-8866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+6791
-8866
lines changed

Cargo-minimal.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ dependencies = [
273273

274274
[[package]]
275275
name = "secp256k1-sys"
276-
version = "0.9.1"
276+
version = "0.9.2"
277277
dependencies = [
278278
"cc",
279279
"libc",

Cargo-recent.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ dependencies = [
194194

195195
[[package]]
196196
name = "secp256k1-sys"
197-
version = "0.9.1"
197+
version = "0.9.2"
198198
dependencies = [
199199
"cc",
200200
"libc",

secp256k1-sys/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.9.2 - 2023-12-18
2+
3+
* Fix incorrect FFI binding for `secp256k1_pubkey_combine`
4+
15
# 0.9.1 - 2023-12-07
26

37
* Patch out any instances of printf in upstream [#663](https://github.com/rust-bitcoin/rust-secp256k1/pull/663)

secp256k1-sys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "secp256k1-sys"
3-
version = "0.9.1"
3+
version = "0.9.2"
44
authors = [ "Dawid Ciężarkiewicz <[email protected]>",
55
"Andrew Poelstra <[email protected]>",
66
"Steven Roose <[email protected]>" ]
@@ -12,7 +12,7 @@ description = "FFI for Pieter Wuille's `libsecp256k1` library."
1212
keywords = [ "secp256k1", "libsecp256k1", "ffi" ]
1313
readme = "README.md"
1414
build = "build.rs"
15-
links = "rustsecp256k1_v0_9_1"
15+
links = "rustsecp256k1_v0_9_2"
1616
edition = "2018"
1717

1818
[package.metadata.docs.rs]

secp256k1-sys/depend/secp256k1/Makefile.am

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AM_CFLAGS = $(SECP_CFLAGS)
66

77
lib_LTLIBRARIES = libsecp256k1.la
88
include_HEADERS = include/secp256k1.h
9-
include_HEADERS += include/rustsecp256k1_v0_9_1_preallocated.h
9+
include_HEADERS += include/rustsecp256k1_v0_9_2_preallocated.h
1010
noinst_HEADERS =
1111
noinst_HEADERS += src/scalar.h
1212
noinst_HEADERS += src/scalar_4x64.h
@@ -63,22 +63,22 @@ noinst_HEADERS += src/hash_impl.h
6363
noinst_HEADERS += src/field.h
6464
noinst_HEADERS += src/field_impl.h
6565
noinst_HEADERS += src/bench.h
66-
noinst_HEADERS += src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.h
66+
noinst_HEADERS += src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.h
6767
noinst_HEADERS += contrib/lax_der_parsing.h
6868
noinst_HEADERS += contrib/lax_der_parsing.c
6969
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
7070
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
7171
noinst_HEADERS += examples/examples_util.h
7272

73-
PRECOMPUTED_LIB = librustsecp256k1_v0_9_1_precomputed.la
73+
PRECOMPUTED_LIB = librustsecp256k1_v0_9_2_precomputed.la
7474
noinst_LTLIBRARIES = $(PRECOMPUTED_LIB)
75-
librustsecp256k1_v0_9_1_precomputed_la_SOURCES = src/precomputed_ecmult.c src/precomputed_ecmult_gen.c
76-
# We need `-I$(top_srcdir)/src` in VPATH builds if librustsecp256k1_v0_9_1_precomputed_la_SOURCES have been recreated in the build tree.
75+
librustsecp256k1_v0_9_2_precomputed_la_SOURCES = src/precomputed_ecmult.c src/precomputed_ecmult_gen.c
76+
# We need `-I$(top_srcdir)/src` in VPATH builds if librustsecp256k1_v0_9_2_precomputed_la_SOURCES have been recreated in the build tree.
7777
# This helps users and packagers who insist on recreating the precomputed files (e.g., Gentoo).
78-
librustsecp256k1_v0_9_1_precomputed_la_CPPFLAGS = -I$(top_srcdir)/src $(SECP_CONFIG_DEFINES)
78+
librustsecp256k1_v0_9_2_precomputed_la_CPPFLAGS = -I$(top_srcdir)/src $(SECP_CONFIG_DEFINES)
7979

8080
if USE_EXTERNAL_ASM
81-
COMMON_LIB = librustsecp256k1_v0_9_1_common.la
81+
COMMON_LIB = librustsecp256k1_v0_9_2_common.la
8282
else
8383
COMMON_LIB =
8484
endif
@@ -89,14 +89,14 @@ pkgconfig_DATA = libsecp256k1.pc
8989

9090
if USE_EXTERNAL_ASM
9191
if USE_ASM_ARM
92-
librustsecp256k1_v0_9_1_common_la_SOURCES = src/asm/field_10x26_arm.s
92+
librustsecp256k1_v0_9_2_common_la_SOURCES = src/asm/field_10x26_arm.s
9393
endif
9494
endif
9595

96-
librustsecp256k1_v0_9_1_la_SOURCES = src/secp256k1.c
97-
librustsecp256k1_v0_9_1_la_CPPFLAGS = $(SECP_CONFIG_DEFINES)
98-
librustsecp256k1_v0_9_1_la_LIBADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
99-
librustsecp256k1_v0_9_1_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE)
96+
librustsecp256k1_v0_9_2_la_SOURCES = src/secp256k1.c
97+
librustsecp256k1_v0_9_2_la_CPPFLAGS = $(SECP_CONFIG_DEFINES)
98+
librustsecp256k1_v0_9_2_la_LIBADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
99+
librustsecp256k1_v0_9_2_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE)
100100

101101
noinst_PROGRAMS =
102102
if USE_BENCHMARK
@@ -223,11 +223,11 @@ maintainer-clean-local: clean-precomp
223223

224224
### Pregenerated test vectors
225225
### (see the comments in the previous section for detailed rationale)
226-
TESTVECTORS = src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.h
226+
TESTVECTORS = src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.h
227227

228-
src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.h:
228+
src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.h:
229229
mkdir -p $(@D)
230-
python3 $(top_srcdir)/tools/tests_wycheproof_generate.py $(top_srcdir)/src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.json > $@
230+
python3 $(top_srcdir)/tools/tests_wycheproof_generate.py $(top_srcdir)/src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.json > $@
231231

232232
testvectors: $(TESTVECTORS)
233233

@@ -246,10 +246,10 @@ EXTRA_DIST += sage/gen_exhaustive_groups.sage
246246
EXTRA_DIST += sage/gen_split_lambda_constants.sage
247247
EXTRA_DIST += sage/group_prover.sage
248248
EXTRA_DIST += sage/prove_group_implementations.sage
249-
EXTRA_DIST += sage/rustsecp256k1_v0_9_1_params.sage
249+
EXTRA_DIST += sage/rustsecp256k1_v0_9_2_params.sage
250250
EXTRA_DIST += sage/weierstrass_prover.sage
251251
EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING
252-
EXTRA_DIST += src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.json
252+
EXTRA_DIST += src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.json
253253
EXTRA_DIST += tools/tests_wycheproof_generate.py
254254

255255
if ENABLE_MODULE_ECDH

secp256k1-sys/depend/secp256k1/cmake/TryAppendCFlags.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include(CheckCCompilerFlag)
22

3-
function(rustsecp256k1_v0_9_1_check_c_flags_internal flags output)
3+
function(rustsecp256k1_v0_9_2_check_c_flags_internal flags output)
44
string(MAKE_C_IDENTIFIER "${flags}" result)
55
string(TOUPPER "${result}" result)
66
set(result "C_SUPPORTS_${result}")
@@ -17,7 +17,7 @@ endfunction()
1717

1818
# Append flags to the COMPILE_OPTIONS directory property if CC accepts them.
1919
macro(try_append_c_flags)
20-
rustsecp256k1_v0_9_1_check_c_flags_internal("${ARGV}" result)
20+
rustsecp256k1_v0_9_2_check_c_flags_internal("${ARGV}" result)
2121
if(result)
2222
add_compile_options(${ARGV})
2323
endif()

secp256k1-sys/depend/secp256k1/contrib/lax_der_parsing.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
#include <string.h>
88

99
#include "lax_der_parsing.h"
10-
extern int rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(
11-
const rustsecp256k1_v0_9_1_context *ctx,
12-
rustsecp256k1_v0_9_1_ecdsa_signature *sig, const unsigned char *input64);
13-
int rustsecp256k1_v0_9_1_ecdsa_signature_parse_der_lax(const rustsecp256k1_v0_9_1_context* ctx, rustsecp256k1_v0_9_1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) {
10+
extern int rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(
11+
const rustsecp256k1_v0_9_2_context *ctx,
12+
rustsecp256k1_v0_9_2_ecdsa_signature *sig, const unsigned char *input64);
13+
int rustsecp256k1_v0_9_2_ecdsa_signature_parse_der_lax(const rustsecp256k1_v0_9_2_context* ctx, rustsecp256k1_v0_9_2_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) {
1414
size_t rpos, rlen, spos, slen;
1515
size_t pos = 0;
1616
size_t lenbyte;
1717
unsigned char tmpsig[64] = {0};
1818
int overflow = 0;
1919

2020
/* Hack to initialize sig with a correctly-parsed but invalid signature. */
21-
rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
21+
rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
2222

2323
/* Sequence tag byte */
2424
if (pos == inputlen || input[pos] != 0x30) {
@@ -139,11 +139,11 @@ int rustsecp256k1_v0_9_1_ecdsa_signature_parse_der_lax(const rustsecp256k1_v0_9_
139139
}
140140

141141
if (!overflow) {
142-
overflow = !rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
142+
overflow = !rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
143143
}
144144
if (overflow) {
145145
memset(tmpsig, 0, 64);
146-
rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
146+
rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
147147
}
148148
return 1;
149149
}

secp256k1-sys/depend/secp256k1/contrib/lax_der_parsing.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* certain violations are easily supported. You may need to adapt it.
2727
*
2828
* Do not use this for new systems. Use well-defined DER or compact signatures
29-
* instead if you have the choice (see rustsecp256k1_v0_9_1_ecdsa_signature_parse_der and
30-
* rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact).
29+
* instead if you have the choice (see rustsecp256k1_v0_9_2_ecdsa_signature_parse_der and
30+
* rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact).
3131
*
3232
* The supported violations are:
3333
* - All numbers are parsed as nonnegative integers, even though X.609-0207
@@ -83,9 +83,9 @@ extern "C" {
8383
* encoded numbers are out of range, signature validation with it is
8484
* guaranteed to fail for every message and public key.
8585
*/
86-
int rustsecp256k1_v0_9_1_ecdsa_signature_parse_der_lax(
87-
const rustsecp256k1_v0_9_1_context* ctx,
88-
rustsecp256k1_v0_9_1_ecdsa_signature* sig,
86+
int rustsecp256k1_v0_9_2_ecdsa_signature_parse_der_lax(
87+
const rustsecp256k1_v0_9_2_context* ctx,
88+
rustsecp256k1_v0_9_2_ecdsa_signature* sig,
8989
const unsigned char *input,
9090
size_t inputlen
9191
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);

secp256k1-sys/depend/secp256k1/contrib/lax_der_privatekey_parsing.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "lax_der_privatekey_parsing.h"
1010

11-
int ec_privkey_import_der(const rustsecp256k1_v0_9_1_context* ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen) {
11+
int ec_privkey_import_der(const rustsecp256k1_v0_9_2_context* ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen) {
1212
const unsigned char *end = privkey + privkeylen;
1313
int lenb = 0;
1414
int len = 0;
@@ -45,17 +45,17 @@ int ec_privkey_import_der(const rustsecp256k1_v0_9_1_context* ctx, unsigned char
4545
return 0;
4646
}
4747
if (privkey[1]) memcpy(out32 + 32 - privkey[1], privkey + 2, privkey[1]);
48-
if (!rustsecp256k1_v0_9_1_ec_seckey_verify(ctx, out32)) {
48+
if (!rustsecp256k1_v0_9_2_ec_seckey_verify(ctx, out32)) {
4949
memset(out32, 0, 32);
5050
return 0;
5151
}
5252
return 1;
5353
}
5454

55-
int ec_privkey_export_der(const rustsecp256k1_v0_9_1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) {
56-
rustsecp256k1_v0_9_1_pubkey pubkey;
55+
int ec_privkey_export_der(const rustsecp256k1_v0_9_2_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) {
56+
rustsecp256k1_v0_9_2_pubkey pubkey;
5757
size_t pubkeylen = 0;
58-
if (!rustsecp256k1_v0_9_1_ec_pubkey_create(ctx, &pubkey, key32)) {
58+
if (!rustsecp256k1_v0_9_2_ec_pubkey_create(ctx, &pubkey, key32)) {
5959
*privkeylen = 0;
6060
return 0;
6161
}
@@ -79,7 +79,7 @@ int ec_privkey_export_der(const rustsecp256k1_v0_9_1_context *ctx, unsigned char
7979
memcpy(ptr, key32, 32); ptr += 32;
8080
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
8181
pubkeylen = 33;
82-
rustsecp256k1_v0_9_1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
82+
rustsecp256k1_v0_9_2_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
8383
ptr += pubkeylen;
8484
*privkeylen = ptr - privkey;
8585
} else {
@@ -104,7 +104,7 @@ int ec_privkey_export_der(const rustsecp256k1_v0_9_1_context *ctx, unsigned char
104104
memcpy(ptr, key32, 32); ptr += 32;
105105
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
106106
pubkeylen = 65;
107-
rustsecp256k1_v0_9_1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
107+
rustsecp256k1_v0_9_2_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
108108
ptr += pubkeylen;
109109
*privkeylen = ptr - privkey;
110110
}

secp256k1-sys/depend/secp256k1/contrib/lax_der_privatekey_parsing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343
/** Export a private key in DER format.
4444
*
4545
* Returns: 1 if the private key was valid.
46-
* Args: ctx: pointer to a context object (not rustsecp256k1_v0_9_1_context_static).
46+
* Args: ctx: pointer to a context object (not rustsecp256k1_v0_9_2_context_static).
4747
* Out: privkey: pointer to an array for storing the private key in BER.
4848
* Should have space for 279 bytes, and cannot be NULL.
4949
* privkeylen: Pointer to an int where the length of the private key in
@@ -57,10 +57,10 @@ extern "C" {
5757
* simple 32-byte private keys are sufficient.
5858
*
5959
* Note that this function does not guarantee correct DER output. It is
60-
* guaranteed to be parsable by rustsecp256k1_v0_9_1_ec_privkey_import_der
60+
* guaranteed to be parsable by rustsecp256k1_v0_9_2_ec_privkey_import_der
6161
*/
6262
SECP256K1_WARN_UNUSED_RESULT int ec_privkey_export_der(
63-
const rustsecp256k1_v0_9_1_context* ctx,
63+
const rustsecp256k1_v0_9_2_context* ctx,
6464
unsigned char *privkey,
6565
size_t *privkeylen,
6666
const unsigned char *seckey,
@@ -82,7 +82,7 @@ SECP256K1_WARN_UNUSED_RESULT int ec_privkey_export_der(
8282
* key.
8383
*/
8484
SECP256K1_WARN_UNUSED_RESULT int ec_privkey_import_der(
85-
const rustsecp256k1_v0_9_1_context* ctx,
85+
const rustsecp256k1_v0_9_2_context* ctx,
8686
unsigned char *seckey,
8787
const unsigned char *privkey,
8888
size_t privkeylen

secp256k1-sys/depend/secp256k1/doc/ellswift.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ but the approach here is simple enough and gives fairly uniform output even in t
144144
**Note**: in the paper these conditions result in $\infty$ as output, due to the use of projective coordinates there.
145145
We wish to avoid the need for callers to deal with this special case.
146146

147-
This is implemented in `rustsecp256k1_v0_9_1_ellswift_xswiftec_frac_var` (which decodes to an x-coordinate represented as a fraction), and
148-
in `rustsecp256k1_v0_9_1_ellswift_xswiftec_var` (which outputs the actual x-coordinate).
147+
This is implemented in `rustsecp256k1_v0_9_2_ellswift_xswiftec_frac_var` (which decodes to an x-coordinate represented as a fraction), and
148+
in `rustsecp256k1_v0_9_2_ellswift_xswiftec_var` (which outputs the actual x-coordinate).
149149

150150
## 3. The encoding function
151151

@@ -247,7 +247,7 @@ the loop can be simplified to only compute one of the inverses instead of all of
247247
* Let $t = G_{c,u}(x).$
248248
* If $t \neq \bot$, return $(u, t)$; restart loop otherwise.
249249

250-
This is implemented in `rustsecp256k1_v0_9_1_ellswift_xelligatorswift_var`.
250+
This is implemented in `rustsecp256k1_v0_9_2_ellswift_xelligatorswift_var`.
251251

252252
### 3.3 Finding the inverse
253253

@@ -388,7 +388,7 @@ Specialized for odd-ordered $a=0$ curves:
388388
* If $c \in \\{4, 6\\}:$ return $w(\frac{-\sqrt{-3}+1}{2}u + v).$
389389
* If $c \in \\{5, 7\\}:$ return $w(\frac{-\sqrt{-3}-1}{2}u - v).$
390390

391-
This is implemented in `rustsecp256k1_v0_9_1_ellswift_xswiftec_inv_var`.
391+
This is implemented in `rustsecp256k1_v0_9_2_ellswift_xswiftec_inv_var`.
392392

393393
And the x-only ElligatorSwift encoding algorithm is still:
394394

@@ -471,11 +471,11 @@ as decoder:
471471
* Let $y = \sqrt{g(x)}.$
472472
* Return $(x, y)$ if $sign(y) = sign(t)$; $(x, -y)$ otherwise.
473473

474-
This is implemented in `rustsecp256k1_v0_9_1_ellswift_swiftec_var`. The used $sign(x)$ function is the parity of $x$ when represented as in integer in $[0,q).$
474+
This is implemented in `rustsecp256k1_v0_9_2_ellswift_swiftec_var`. The used $sign(x)$ function is the parity of $x$ when represented as in integer in $[0,q).$
475475

476476
The corresponding encoder would invoke the x-only one, but negating the output $t$ if $sign(t) \neq sign(y).$
477477

478-
This is implemented in `rustsecp256k1_v0_9_1_ellswift_elligatorswift_var`.
478+
This is implemented in `rustsecp256k1_v0_9_2_ellswift_elligatorswift_var`.
479479

480480
Note that this is only intended for encoding points where both the x-coordinate and y-coordinate are unpredictable. When encoding x-only points
481481
where the y-coordinate is implicitly even (or implicitly square, or implicitly in $[0,q/2]$), the encoder in

0 commit comments

Comments
 (0)