Skip to content

Commit bf90997

Browse files
chore(deps): update subtree secp256k1-zkp to 56751a4c (#1010)
* chore: clean stale extractions for secp256k1-zkp * Squashed 'Vendor/secp256k1-zkp/' changes from 42ae776d..56751a4c 56751a4c Merge BlockstreamResearch/secp256k1-zkp#331: Upstream PRs 1735, 1745, 1741, 1749, 1748, 1727, 1756, 1750, 1719, 1734, 1759, 1758 7111d365 modules, tests: Port bitcoin-core/secp256k1#1734 to zkp-specific code 7699fe9a modules: Port bitcoin-core/secp256k1#1735 to zkp-specific code f1e52fac Merge commits '88be4e8d b4756543 10dab907 58178851 de6af6ae baa26542 2b7337f6 a44a3393 f44c1ebd d543c0d9 43e7b115 7a2fff85 ' into temp-merge-1758 7a2fff85 Merge bitcoin-core/secp256k1#1758: ci: Drop workaround for Valgrind older than 3.20.0 43e7b115 Merge bitcoin-core/secp256k1#1759: ci: Switch to macOS 15 Sequoia Intel-based image 8bc50b72 ci: Switch to macOS 15 Sequoia Intel-based image c09519f0 ci: Drop workaround for Valgrind older than 3.20.0 d543c0d9 Merge bitcoin-core/secp256k1#1734: Introduce (mini) unit test framework f44c1ebd Merge bitcoin-core/secp256k1#1719: ci: DRY workflow using anchors a44a3393 Merge bitcoin-core/secp256k1#1750: ci: Use clang-snapshot in "MSan" job 15d01480 ci: Drop default for `inputs.command` in `run-in-docker-action` 1decc49a ci: Use YAML anchor and aliases for repeated "CI script" steps dff1bc10 ci, refactor: Generalize use of `matrix.configuration.env_vars` 4b644da1 ci: Use YAML anchor and aliases for repeated "Print logs" steps a889cd93 ci: Bump `actions/checkout` version 574c2f30 ci: Use YAML anchor and aliases for repeated "Checkout" steps 53585f93 ci: Use clang-snapshot in "MSan" job 6894c964 Fix Clang 21+ `-Wuninitialized-const-pointer` warning when using MSan 2b7337f6 Merge bitcoin-core/secp256k1#1756: ci: Fix image caching and apply other improvements f163c358 ci: Set `DEBIAN_FRONTEND=noninteractive` 70ae177c ci: Bump `docker/build-push-action` version b2a95a42 ci: Drop `tags` input for `docker/build-push-action` 122014ed ci: Add `scope` parameter to `cache-{to,from}` options 2f4546ce test: add --log option to display tests execution 95b9953e test: Add option to display all available tests 953f7b00 test: support running specific tests/modules targets 0302c1a3 test: add --help for command-line options 9ec3bfe2 test: adapt modules to the new test infrastructure 48789daf test: introduce (mini) unit test framework baa26542 Merge bitcoin-core/secp256k1#1727: docs: Clarify that callback can be called more than once 4d90585f docs: Improve API docs of _context_set_illegal_callback 895f53d1 docs: Clarify that callback can be called more than once de6af6ae Merge bitcoin-core/secp256k1#1748: bench: improve context creation in ECDH benchmark 58178851 Merge bitcoin-core/secp256k1#1749: build: Fix warnings in x86_64 assembly check ab560078 build: Fix warnings in x86_64 assembly check 10dab907 Merge bitcoin-core/secp256k1#1741: doc: clarify API doc of `secp256k1_ecdsa_recover` return value dfe284ed bench: improve context creation in ECDH benchmark 7321bdf2 doc: clarify API doc of `secp256k1_ecdsa_recover` return value b4756543 Merge bitcoin-core/secp256k1#1745: test: introduce group order byte-array constant for deduplication 9cce7038 refactor: move 'gettime_i64()' to tests_common.h 0c91c560 test: introduce group order byte-array constant for deduplication 88be4e8d Merge bitcoin-core/secp256k1#1735: musig: Invalidate secnonce in secp256k1_musig_partial_sign 399b582a Split memclear into two versions git-subtree-dir: Vendor/secp256k1-zkp git-subtree-split: 56751a4cf069b48ec8562b81dedff7e306679d59 * chore(deps): update subtree secp256k1-zkp to 56751a4c --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a4d9282 commit bf90997

71 files changed

Lines changed: 1394 additions & 751 deletions

Some content is hidden

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

Sources/libsecp256k1_zkp/include/secp256k1.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ SECP256K1_DEPRECATED("Use secp256k1_context_static instead");
261261
* secp256k1_context_create (or secp256k1_context_preallocated_create), which will
262262
* take care of performing the self tests.
263263
*
264-
* If the tests fail, this function will call the default error handler to abort the
264+
* If the tests fail, this function will call the default error callback to abort the
265265
* program (see secp256k1_context_set_error_callback).
266266
*/
267267
SECP256K1_API void secp256k1_selftest(void);
@@ -334,36 +334,37 @@ SECP256K1_API void secp256k1_context_destroy(
334334
* an API call. It will only trigger for violations that are mentioned
335335
* explicitly in the header.
336336
*
337-
* The philosophy is that these shouldn't be dealt with through a
338-
* specific return value, as calling code should not have branches to deal with
339-
* the case that this code itself is broken.
337+
* The philosophy is that these shouldn't be dealt with through a specific
338+
* return value, as calling code should not have branches to deal with the case
339+
* that this code itself is broken.
340340
*
341341
* On the other hand, during debug stage, one would want to be informed about
342-
* such mistakes, and the default (crashing) may be inadvisable.
343-
* When this callback is triggered, the API function called is guaranteed not
344-
* to cause a crash, though its return value and output arguments are
345-
* undefined.
346-
*
347-
* When this function has not been called (or called with fn==NULL), then the
348-
* default handler will be used. The library provides a default handler which
349-
* writes the message to stderr and calls abort. This default handler can be
342+
* such mistakes, and the default (crashing) may be inadvisable. Should this
343+
* callback return instead of crashing, the return value and output arguments
344+
* of the API function call are undefined. Moreover, the same API call may
345+
* trigger the callback again in this case.
346+
*
347+
* When this function has not been called (or called with fun==NULL), then the
348+
* default callback will be used. The library provides a default callback which
349+
* writes the message to stderr and calls abort. This default callback can be
350350
* replaced at link time if the preprocessor macro
351351
* USE_EXTERNAL_DEFAULT_CALLBACKS is defined, which is the case if the build
352352
* has been configured with --enable-external-default-callbacks. Then the
353353
* following two symbols must be provided to link against:
354354
* - void secp256k1_default_illegal_callback_fn(const char *message, void *data);
355355
* - void secp256k1_default_error_callback_fn(const char *message, void *data);
356-
* The library can call these default handlers even before a proper callback data
356+
* The library may call a default callback even before a proper callback data
357357
* pointer could have been set using secp256k1_context_set_illegal_callback or
358358
* secp256k1_context_set_error_callback, e.g., when the creation of a context
359-
* fails. In this case, the corresponding default handler will be called with
359+
* fails. In this case, the corresponding default callback will be called with
360360
* the data pointer argument set to NULL.
361361
*
362362
* Args: ctx: pointer to a context object.
363363
* In: fun: pointer to a function to call when an illegal argument is
364364
* passed to the API, taking a message and an opaque pointer.
365-
* (NULL restores the default handler.)
366-
* data: the opaque pointer to pass to fun above, must be NULL for the default handler.
365+
* (NULL restores the default callback.)
366+
* data: the opaque pointer to pass to fun above, must be NULL for the
367+
* default callback.
367368
*
368369
* See also secp256k1_context_set_error_callback.
369370
*/
@@ -380,18 +381,19 @@ SECP256K1_API void secp256k1_context_set_illegal_callback(
380381
* to abort the program.
381382
*
382383
* This can only trigger in case of a hardware failure, miscompilation,
383-
* memory corruption, serious bug in the library, or other error would can
384-
* otherwise result in undefined behaviour. It will not trigger due to mere
384+
* memory corruption, serious bug in the library, or other error that would
385+
* result in undefined behaviour. It will not trigger due to mere
385386
* incorrect usage of the API (see secp256k1_context_set_illegal_callback
386387
* for that). After this callback returns, anything may happen, including
387388
* crashing.
388389
*
389390
* Args: ctx: pointer to a context object.
390391
* In: fun: pointer to a function to call when an internal error occurs,
391392
* taking a message and an opaque pointer (NULL restores the
392-
* default handler, see secp256k1_context_set_illegal_callback
393+
* default callback, see secp256k1_context_set_illegal_callback
393394
* for details).
394-
* data: the opaque pointer to pass to fun above, must be NULL for the default handler.
395+
* data: the opaque pointer to pass to fun above, must be NULL for the
396+
* default callback.
395397
*
396398
* See also secp256k1_context_set_illegal_callback.
397399
*/

Sources/libsecp256k1_zkp/include/secp256k1_recovery.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ SECP256K1_API int secp256k1_ecdsa_sign_recoverable(
9292

9393
/** Recover an ECDSA public key from a signature.
9494
*
95-
* Returns: 1: public key successfully recovered (which guarantees a correct signature).
95+
* Successful public key recovery guarantees that the signature, after normalization,
96+
* passes `secp256k1_ecdsa_verify`. Thus, explicit verification is not necessary.
97+
*
98+
* However, a recoverable signature that successfully passes `secp256k1_ecdsa_recover`,
99+
* when converted to a non-recoverable signature (using
100+
* `secp256k1_ecdsa_recoverable_signature_convert`), is not guaranteed to be
101+
* normalized and thus not guaranteed to pass `secp256k1_ecdsa_verify`. If a
102+
* normalized signature is required, call `secp256k1_ecdsa_signature_normalize`
103+
* after `secp256k1_ecdsa_recoverable_signature_convert`.
104+
*
105+
* Returns: 1: public key successfully recovered
96106
* 0: otherwise.
97107
* Args: ctx: pointer to a context object.
98108
* Out: pubkey: pointer to the recovered public key.

Sources/libsecp256k1_zkp/src/checkmem.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@
4848
# if __has_feature(memory_sanitizer)
4949
# include <sanitizer/msan_interface.h>
5050
# define SECP256K1_CHECKMEM_ENABLED 1
51-
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) __msan_allocated_memory((p), (len))
51+
# if defined(__clang__) && ((__clang_major__ == 21 && __clang_minor__ >= 1) || __clang_major__ >= 22)
52+
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) do { \
53+
/* Work around https://github.com/llvm/llvm-project/issues/160094 */ \
54+
_Pragma("clang diagnostic push") \
55+
_Pragma("clang diagnostic ignored \"-Wuninitialized-const-pointer\"") \
56+
__msan_allocated_memory((p), (len)); \
57+
_Pragma("clang diagnostic pop") \
58+
} while(0)
59+
# else
60+
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) __msan_allocated_memory((p), (len))
61+
# endif
5262
# define SECP256K1_CHECKMEM_DEFINE(p, len) __msan_unpoison((p), (len))
5363
# define SECP256K1_CHECKMEM_MSAN_DEFINE(p, len) __msan_unpoison((p), (len))
5464
# define SECP256K1_CHECKMEM_CHECK(p, len) __msan_check_mem_is_initialized((p), (len))

Sources/libsecp256k1_zkp/src/ecmult_gen_impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp25
277277
/* Cleanup. */
278278
secp256k1_fe_clear(&neg);
279279
secp256k1_ge_clear(&add);
280-
secp256k1_memclear(&adds, sizeof(adds));
281-
secp256k1_memclear(&recoded, sizeof(recoded));
280+
secp256k1_memclear_explicit(&adds, sizeof(adds));
281+
secp256k1_memclear_explicit(&recoded, sizeof(recoded));
282282
}
283283

284284
/* Setup blinding values for secp256k1_ecmult_gen. */
@@ -310,7 +310,7 @@ static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const
310310
VERIFY_CHECK(seed32 != NULL);
311311
memcpy(keydata + 32, seed32, 32);
312312
secp256k1_rfc6979_hmac_sha256_initialize(&rng, keydata, 64);
313-
secp256k1_memclear(keydata, sizeof(keydata));
313+
secp256k1_memclear_explicit(keydata, sizeof(keydata));
314314

315315
/* Compute projective blinding factor (cannot be 0). */
316316
secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32);
@@ -331,7 +331,7 @@ static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const
331331
secp256k1_ge_set_gej(&ctx->ge_offset, &gb);
332332

