mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
![Pieter Wuille](/assets/img/avatar_default.png)
4258c54f4e Merge bitcoin-core/secp256k1#1276: autotools: Don't regenerate Wycheproof header automatically 06c67dea9f autotools: Don't regenerate Wycheproof header automatically 3bab71cf05 Merge bitcoin-core/secp256k1#1268: release cleanup: bump version after 0.3.1 656c6ea8d8 release cleanup: bump version after 0.3.1 346a053d4c Merge bitcoin-core/secp256k1#1269: changelog: Fix link 6a37b2a5ea changelog: Fix link ec98fcedd5 Merge bitcoin-core/secp256k1#1266: release: Prepare for 0.3.1 898e1c676e release: Prepare for 0.3.1 1d9a13fc26 changelog: Remove inconsistent newlines 0e091669a1 changelog: Catch up in preparation of 0.3.1 7b7503dac5 Merge bitcoin-core/secp256k1#1245: tests: Add Wycheproof ECDSA vectors 145078c418 Merge bitcoin-core/secp256k1#1118: Add x-only ecmult_const version with x specified as n/d e5de454609 tests: Add Wycheproof ECDSA vectors 0f8642079b Add exhaustive tests for ecmult_const_xonly 4485926ace Add x-only ecmult_const version for x=n/d a0f4644f7e Merge bitcoin-core/secp256k1#1252: Make position of * in pointer declarations in include/ consistent 4e682626a3 Merge bitcoin-core/secp256k1#1226: Add CMake instructions to release process 2d51a454fc Merge bitcoin-core/secp256k1#1257: ct: Use volatile "trick" in all fe/scalar cmov implementations 4a496a36fb ct: Use volatile "trick" in all fe/scalar cmov implementations 3d1f430f9f Make position of * in pointer declarations in include/ consistent 2bca0a5cbf Merge bitcoin-core/secp256k1#1241: build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro afd8b23b27 Merge bitcoin-core/secp256k1#1244: Suppress `-Wunused-parameter` when building for coverage analysis 1d8f367515 Merge bitcoin-core/secp256k1#1250: No need to subtract 1 before doing a right shift 3e43041be6 No need to subtract 1 before doing a right shift 3addb4c1e8 build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro 0c07c82834 Add CMake instructions to release process 464a9115b4 Merge bitcoin-core/secp256k1#1242: Set ARM ASM symbol visibility to `hidden` f16a709fd6 Merge bitcoin-core/secp256k1#1247: Apply Checks only in VERIFY mode. 70be3cade5 Merge bitcoin-core/secp256k1#1246: Typo 4ebd82852d Apply Checks only in VERIFY mode. d1e7ca192d Typo 5bb03c2911 Replace `SECP256K1_ECMULT_TABLE_VERIFY` macro by a function 9c8c4f443c Merge bitcoin-core/secp256k1#1238: build: bump CMake minimum requirement to 3.13 0cf2fb91ef Merge bitcoin-core/secp256k1#1243: build: Ensure no optimization when building for coverage analysis fd2a408647 Set ARM ASM symbol visibility to `hidden` 4429a8c218 Suppress `-Wunused-parameter` when building for coverage analysis 8e79c7ed11 build: Ensure no optimization when building for coverage analysis 96dd062511 build: bump CMake minimum requirement to 3.13 427bc3cdcf Merge bitcoin-core/secp256k1#1236: Update comment for secp256k1_modinv32_inv256 647f0a5cb1 Update comment for secp256k1_modinv32_inv256 5658209459 Merge bitcoin-core/secp256k1#1228: release cleanup: bump version after 0.3.0 28e63f7ea7 release cleanup: bump version after 0.3.0 git-subtree-dir: src/secp256k1 git-subtree-split: 4258c54f4ebfc09390168e8a43306c46b315134b
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: a secp256k1 context object
|
|
* Out: sig: a pointer to a signature object
|
|
* In: input64: a 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: a secp256k1 context object.
|
|
* Out: sig: a pointer to a normal signature.
|
|
* In: sigin: a 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: a secp256k1 context object.
|
|
* Out: output64: a pointer to a 64-byte array of the compact signature.
|
|
* recid: a pointer to an integer to hold the recovery id.
|
|
* In: sig: a 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 */
|