@@ -109,7 +109,7 @@ int secp256k1_borromean_verify(secp256k1_scalar *evalues, const unsigned char *e
109
109
}
110
110
111
111
int secp256k1_borromean_sign (const secp256k1_ecmult_gen_context * ecmult_gen_ctx ,
112
- unsigned char * e0 , secp256k1_scalar * s , const secp256k1_gej * pubs , const secp256k1_scalar * k , const secp256k1_scalar * sec ,
112
+ unsigned char * e0 , secp256k1_scalar * s , const secp256k1_gej * pubs , const secp256k1_scalar * sec ,
113
113
const size_t * rsizes , const size_t * secidx , size_t nrings , const unsigned char * m , size_t mlen ) {
114
114
secp256k1_gej rgej ;
115
115
secp256k1_ge rge ;
@@ -125,7 +125,6 @@ int secp256k1_borromean_sign(const secp256k1_ecmult_gen_context *ecmult_gen_ctx,
125
125
VERIFY_CHECK (e0 != NULL );
126
126
VERIFY_CHECK (s != NULL );
127
127
VERIFY_CHECK (pubs != NULL );
128
- VERIFY_CHECK (k != NULL );
129
128
VERIFY_CHECK (sec != NULL );
130
129
VERIFY_CHECK (rsizes != NULL );
131
130
VERIFY_CHECK (secidx != NULL );
@@ -135,7 +134,8 @@ int secp256k1_borromean_sign(const secp256k1_ecmult_gen_context *ecmult_gen_ctx,
135
134
count = 0 ;
136
135
for (i = 0 ; i < nrings ; i ++ ) {
137
136
VERIFY_CHECK (INT_MAX - count > rsizes [i ]);
138
- secp256k1_ecmult_gen (ecmult_gen_ctx , & rgej , & k [i ]);
137
+ /* We have been provided an s value that we will just overwrite, so use it as a nonce */
138
+ secp256k1_ecmult_gen (ecmult_gen_ctx , & rgej , & s [count + secidx [i ]]);
139
139
secp256k1_ge_set_gej (& rge , & rgej );
140
140
if (secp256k1_gej_is_infinity (& rgej )) {
141
141
return 0 ;
@@ -165,6 +165,10 @@ int secp256k1_borromean_sign(const secp256k1_ecmult_gen_context *ecmult_gen_ctx,
165
165
secp256k1_sha256_finalize (& sha256_e0 , e0 );
166
166
count = 0 ;
167
167
for (i = 0 ; i < nrings ; i ++ ) {
168
+ /* We have been provided an s value that we will just overwrite, so use it as a nonce */
169
+ secp256k1_scalar k = s [count + secidx [i ]];
170
+ secp256k1_scalar_clear (& s [count + secidx [i ]]);
171
+
168
172
VERIFY_CHECK (INT_MAX - count > rsizes [i ]);
169
173
secp256k1_borromean_hash (tmp , m , mlen , e0 , 32 , i , 0 );
170
174
secp256k1_scalar_set_b32 (& ens , tmp , & overflow );
@@ -186,7 +190,7 @@ int secp256k1_borromean_sign(const secp256k1_ecmult_gen_context *ecmult_gen_ctx,
186
190
}
187
191
secp256k1_scalar_mul (& s [count + j ], & ens , & sec [i ]);
188
192
secp256k1_scalar_negate (& s [count + j ], & s [count + j ]);
189
- secp256k1_scalar_add (& s [count + j ], & s [count + j ], & k [ i ] );
193
+ secp256k1_scalar_add (& s [count + j ], & s [count + j ], & k );
190
194
if (secp256k1_scalar_is_zero (& s [count + j ])) {
191
195
return 0 ;
192
196
}
0 commit comments