333333
/* Clean up. */
334-
secp256k1_memclear(nonce32, sizeof(nonce32));
334+
secp256k1_memclear_explicit(nonce32, sizeof(nonce32));
335335
secp256k1_scalar_clear(&b);
336336
secp256k1_gej_clear(&gb);
337337
secp256k1_fe_clear(&f);

Sources/libsecp256k1_zkp/src/field_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#endif
2020

2121
SECP256K1_INLINE static void secp256k1_fe_clear(secp256k1_fe *a) {
22-
secp256k1_memclear(a, sizeof(secp256k1_fe));
22+
secp256k1_memclear_explicit(a, sizeof(secp256k1_fe));
2323
}
2424

2525
SECP256K1_INLINE static int secp256k1_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b) {

Sources/libsecp256k1_zkp/src/group_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ static void secp256k1_ge_set_infinity(secp256k1_ge *r) {
337337
}
338338

339339
static void secp256k1_gej_clear(secp256k1_gej *r) {
340-
secp256k1_memclear(r, sizeof(secp256k1_gej));
340+
secp256k1_memclear_explicit(r, sizeof(secp256k1_gej));
341341
}
342342

343343
static void secp256k1_ge_clear(secp256k1_ge *r) {
344-
secp256k1_memclear(r, sizeof(secp256k1_ge));
344+
secp256k1_memclear_explicit(r, sizeof(secp256k1_ge));
345345
}
346346

347347
static int secp256k1_ge_set_xquad(secp256k1_ge *r, const secp256k1_fe *x) {

Sources/libsecp256k1_zkp/src/hash_impl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void secp256k1_sha256_initialize_tagged(secp256k1_sha256 *hash, const uns
172172
}
173173

174174
static void secp256k1_sha256_clear(secp256k1_sha256 *hash) {
175-
secp256k1_memclear(hash, sizeof(*hash));
175+
secp256k1_memclear_explicit(hash, sizeof(*hash));
176176
}
177177

178178
static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256 *hash, const unsigned char *key, size_t keylen) {
@@ -200,7 +200,7 @@ static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256 *hash, const
200200
rkey[n] ^= 0x5c ^ 0x36;
201201
}
202202
secp256k1_sha256_write(&hash->inner, rkey, sizeof(rkey));
203-
secp256k1_memclear(rkey, sizeof(rkey));
203+
secp256k1_memclear_explicit(rkey, sizeof(rkey));
204204
}
205205

