Skip to content

Commit 297ce82

Browse files
committed
Merge bitcoin-core/secp256k1#966: Make aux_rand32 arg to secp256k1_schnorrsig_sign const
db4667d Make aux_rand32 arg to secp256k1_schnorrsig_sign const (Pieter Wuille) Pull request description: ACKs for top commit: real-or-random: ACK db4667d diff looks good jonasnick: ACK db4667d Tree-SHA512: 6f003c856b0e11f3f41f6d8007470129f02f9075416c6a5d3904f8efb5fa461f38e600a6b31d326314b2961946c8c6b3bca1a8e9b333b52e099a6f023a04c698
2 parents 10f9bd8 + db4667d commit 297ce82

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/secp256k1_schnorrsig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ SECP256K1_API int secp256k1_schnorrsig_sign(
120120
unsigned char *sig64,
121121
const unsigned char *msg32,
122122
const secp256k1_keypair *keypair,
123-
unsigned char *aux_rand32
123+
const unsigned char *aux_rand32
124124
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
125125

126126
/** Create a Schnorr signature with a more flexible API.

src/modules/schnorrsig/main_impl.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ static int secp256k1_schnorrsig_sign_internal(const secp256k1_context* ctx, unsi
185185
return ret;
186186
}
187187

188-
int secp256k1_schnorrsig_sign(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char *msg32, const secp256k1_keypair *keypair, unsigned char *aux_rand32) {
189-
return secp256k1_schnorrsig_sign_internal(ctx, sig64, msg32, 32, keypair, secp256k1_nonce_function_bip340, aux_rand32);
188+
int secp256k1_schnorrsig_sign(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char *msg32, const secp256k1_keypair *keypair, const unsigned char *aux_rand32) {
189+
/* We cast away const from the passed aux_rand32 argument since we know the default nonce function does not modify it. */
190+
return secp256k1_schnorrsig_sign_internal(ctx, sig64, msg32, 32, keypair, secp256k1_nonce_function_bip340, (unsigned char*)aux_rand32);
190191
}
191192

192193
int secp256k1_schnorrsig_sign_custom(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_keypair *keypair, secp256k1_schnorrsig_extraparams *extraparams) {

src/modules/schnorrsig/tests_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void test_schnorrsig_sha256_tagged(void) {
230230

231231
/* Helper function for schnorrsig_bip_vectors
232232
* Signs the message and checks that it's the same as expected_sig. */
233-
void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, const unsigned char *pk_serialized, unsigned char *aux_rand, const unsigned char *msg32, const unsigned char *expected_sig) {
233+
void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, const unsigned char *pk_serialized, const unsigned char *aux_rand, const unsigned char *msg32, const unsigned char *expected_sig) {
234234
unsigned char sig[64];
235235
secp256k1_keypair keypair;
236236
secp256k1_xonly_pubkey pk, pk_expected;

0 commit comments

Comments
 (0)