Skip to content

Commit

Permalink
secp256k1-sys: update all symbols from 0.9.1 to 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Jan 2, 2024
1 parent 484e5d8 commit 3373cc9
Show file tree
Hide file tree
Showing 115 changed files with 6,781 additions and 8,860 deletions.
2 changes: 1 addition & 1 deletion secp256k1-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description = "FFI for Pieter Wuille's `libsecp256k1` library."
keywords = [ "secp256k1", "libsecp256k1", "ffi" ]
readme = "README.md"
build = "build.rs"
links = "rustsecp256k1_v0_9_1"
links = "rustsecp256k1_v0_9_2"
edition = "2018"

[package.metadata.docs.rs]
Expand Down
34 changes: 17 additions & 17 deletions secp256k1-sys/depend/secp256k1/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AM_CFLAGS = $(SECP_CFLAGS)

lib_LTLIBRARIES = libsecp256k1.la
include_HEADERS = include/secp256k1.h
include_HEADERS += include/rustsecp256k1_v0_9_1_preallocated.h
include_HEADERS += include/rustsecp256k1_v0_9_2_preallocated.h
noinst_HEADERS =
noinst_HEADERS += src/scalar.h
noinst_HEADERS += src/scalar_4x64.h
Expand Down Expand Up @@ -63,22 +63,22 @@ noinst_HEADERS += src/hash_impl.h
noinst_HEADERS += src/field.h
noinst_HEADERS += src/field_impl.h
noinst_HEADERS += src/bench.h
noinst_HEADERS += src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.h
noinst_HEADERS += src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.h
noinst_HEADERS += contrib/lax_der_parsing.h
noinst_HEADERS += contrib/lax_der_parsing.c
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
noinst_HEADERS += examples/examples_util.h

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

if USE_EXTERNAL_ASM
COMMON_LIB = librustsecp256k1_v0_9_1_common.la
COMMON_LIB = librustsecp256k1_v0_9_2_common.la
else
COMMON_LIB =
endif
Expand All @@ -89,14 +89,14 @@ pkgconfig_DATA = libsecp256k1.pc

if USE_EXTERNAL_ASM
if USE_ASM_ARM
librustsecp256k1_v0_9_1_common_la_SOURCES = src/asm/field_10x26_arm.s
librustsecp256k1_v0_9_2_common_la_SOURCES = src/asm/field_10x26_arm.s
endif
endif

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

noinst_PROGRAMS =
if USE_BENCHMARK
Expand Down Expand Up @@ -223,11 +223,11 @@ maintainer-clean-local: clean-precomp

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

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

testvectors: $(TESTVECTORS)

Expand All @@ -246,10 +246,10 @@ EXTRA_DIST += sage/gen_exhaustive_groups.sage
EXTRA_DIST += sage/gen_split_lambda_constants.sage
EXTRA_DIST += sage/group_prover.sage
EXTRA_DIST += sage/prove_group_implementations.sage
EXTRA_DIST += sage/rustsecp256k1_v0_9_1_params.sage
EXTRA_DIST += sage/rustsecp256k1_v0_9_2_params.sage
EXTRA_DIST += sage/weierstrass_prover.sage
EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING
EXTRA_DIST += src/wycheproof/ecdsa_rustsecp256k1_v0_9_1_sha256_bitcoin_test.json
EXTRA_DIST += src/wycheproof/ecdsa_rustsecp256k1_v0_9_2_sha256_bitcoin_test.json
EXTRA_DIST += tools/tests_wycheproof_generate.py

if ENABLE_MODULE_ECDH
Expand Down
4 changes: 2 additions & 2 deletions secp256k1-sys/depend/secp256k1/cmake/TryAppendCFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include(CheckCCompilerFlag)

function(rustsecp256k1_v0_9_1_check_c_flags_internal flags output)
function(rustsecp256k1_v0_9_2_check_c_flags_internal flags output)
string(MAKE_C_IDENTIFIER "${flags}" result)
string(TOUPPER "${result}" result)
set(result "C_SUPPORTS_${result}")
Expand All @@ -17,7 +17,7 @@ endfunction()

