secp256k1_nonce_function_bipschnorr
This commit is contained in:
@@ -340,6 +340,27 @@ static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *m
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* This nonce function is described in BIP-schnorr
|
||||
* (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki) */
|
||||
static int secp256k1_nonce_function_bipschnorr(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) {
|
||||
secp256k1_sha256 sha;
|
||||
(void) data;
|
||||
(void) counter;
|
||||
VERIFY_CHECK(counter == 0);
|
||||
|
||||
/* Hash x||msg as per the spec */
|
||||
secp256k1_sha256_initialize(&sha);
|
||||
secp256k1_sha256_write(&sha, key32, 32);
|
||||
secp256k1_sha256_write(&sha, msg32, 32);
|
||||
/* Hash in algorithm, which is not in the spec, but may be critical to
|
||||
* users depending on it to avoid nonce reuse across algorithms. */
|
||||
if (algo16 != NULL) {
|
||||
secp256k1_sha256_write(&sha, algo16, 16);
|
||||
}
|
||||
secp256k1_sha256_finalize(&sha, nonce32);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const secp256k1_nonce_function secp256k1_nonce_function_rfc6979 = nonce_function_rfc6979;
|
||||
const secp256k1_nonce_function secp256k1_nonce_function_default = nonce_function_rfc6979;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user