206206
static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256 *hash, const unsigned char *data, size_t size) {
@@ -211,12 +211,12 @@ static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256 *hash, unsigned
211211
unsigned char temp[32];
212212
secp256k1_sha256_finalize(&hash->inner, temp);
213213
secp256k1_sha256_write(&hash->outer, temp, 32);
214-
secp256k1_memclear(temp, sizeof(temp));
214+
secp256k1_memclear_explicit(temp, sizeof(temp));
215215
secp256k1_sha256_finalize(&hash->outer, out32);
216216
}
217217

218218
static void secp256k1_hmac_sha256_clear(secp256k1_hmac_sha256 *hash) {
219-
secp256k1_memclear(hash, sizeof(*hash));
219+
secp256k1_memclear_explicit(hash, sizeof(*hash));
220220
}
221221

222222
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256 *rng, const unsigned char *key, size_t keylen) {
@@ -285,7 +285,7 @@ static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256
285285
}
286286

287287
static void secp256k1_rfc6979_hmac_sha256_clear(secp256k1_rfc6979_hmac_sha256 *rng) {
288-
secp256k1_memclear(rng, sizeof(*rng));
288+
secp256k1_memclear_explicit(rng, sizeof(*rng));
289289
}
290290

291291
#undef Round

Sources/libsecp256k1_zkp/src/modules/ecdh/main_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *output, const se
6262

