mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-21 12:18:13 +02:00
d543c0d917 Merge bitcoin-core/secp256k1#1734: Introduce (mini) unit test framework f44c1ebd96 Merge bitcoin-core/secp256k1#1719: ci: DRY workflow using anchors a44a339384 Merge bitcoin-core/secp256k1#1750: ci: Use clang-snapshot in "MSan" job 15d014804e ci: Drop default for `inputs.command` in `run-in-docker-action` 1decc49a1f ci: Use YAML anchor and aliases for repeated "CI script" steps dff1bc107d ci, refactor: Generalize use of `matrix.configuration.env_vars` 4b644da199 ci: Use YAML anchor and aliases for repeated "Print logs" steps a889cd93df ci: Bump `actions/checkout` version 574c2f3080 ci: Use YAML anchor and aliases for repeated "Checkout" steps 53585f93b7 ci: Use clang-snapshot in "MSan" job 6894c964f3 Fix Clang 21+ `-Wuninitialized-const-pointer` warning when using MSan 2b7337f63a Merge bitcoin-core/secp256k1#1756: ci: Fix image caching and apply other improvements f163c35897 ci: Set `DEBIAN_FRONTEND=noninteractive` 70ae177ca0 ci: Bump `docker/build-push-action` version b2a95a420f ci: Drop `tags` input for `docker/build-push-action` 122014edb3 ci: Add `scope` parameter to `cache-{to,from}` options 2f4546ce56 test: add --log option to display tests execution 95b9953ea4 test: Add option to display all available tests 953f7b0088 test: support running specific tests/modules targets 0302c1a3d7 test: add --help for command-line options 9ec3bfe22d test: adapt modules to the new test infrastructure 48789dafc2 test: introduce (mini) unit test framework baa265429f Merge bitcoin-core/secp256k1#1727: docs: Clarify that callback can be called more than once 4d90585fea docs: Improve API docs of _context_set_illegal_callback 895f53d1cf docs: Clarify that callback can be called more than once de6af6ae35 Merge bitcoin-core/secp256k1#1748: bench: improve context creation in ECDH benchmark 5817885153 Merge bitcoin-core/secp256k1#1749: build: Fix warnings in x86_64 assembly check ab560078aa build: Fix warnings in x86_64 assembly check 10dab907e7 Merge bitcoin-core/secp256k1#1741: doc: clarify API doc of `secp256k1_ecdsa_recover` return value dfe284ed2d bench: improve context creation in ECDH benchmark 7321bdf27b doc: clarify API doc of `secp256k1_ecdsa_recover` return value b475654302 Merge bitcoin-core/secp256k1#1745: test: introduce group order byte-array constant for deduplication 9cce703863 refactor: move 'gettime_i64()' to tests_common.h 0c91c56041 test: introduce group order byte-array constant for deduplication 88be4e8d86 Merge bitcoin-core/secp256k1#1735: musig: Invalidate secnonce in secp256k1_musig_partial_sign 36e76952cb Merge bitcoin-core/secp256k1#1738: check-abi: remove support for obsolete CMake library output location (src/libsecp256k1.so) 399b582a5f Split memclear into two versions 4985ac0f89 Merge bitcoin-core/secp256k1#1737: doc: mention ctx requirement for `_ellswift_create` (not secp256k1_context_static) 7ebaa134a7 check-abi: remove support for obsolete CMake library output location (src/libsecp256k1.so) 806de38bfc doc: mention ctx requirement for `_ellswift_create` (not secp256k1_context_static) 03fb60ad2e Merge bitcoin-core/secp256k1#1681: doc: Recommend clang-cl when building on Windows d93380fb35 Merge bitcoin-core/secp256k1#1731: schnorrsig: Securely clear buf containing k or its negation 8113671f80 Merge bitcoin-core/secp256k1#1729: hash: Use size_t instead of int for RFC6979 outlen copy 325d65a8cf Rename and clear var containing k or -k 960ba5f9c6 Use size_t instead of int for RFC6979 outlen copy 737912430d ci: Add more tests for clang-cl 7379a5bed3 doc: Recommend clang-cl when building on Windows f36afb8b3d Merge bitcoin-core/secp256k1#1725: tests: refactor tagged hash verification 5153cf1c91 tests: refactor tagged hash tests d2dcf52091 Merge bitcoin-core/secp256k1#1726: docs: fix broken link to Tromer's cache.pdf paper 489a43d1bf docs: fix broken link to eprint cache.pdf paper d599714147 Merge bitcoin-core/secp256k1#1722: docs: Exclude modules' `bench_impl.h` headers from coverage report 0458def51e doc: Add `--gcov-ignore-parse-errors=all` option to `gcovr` invocations 1aecce5936 doc: Add `--merge-mode-functions=separate` option to `gcovr` invocations 106a7cbf41 doc: Exclude modules' `bench_impl.h` headers from coverage report a9e955d3ea autotools, docs: Adjust help string for `--enable-coverage` option e523e4f90e Merge bitcoin-core/secp256k1#1720: chore(ci): Fix typo in Dockerfile comment 24ba8ff168 chore(ci): Fix typo in Dockerfile comment 74b8068c5d Merge bitcoin-core/secp256k1#1717: test: update wycheproof test vectors c25c3c8a88 test: update wycheproof test vectors 20e3b44746 Merge bitcoin-core/secp256k1#1688: cmake: Avoid contaminating parent project's cache with `BUILD_SHARED_LIBS` 2c076d907a Merge bitcoin-core/secp256k1#1711: tests: update Wycheproof 7b07b22957 cmake: Avoid contaminating parent project's cache with BUILD_SHARED_LIBS 5433648ca0 Fix typos and spellings 9ea54c69b7 tests: update Wycheproof files git-subtree-dir: src/secp256k1 git-subtree-split: d543c0d917a76a201578948701cc30ef336e0fe6
124 lines
5.1 KiB
C
124 lines
5.1 KiB
C
#ifndef SECP256K1_RECOVERY_H
|
|
#define SECP256K1_RECOVERY_H
|
|
|
|
#include "secp256k1.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/** Opaque data structure that holds a parsed ECDSA signature,
|
|
* supporting pubkey recovery.
|
|
*
|
|
* The exact representation of data inside is implementation defined and not
|
|
* guaranteed to be portable between different platforms or versions. It is
|
|
* however guaranteed to be 65 bytes in size, and can be safely copied/moved.
|
|
* If you need to convert to a format suitable for storage or transmission, use
|
|
* the secp256k1_ecdsa_signature_serialize_* and
|
|
* secp256k1_ecdsa_signature_parse_* functions.
|
|
*
|
|
* Furthermore, it is guaranteed that identical signatures (including their
|
|
* recoverability) will have identical representation, so they can be
|
|
* memcmp'ed.
|
|
*/
|
|
typedef struct secp256k1_ecdsa_recoverable_signature {
|
|
unsigned char data[65];
|
|
} secp256k1_ecdsa_recoverable_signature;
|
|
|
|
/** Parse a compact ECDSA signature (64 bytes + recovery id).
|
|
*
|
|
* Returns: 1 when the signature could be parsed, 0 otherwise
|
|
* Args: ctx: pointer to a context object
|
|
* Out: sig: pointer to a signature object
|
|
* In: input64: pointer to a 64-byte compact signature
|
|
* recid: the recovery id (0, 1, 2 or 3)
|
|
*/
|
|
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_parse_compact(
|
|
const secp256k1_context *ctx,
|
|
secp256k1_ecdsa_recoverable_signature *sig,
|
|
const unsigned char *input64,
|
|
int recid
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
|
|
|
|
/** Convert a recoverable signature into a normal signature.
|
|
*
|
|
* Returns: 1
|
|
* Args: ctx: pointer to a context object.
|
|
* Out: sig: pointer to a normal signature.
|
|
* In: sigin: pointer to a recoverable signature.
|
|
*/
|
|
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_convert(
|
|
const secp256k1_context *ctx,
|
|
secp256k1_ecdsa_signature *sig,
|
|
const secp256k1_ecdsa_recoverable_signature *sigin
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
|
|
|
|
/** Serialize an ECDSA signature in compact format (64 bytes + recovery id).
|
|
*
|
|
* Returns: 1
|
|
* Args: ctx: pointer to a context object.
|
|
* Out: output64: pointer to a 64-byte array of the compact signature.
|
|
* recid: pointer to an integer to hold the recovery id.
|
|
* In: sig: pointer to an initialized signature object.
|
|
*/
|
|
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_serialize_compact(
|
|
const secp256k1_context *ctx,
|
|
unsigned char *output64,
|
|
int *recid,
|
|
const secp256k1_ecdsa_recoverable_signature *sig
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
|
|
|
|
/** Create a recoverable ECDSA signature.
|
|
*
|
|
* Returns: 1: signature created
|
|
* 0: the nonce generation function failed, or the secret key was invalid.
|
|
* Args: ctx: pointer to a context object (not secp256k1_context_static).
|
|
* Out: sig: pointer to an array where the signature will be placed.
|
|
* In: msghash32: the 32-byte message hash being signed.
|
|
* seckey: pointer to a 32-byte secret key.
|
|
* noncefp: pointer to a nonce generation function. If NULL,
|
|
* secp256k1_nonce_function_default is used.
|
|
* ndata: pointer to arbitrary data used by the nonce generation function
|
|
* (can be NULL for secp256k1_nonce_function_default).
|
|
*/
|
|
SECP256K1_API int secp256k1_ecdsa_sign_recoverable(
|
|
const secp256k1_context *ctx,
|
|
secp256k1_ecdsa_recoverable_signature *sig,
|
|
const unsigned char *msghash32,
|
|
const unsigned char *seckey,
|
|
secp256k1_nonce_function noncefp,
|
|
const void *ndata
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
|
|
|
|
/** Recover an ECDSA public key from a signature.
|
|
*
|
|
* Successful public key recovery guarantees that the signature, after normalization,
|
|
* passes `secp256k1_ecdsa_verify`. Thus, explicit verification is not necessary.
|
|
*
|
|
* However, a recoverable signature that successfully passes `secp256k1_ecdsa_recover`,
|
|
* when converted to a non-recoverable signature (using
|
|
* `secp256k1_ecdsa_recoverable_signature_convert`), is not guaranteed to be
|
|
* normalized and thus not guaranteed to pass `secp256k1_ecdsa_verify`. If a
|
|
* normalized signature is required, call `secp256k1_ecdsa_signature_normalize`
|
|
* after `secp256k1_ecdsa_recoverable_signature_convert`.
|
|
*
|
|
* Returns: 1: public key successfully recovered
|
|
* 0: otherwise.
|
|
* Args: ctx: pointer to a context object.
|
|
* Out: pubkey: pointer to the recovered public key.
|
|
* In: sig: pointer to initialized signature that supports pubkey recovery.
|
|
* msghash32: the 32-byte message hash assumed to be signed.
|
|
*/
|
|
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover(
|
|
const secp256k1_context *ctx,
|
|
secp256k1_pubkey *pubkey,
|
|
const secp256k1_ecdsa_recoverable_signature *sig,
|
|
const unsigned char *msghash32
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SECP256K1_RECOVERY_H */
|