mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
d8311688bd Merge bitcoin-core/secp256k1#1515: ci: Note affected clangs in comment on ASLR quirk a85e2233e7 ci: Note affected clangs in comment on ASLR quirk 4b77fec67a Merge bitcoin-core/secp256k1#1512: msan: notate more variable assignments from assembly code f7f0184ba1 msan: notate more variable assignments from assembly code a61339149f change inconsistent array param to pointer 05bfab69ae Merge bitcoin-core/secp256k1#1507: ci: Add workaround for ASLR bug in sanitizers a5e8ab2484 ci: Add sanitizer env variables to debug output 84a93de4d2 ci: Add workaround for ASLR bug in sanitizers 427e86b9ed Merge bitcoin-core/secp256k1#1490: tests: improve fe_sqr test (issue #1472) 2028069df2 doc: clarify input requirements for secp256k1_fe_mul 11420a7a28 tests: improve fe_sqr test cdc9a6258e Merge bitcoin-core/secp256k1#1489: tests: add missing fe comparison checks for inverse field test cases d926510cf7 Merge bitcoin-core/secp256k1#1496: msan: notate variable assignments from assembly code 31ba404944 msan: notate variable assignments from assembly code e7ea32e30a msan: Add SECP256K1_CHECKMEM_MSAN_DEFINE which applies to memory sanitizer and not valgrind e7bdddd9c9 refactor: rename `check_fe_equal` -> `fe_equal` 00111c9c56 tests: add missing fe comparison checks for inverse field test cases 0653a25d50 Merge bitcoin-core/secp256k1#1486: ci: Update cache action 94a14d5290 ci: Update cache action 2483627299 Merge bitcoin-core/secp256k1#1483: cmake: Recommend native CMake commands in README 5ad3aa3dcd Merge bitcoin-core/secp256k1#1484: tests: Drop redundant _scalar_check_overflow calls 51df2d9ab3 tests: Drop redundant _scalar_check_overflow calls 3777e3f36a cmake: Recommend native CMake commands in README e4af41c61b Merge bitcoin-core/secp256k1#1249: cmake: Add `SECP256K1_LATE_CFLAGS` configure option 3bf4d68fc0 Merge bitcoin-core/secp256k1#1482: build: Clean up handling of module dependencies e6822678ea build: Error if required module explicitly off 89ec583ccf build: Clean up handling of module dependencies 44378867a0 Merge bitcoin-core/secp256k1#1468: v0.4.1 release aftermath a9db9f2d75 Merge bitcoin-core/secp256k1#1480: Get rid of untested sizeof(secp256k1_ge_storage) == 64 code path 74b7c3b53e Merge bitcoin-core/secp256k1#1476: include: make docs more consistent b37fdb28ce check-abi: Minor UI improvements ad5f589a94 check-abi: Default to HEAD for new version 9fb7e2f156 release process: Style and formatting nits ba5d72d626 assumptions: Use new STATIC_ASSERT macro e53c2d9ffc Require that sizeof(secp256k1_ge_storage) == 64 d0ba2abbff util: Add STATIC_ASSERT macro da7bc1b803 include: in doc, remove article in front of "pointer" aa3dd5280b include: make doc about ctx more consistent e3f690015a include: remove obvious "cannot be NULL" doc d373bf6d08 Merge bitcoin-core/secp256k1#1474: tests: restore scalar_mul test 79e094517c Merge bitcoin-core/secp256k1#1473: Fix typos 3dbfb48946 tests: restore scalar_mul test d77170a88d Fix typos e7053d065b release process: Add email step 429d21dc79 release process: Run sanity checks on release PR 42f8c51402 cmake: Add `SECP256K1_LATE_CFLAGS` configure option git-subtree-dir: src/secp256k1 git-subtree-split: d8311688bd383d3a923a1b11789cded3cc8e5e03
113 lines
4.5 KiB
C
113 lines
4.5 KiB
C
#ifndef SECP256K1_RECOVERY_H
|
|
#define SECP256K1_RECOVERY_H
|
|
|
|
#include "secp256k1.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/** Opaque data structured 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 {
|
|
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.
|
|
*
|
|
* Returns: 1: public key successfully recovered (which guarantees a correct signature).
|
|
* 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 */
|