6363
ret = hashfp(output, x, y, data);
6464

65-
secp256k1_memclear(x, sizeof(x));
66-
secp256k1_memclear(y, sizeof(y));
65+
secp256k1_memclear_explicit(x, sizeof(x));
66+
secp256k1_memclear_explicit(y, sizeof(y));
6767
secp256k1_scalar_clear(&s);
6868
secp256k1_ge_clear(&pt);
6969
secp256k1_gej_clear(&res);

Sources/libsecp256k1_zkp/src/modules/ecdsa_s2c/main_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ int secp256k1_ecdsa_anti_exfil_signer_commit(const secp256k1_context* ctx, secp2
182182
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &rj, &k);
183183
secp256k1_ge_set_gej(&r, &rj);
184184
secp256k1_ecdsa_s2c_opening_save(opening, &r);
185-
secp256k1_memclear(nonce32, 32);
185+
secp256k1_memclear_explicit(nonce32, 32);
186186
secp256k1_scalar_clear(&k);
187187
return 1;
188188
}

Sources/libsecp256k1_zkp/src/modules/ellswift/main_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ int secp256k1_ellswift_xdh(const secp256k1_context *ctx, unsigned char *output,
582582
/* Invoke hasher */
583583
ret = hashfp(output, sx, ell_a64, ell_b64, data);
584584

585-
secp256k1_memclear(sx, sizeof(sx));
585+
secp256k1_memclear_explicit(sx, sizeof(sx));
586586
secp256k1_fe_clear(&px);
587587
secp256k1_scalar_clear(&s);
588588

0 commit comments

Comments
 (0)