# Append flags to the COMPILE_OPTIONS directory property if CC accepts them.
macro(try_append_c_flags)
rustsecp256k1_v0_9_1_check_c_flags_internal("${ARGV}" result)
rustsecp256k1_v0_9_2_check_c_flags_internal("${ARGV}" result)
if(result)
add_compile_options(${ARGV})
endif()
Expand Down
14 changes: 7 additions & 7 deletions secp256k1-sys/depend/secp256k1/contrib/lax_der_parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
#include <string.h>

#include "lax_der_parsing.h"
extern int rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(
const rustsecp256k1_v0_9_1_context *ctx,
rustsecp256k1_v0_9_1_ecdsa_signature *sig, const unsigned char *input64);
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) {
extern int rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(
const rustsecp256k1_v0_9_2_context *ctx,
rustsecp256k1_v0_9_2_ecdsa_signature *sig, const unsigned char *input64);
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) {
size_t rpos, rlen, spos, slen;
size_t pos = 0;
size_t lenbyte;
unsigned char tmpsig[64] = {0};
int overflow = 0;

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

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

if (!overflow) {
overflow = !rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
overflow = !rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
}
if (overflow) {
memset(tmpsig, 0, 64);
rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
}
return 1;
}
Expand Down
10 changes: 5 additions & 5 deletions secp256k1-sys/depend/secp256k1/contrib/lax_der_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* certain violations are easily supported. You may need to adapt it.
*
* Do not use this for new systems. Use well-defined DER or compact signatures
* instead if you have the choice (see rustsecp256k1_v0_9_1_ecdsa_signature_parse_der and
* rustsecp256k1_v0_9_1_ecdsa_signature_parse_compact).
* instead if you have the choice (see rustsecp256k1_v0_9_2_ecdsa_signature_parse_der and
* rustsecp256k1_v0_9_2_ecdsa_signature_parse_compact).
*
* The supported violations are:
* - All numbers are parsed as nonnegative integers, even though X.609-0207
Expand Down Expand Up @@ -83,9 +83,9 @@ extern "C" {
* encoded numbers are out of range, signature validation with it is
* guaranteed to fail for every message and public key.
*/
int rustsecp256k1_v0_9_1_ecdsa_signature_parse_der_lax(
const rustsecp256k1_v0_9_1_context* ctx,
rustsecp256k1_v0_9_1_ecdsa_signature* sig,
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
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "lax_der_privatekey_parsing.h"

int ec_privkey_import_der(const rustsecp256k1_v0_9_1_context* ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen) {
int ec_privkey_import_der(const rustsecp256k1_v0_9_2_context* ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen) {
const unsigned char *end = privkey + privkeylen;
int lenb = 0;
int len = 0;
Expand Down Expand Up @@ -45,17 +45,17 @@ int ec_privkey_import_der(const rustsecp256k1_v0_9_1_context* ctx, unsigned char
return 0;
}
if (privkey[1]) memcpy(out32 + 32 - privkey[1], privkey + 2, privkey[1]);
if (!rustsecp256k1_v0_9_1_ec_seckey_verify(ctx, out32)) {
if (!rustsecp256k1_v0_9_2_ec_seckey_verify(ctx, out32)) {
memset(out32, 0, 32);
return 0;
}
return 1;
}

int ec_privkey_export_der(const rustsecp256k1_v0_9_1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) {
rustsecp256k1_v0_9_1_pubkey pubkey;
int ec_privkey_export_der(const rustsecp256k1_v0_9_2_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) {
rustsecp256k1_v0_9_2_pubkey pubkey;
size_t pubkeylen = 0;
if (!rustsecp256k1_v0_9_1_ec_pubkey_create(ctx, &pubkey, key32)) {
if (!rustsecp256k1_v0_9_2_ec_pubkey_create(ctx, &pubkey, key32)) {
*privkeylen = 0;
return 0;
}
Expand All @@ -79,7 +79,7 @@ int ec_privkey_export_der(const rustsecp256k1_v0_9_1_context *ctx, unsigned char
memcpy(ptr, key32, 32); ptr += 32;
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
pubkeylen = 33;
rustsecp256k1_v0_9_1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
rustsecp256k1_v0_9_2_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
ptr += pubkeylen;
*privkeylen = ptr - privkey;
} else {
Expand All @@ -104,7 +104,7 @@ int ec_privkey_export_der(const rustsecp256k1_v0_9_1_context *ctx, unsigned char
memcpy(ptr, key32, 32); ptr += 32;
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
pubkeylen = 65;
rustsecp256k1_v0_9_1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
rustsecp256k1_v0_9_2_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
ptr += pubkeylen;
*privkeylen = ptr - privkey;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern "C" {
/** Export a private key in DER format.
*
* Returns: 1 if the private key was valid.
* Args: ctx: pointer to a context object (not rustsecp256k1_v0_9_1_context_static).
* Args: ctx: pointer to a context object (not rustsecp256k1_v0_9_2_context_static).
* Out: privkey: pointer to an array for storing the private key in BER.
* Should have space for 279 bytes, and cannot be NULL.
* privkeylen: Pointer to an int where the length of the private key in
Expand All @@ -57,10 +57,10 @@ extern "C" {
* simple 32-byte private keys are sufficient.
*
* Note that this function does not guarantee correct DER output. It is
* guaranteed to be parsable by rustsecp256k1_v0_9_1_ec_privkey_import_der
* guaranteed to be parsable by rustsecp256k1_v0_9_2_ec_privkey_import_der
*/
SECP256K1_WARN_UNUSED_RESULT int ec_privkey_export_der(
const rustsecp256k1_v0_9_1_context* ctx,
const rustsecp256k1_v0_9_2_context* ctx,
unsigned char *privkey,
size_t *privkeylen,
const unsigned char *seckey,
Expand All @@ -82,7 +82,7 @@ SECP256K1_WARN_UNUSED_RESULT int ec_privkey_export_der(
* key.
*/
SECP256K1_WARN_UNUSED_RESULT int ec_privkey_import_der(
const rustsecp256k1_v0_9_1_context* ctx,
const rustsecp256k1_v0_9_2_context* ctx,
unsigned char *seckey,
const unsigned char *privkey,
size_t privkeylen
Expand Down
12 changes: 6 additions & 6 deletions secp256k1-sys/depend/secp256k1/doc/ellswift.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ but the approach here is simple enough and gives fairly uniform output even in t
**Note**: in the paper these conditions result in $\infty$ as output, due to the use of projective coordinates there.
We wish to avoid the need for callers to deal with this special case.

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

## 3. The encoding function

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

This is implemented in `rustsecp256k1_v0_9_1_ellswift_xelligatorswift_var`.
This is implemented in `rustsecp256k1_v0_9_2_ellswift_xelligatorswift_var`.

### 3.3 Finding the inverse

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

This is implemented in `rustsecp256k1_v0_9_1_ellswift_xswiftec_inv_var`.
This is implemented in `rustsecp256k1_v0_9_2_ellswift_xswiftec_inv_var`.

And the x-only ElligatorSwift encoding algorithm is still:

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

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).$
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).$

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

This is implemented in `rustsecp256k1_v0_9_1_ellswift_elligatorswift_var`.
This is implemented in `rustsecp256k1_v0_9_2_ellswift_elligatorswift_var`.

Note that this is only intended for encoding points where both the x-coordinate and y-coordinate are unpredictable. When encoding x-only points
where the y-coordinate is implicitly even (or implicitly square, or implicitly in $[0,q/2]$), the encoder in
Expand Down
26 changes: 13 additions & 13 deletions secp256k1-sys/depend/secp256k1/examples/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ int main(void) {
unsigned char randomize[32];
int return_val;
size_t len;
rustsecp256k1_v0_9_1_pubkey pubkey1;
rustsecp256k1_v0_9_1_pubkey pubkey2;
rustsecp256k1_v0_9_2_pubkey pubkey1;
rustsecp256k1_v0_9_2_pubkey pubkey2;

/* Before we can call actual API functions, we need to create a "context". */
rustsecp256k1_v0_9_1_context* ctx = rustsecp256k1_v0_9_1_context_create(SECP256K1_CONTEXT_NONE);
rustsecp256k1_v0_9_2_context* ctx = rustsecp256k1_v0_9_2_context_create(SECP256K1_CONTEXT_NONE);
if (!fill_random(randomize, sizeof(randomize))) {
printf("Failed to generate randomness\n");
return 1;
}
/* Randomizing the context is recommended to protect against side-channel
* leakage See `rustsecp256k1_v0_9_1_context_randomize` in secp256k1.h for more
* leakage See `rustsecp256k1_v0_9_2_context_randomize` in secp256k1.h for more
* information about it. This should never fail. */
return_val = rustsecp256k1_v0_9_1_context_randomize(ctx, randomize);
return_val = rustsecp256k1_v0_9_2_context_randomize(ctx, randomize);
assert(return_val);

/*** Key Generation ***/
Expand All @@ -51,27 +51,27 @@ int main(void) {
printf("Failed to generate randomness\n");
return 1;
}
if (rustsecp256k1_v0_9_1_ec_seckey_verify(ctx, seckey1) && rustsecp256k1_v0_9_1_ec_seckey_verify(ctx, seckey2)) {
if (rustsecp256k1_v0_9_2_ec_seckey_verify(ctx, seckey1) && rustsecp256k1_v0_9_2_ec_seckey_verify(ctx, seckey2)) {
break;
}
}

/* Public key creation using a valid context with a verified secret key should never fail */
return_val = rustsecp256k1_v0_9_1_ec_pubkey_create(ctx, &pubkey1, seckey1);
return_val = rustsecp256k1_v0_9_2_ec_pubkey_create(ctx, &pubkey1, seckey1);
assert(return_val);
return_val = rustsecp256k1_v0_9_1_ec_pubkey_create(ctx, &pubkey2, seckey2);
return_val = rustsecp256k1_v0_9_2_ec_pubkey_create(ctx, &pubkey2, seckey2);
assert(return_val);

/* Serialize pubkey1 in a compressed form (33 bytes), should always return 1 */
len = sizeof(compressed_pubkey1);
return_val = rustsecp256k1_v0_9_1_ec_pubkey_serialize(ctx, compressed_pubkey1, &len, &pubkey1, SECP256K1_EC_COMPRESSED);
return_val = rustsecp256k1_v0_9_2_ec_pubkey_serialize(ctx, compressed_pubkey1, &len, &pubkey1, SECP256K1_EC_COMPRESSED);
assert(return_val);
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
assert(len == sizeof(compressed_pubkey1));

/* Serialize pubkey2 in a compressed form (33 bytes) */
len = sizeof(compressed_pubkey2);
return_val = rustsecp256k1_v0_9_1_ec_pubkey_serialize(ctx, compressed_pubkey2, &len, &pubkey2, SECP256K1_EC_COMPRESSED);
return_val = rustsecp256k1_v0_9_2_ec_pubkey_serialize(ctx, compressed_pubkey2, &len, &pubkey2, SECP256K1_EC_COMPRESSED);
assert(return_val);
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
assert(len == sizeof(compressed_pubkey2));
Expand All @@ -80,12 +80,12 @@ int main(void) {

/* Perform ECDH with seckey1 and pubkey2. Should never fail with a verified
* seckey and valid pubkey */
return_val = rustsecp256k1_v0_9_1_ecdh(ctx, shared_secret1, &pubkey2, seckey1, NULL, NULL);
return_val = rustsecp256k1_v0_9_2_ecdh(ctx, shared_secret1, &pubkey2, seckey1, NULL, NULL);
assert(return_val);

/* Perform ECDH with seckey2 and pubkey1. Should never fail with a verified
* seckey and valid pubkey */
return_val = rustsecp256k1_v0_9_1_ecdh(ctx, shared_secret2, &pubkey1, seckey2, NULL, NULL);
return_val = rustsecp256k1_v0_9_2_ecdh(ctx, shared_secret2, &pubkey1, seckey2, NULL, NULL);
assert(return_val);

/* Both parties should end up with the same shared secret */
Expand All @@ -104,7 +104,7 @@ int main(void) {
print_hex(shared_secret1, sizeof(shared_secret1));

/* This will clear everything from the context and free the memory */
rustsecp256k1_v0_9_1_context_destroy(ctx);
rustsecp256k1_v0_9_2_context_destroy(ctx);

/* It's best practice to try to clear secrets from memory after using them.
* This is done because some bugs can allow an attacker to leak memory, for
Expand Down
Loading

0 comments on commit 3373cc9

Please sign in to comment.