mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-09 08:43:04 +01:00
Squashed 'src/secp256k1/' changes from 6c527ec..8225239
8225239Merge #433: Make the libcrypto detection fail the newer API.12de863Make the libcrypto detection fail the newer API.2928420Merge #427: Remove Schnorr from travis as well8eecc4aRemove Schnorr from travis as wella8abae7Merge #310: Add exhaustive test for group functions on a low-order subgroupb4ceedfAdd exhaustive test for verification83836a9Add exhaustive tests for group arithmetic, signing, and ecmult on a small group20b8877Add exhaustive test for group functions on a low-order subgroup80773a6Merge #425: Remove Schnorr experimente06e878Remove Schnorr experiment04c8ef3Merge #407: Modify parameter order of internal functions to match API parameter order6e06696Merge #411: Remove guarantees about memcmp-ability40c8d7eMerge #421: Update scalar_4x64_impl.ha922365Merge #422: Restructure nonce clearing3769783Restructure nonce clearing0f9e69dRestructure nonce clearing9d67afaUpdate scalar_4x64_impl.h7d15cd7Merge #413: fix auto-enabled static precompuatation00c5d2efix auto-enabled static precompuatation91219a1Remove guarantees about memcmp-ability7a49cacMerge #410: Add string.h include to ecmult_impl0bbd5d4Add string.h include to ecmult_impl353c1bfFix secp256k1_ge_set_table_gej_var parameter order541b783Fix secp256k1_ge_set_all_gej_var parameter order7d893f4Fix secp256k1_fe_inv_all_var parameter orderc5b32e1Merge #405: Make secp256k1_fe_sqrt constant time926836aMake secp256k1_fe_sqrt constant timee2a8e92Merge #404: Replace 3M + 4S doubling formula with 2M + 5S one8ec49d8Add note about 2M + 5S doubling formula5a91bd7Merge #400: A couple minor cleanupsac01378build: add -DSECP256K1_BUILD to benchmark_internal build flagsa6c6f99Remove a bunch of unused stdlib #includes65285a6Merge #403: configure: add flag to disable OpenSSL testsa9b2a5dconfigure: add flag to disable OpenSSL testsb340123Merge #402: Add support for testing quadratic residuese6e9805Add function for testing quadratic residue field/group elements.efd953aAdd Jacobi symbol test via GMPfa36a0dMerge #401: ecmult_const: unify endomorphism and non-endomorphism skew casesc6191fdecmult_const: unify endomorphism and non-endomorphism skew cases0b3e618Merge #378: .gitignore build-aux cleanup6042217Merge #384: JNI: align shared files copyright/comments to bitcoinj's24ad20fMerge #399: build: verify that the native compiler works for static precompb3be852Merge #398: Test whether ECDH and Schnorr are enabled for JNIaa0b1fdbuild: verify that the native compiler works for static precompeee808dTest whether ECDH and Schnorr are enabled for JNI7b0fb18Merge #366: ARM assembly implementation of field_10x26 inner (rebase of #173)001f176ARM assembly implementation of field_10x26 inner0172be9Merge #397: Small fixes for sha2563f8b78eFix undefs in hash_impl.h2ab4695Fix state size in sha256 struct6875b01Merge #386: Add some missing `VERIFY_CHECK(ctx != NULL)`2c52b5dMerge #389: Cast pointers through uintptr_t under JNI43097a4Merge #390: Update bitcoin-core GitHub links31c9c12Merge #391: JNI: Only call ecdsa_verify if its inputs parsed correctly1cb2302Merge #392: Add testcase which hits additional branch in secp256k1_scalar_sqrd2ee340Merge #388: bench_ecdh: fix call to secp256k1_context_create093a497Add testcase which hits additional branch in secp256k1_scalar_sqra40c701JNI: Only call ecdsa_verify if its inputs parsed correctlyfaa2a11Update bitcoin-core GitHub links47b9e78Cast pointers through uintptr_t under JNIf36f9c6bench_ecdh: fix call to secp256k1_context_createbcc4881Add some missing `VERIFY_CHECK(ctx != NULL)` for functions that use `ARG_CHECK`6ceea2calign shared files copyright/comments to bitcoinj's70141a8Update .gitignore7b549b1Merge #373: build: fix x86_64 asm detection for some compilersbc7c93cMerge #374: Add note about y=0 being possible on one of the sextic twistse457018Merge #364: JNI rebased86e2d07JNI library: cleanup, removed unimplemented code3093576aJNI librarybd2895fMerge pull request #371e72e93aAdd note about y=0 being possible on one of the sextic twists3f8fdfbbuild: fix x86_64 asm detection for some compilerse5a9047[Trivial] Remove double semicolonsc18b869Merge pull request #3603026daaMerge pull request #30203d4611Add sage verification script for the group lawsa965937Merge pull request #36183221ecAdd experimental features to configure5d4c5a3Prevent damage_array in the signature test from going out of bounds.419bf7fMerge pull request #35603d84a4Benchmark against OpenSSL verification git-subtree-dir: src/secp256k1 git-subtree-split:8225239f49
This commit is contained in:
@@ -47,11 +47,8 @@ typedef struct secp256k1_context_struct secp256k1_context;
|
||||
* 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 64 bytes in size, and can be safely copied/moved.
|
||||
* If you need to convert to a format suitable for storage or transmission, use
|
||||
* secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse.
|
||||
*
|
||||
* Furthermore, it is guaranteed that identical public keys (ignoring
|
||||
* compression) will have identical representation, so they can be memcmp'ed.
|
||||
* If you need to convert to a format suitable for storage, transmission, or
|
||||
* comparison, use secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char data[64];
|
||||
@@ -62,12 +59,9 @@ typedef struct {
|
||||
* 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 64 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
|
||||
* If you need to convert to a format suitable for storage, transmission, or
|
||||
* comparison, use the secp256k1_ecdsa_signature_serialize_* and
|
||||
* secp256k1_ecdsa_signature_serialize_* functions.
|
||||
*
|
||||
* Furthermore, it is guaranteed to identical signatures will have identical
|
||||
* representation, so they can be memcmp'ed.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char data[64];
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
#ifndef _SECP256K1_SCHNORR_
|
||||
# define _SECP256K1_SCHNORR_
|
||||
|
||||
# include "secp256k1.h"
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/** Create a signature using a custom EC-Schnorr-SHA256 construction. It
|
||||
* produces non-malleable 64-byte signatures which support public key recovery
|
||||
* batch validation, and multiparty signing.
|
||||
* Returns: 1: signature created
|
||||
* 0: the nonce generation function failed, or the private key was
|
||||
* invalid.
|
||||
* Args: ctx: pointer to a context object, initialized for signing
|
||||
* (cannot be NULL)
|
||||
* Out: sig64: pointer to a 64-byte array where the signature will be
|
||||
* placed (cannot be NULL)
|
||||
* In: msg32: the 32-byte message hash being signed (cannot be NULL)
|
||||
* seckey: pointer to a 32-byte secret key (cannot be NULL)
|
||||
* 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)
|
||||
*/
|
||||
SECP256K1_API int secp256k1_schnorr_sign(
|
||||
const secp256k1_context* ctx,
|
||||
unsigned char *sig64,
|
||||
const unsigned char *msg32,
|
||||
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);
|
||||
|
||||
/** Verify a signature created by secp256k1_schnorr_sign.
|
||||
* Returns: 1: correct signature
|
||||
* 0: incorrect signature
|
||||
* Args: ctx: a secp256k1 context object, initialized for verification.
|
||||
* In: sig64: the 64-byte signature being verified (cannot be NULL)
|
||||
* msg32: the 32-byte message hash being verified (cannot be NULL)
|
||||
* pubkey: the public key to verify with (cannot be NULL)
|
||||
*/
|
||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_verify(
|
||||
const secp256k1_context* ctx,
|
||||
const unsigned char *sig64,
|
||||
const unsigned char *msg32,
|
||||
const secp256k1_pubkey *pubkey
|
||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
|
||||
|
||||
/** Recover an EC public key from a Schnorr signature created using
|
||||
* secp256k1_schnorr_sign.
|
||||
* Returns: 1: public key successfully recovered (which guarantees a correct
|
||||
* signature).
|
||||
* 0: otherwise.
|
||||
* Args: ctx: pointer to a context object, initialized for
|
||||
* verification (cannot be NULL)
|
||||
* Out: pubkey: pointer to a pubkey to set to the recovered public key
|
||||
* (cannot be NULL).
|
||||
* In: sig64: signature as 64 byte array (cannot be NULL)
|
||||
* msg32: the 32-byte message hash assumed to be signed (cannot
|
||||
* be NULL)
|
||||
*/
|
||||
SECP256K1_API int secp256k1_schnorr_recover(
|
||||
const secp256k1_context* ctx,
|
||||
secp256k1_pubkey *pubkey,
|
||||
const unsigned char *sig64,
|
||||
const unsigned char *msg32
|
||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
|
||||
|
||||
/** Generate a nonce pair deterministically for use with
|
||||
* secp256k1_schnorr_partial_sign.
|
||||
* Returns: 1: valid nonce pair was generated.
|
||||
* 0: otherwise (nonce generation function failed)
|
||||
* Args: ctx: pointer to a context object, initialized for signing
|
||||
* (cannot be NULL)
|
||||
* Out: pubnonce: public side of the nonce (cannot be NULL)
|
||||
* privnonce32: private side of the nonce (32 byte) (cannot be NULL)
|
||||
* In: msg32: the 32-byte message hash assumed to be signed (cannot
|
||||
* be NULL)
|
||||
* sec32: the 32-byte private key (cannot be NULL)
|
||||
* noncefp: pointer to a nonce generation function. If NULL,
|
||||
* secp256k1_nonce_function_default is used
|
||||
* noncedata: pointer to arbitrary data used by the nonce generation
|
||||
* function (can be NULL)
|
||||
*
|
||||
* Do not use the output as a private/public key pair for signing/validation.
|
||||
*/
|
||||
SECP256K1_API int secp256k1_schnorr_generate_nonce_pair(
|
||||
const secp256k1_context* ctx,
|
||||
secp256k1_pubkey *pubnonce,
|
||||
unsigned char *privnonce32,
|
||||
const unsigned char *msg32,
|
||||
const unsigned char *sec32,
|
||||
secp256k1_nonce_function noncefp,
|
||||
const void* noncedata
|
||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
|
||||
|
||||
/** Produce a partial Schnorr signature, which can be combined using
|
||||
* secp256k1_schnorr_partial_combine, to end up with a full signature that is
|
||||
* verifiable using secp256k1_schnorr_verify.
|
||||
* Returns: 1: signature created successfully.
|
||||
* 0: no valid signature exists with this combination of keys, nonces
|
||||
* and message (chance around 1 in 2^128)
|
||||
* -1: invalid private key, nonce, or public nonces.
|
||||
* Args: ctx: pointer to context object, initialized for signing (cannot
|
||||
* be NULL)
|
||||
* Out: sig64: pointer to 64-byte array to put partial signature in
|
||||
* In: msg32: pointer to 32-byte message to sign
|
||||
* sec32: pointer to 32-byte private key
|
||||
* pubnonce_others: pointer to pubkey containing the sum of the other's
|
||||
* nonces (see secp256k1_ec_pubkey_combine)
|
||||
* secnonce32: pointer to 32-byte array containing our nonce
|
||||
*
|
||||
* The intended procedure for creating a multiparty signature is:
|
||||
* - Each signer S[i] with private key x[i] and public key Q[i] runs
|
||||
* secp256k1_schnorr_generate_nonce_pair to produce a pair (k[i],R[i]) of
|
||||
* private/public nonces.
|
||||
* - All signers communicate their public nonces to each other (revealing your
|
||||
* private nonce can lead to discovery of your private key, so it should be
|
||||
* considered secret).
|
||||
* - All signers combine all the public nonces they received (excluding their
|
||||
* own) using secp256k1_ec_pubkey_combine to obtain an
|
||||
* Rall[i] = sum(R[0..i-1,i+1..n]).
|
||||
* - All signers produce a partial signature using
|
||||
* secp256k1_schnorr_partial_sign, passing in their own private key x[i],
|
||||
* their own private nonce k[i], and the sum of the others' public nonces
|
||||
* Rall[i].
|
||||
* - All signers communicate their partial signatures to each other.
|
||||
* - Someone combines all partial signatures using
|
||||
* secp256k1_schnorr_partial_combine, to obtain a full signature.
|
||||
* - The resulting signature is validatable using secp256k1_schnorr_verify, with
|
||||
* public key equal to the result of secp256k1_ec_pubkey_combine of the
|
||||
* signers' public keys (sum(Q[0..n])).
|
||||
*
|
||||
* Note that secp256k1_schnorr_partial_combine and secp256k1_ec_pubkey_combine
|
||||
* function take their arguments in any order, and it is possible to
|
||||
* pre-combine several inputs already with one call, and add more inputs later
|
||||
* by calling the function again (they are commutative and associative).
|
||||
*/
|
||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_partial_sign(
|
||||
const secp256k1_context* ctx,
|
||||
unsigned char *sig64,
|
||||
const unsigned char *msg32,
|
||||
const unsigned char *sec32,
|
||||
const secp256k1_pubkey *pubnonce_others,
|
||||
const unsigned char *secnonce32
|
||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6);
|
||||
|
||||
/** Combine multiple Schnorr partial signatures.
|
||||
* Returns: 1: the passed signatures were successfully combined.
|
||||
* 0: the resulting signature is not valid (chance of 1 in 2^256)
|
||||
* -1: some inputs were invalid, or the signatures were not created
|
||||
* using the same set of nonces
|
||||
* Args: ctx: pointer to a context object
|
||||
* Out: sig64: pointer to a 64-byte array to place the combined signature
|
||||
* (cannot be NULL)
|
||||
* In: sig64sin: pointer to an array of n pointers to 64-byte input
|
||||
* signatures
|
||||
* n: the number of signatures to combine (at least 1)
|
||||
*/
|
||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_partial_combine(
|
||||
const secp256k1_context* ctx,
|
||||
unsigned char *sig64,
|
||||
const unsigned char * const * sig64sin,
|
||||
size_t n
|
||||
) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user