@@ -13,9 +13,7 @@ use core::{fmt, ptr, str};
13
13
pub use self :: recovery:: { RecoverableSignature , RecoveryId } ;
14
14
pub use self :: serialized_signature:: SerializedSignature ;
15
15
use crate :: ffi:: CPtr ;
16
- use crate :: {
17
- ecdsa, ffi, from_hex, Error , Message , PublicKey , Secp256k1 , SecretKey ,
18
- } ;
16
+ use crate :: { ecdsa, ffi, from_hex, Error , Message , PublicKey , Secp256k1 , SecretKey } ;
19
17
20
18
/// An ECDSA signature
21
19
#[ derive( Copy , Clone , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
@@ -253,19 +251,21 @@ fn sign_ecdsa_with_noncedata_pointer(
253
251
// We can assume the return value because it's not possible to construct
254
252
// an invalid signature from a valid `Message` and `SecretKey`
255
253
let res = crate :: with_global_context (
256
- |secp : & Secp256k1 < crate :: AllPreallocated > | ffi:: secp256k1_ecdsa_sign (
257
- secp. ctx . as_ptr ( ) ,
258
- & mut ret,
259
- msg. as_c_ptr ( ) ,
260
- sk. as_c_ptr ( ) ,
261
- ffi:: secp256k1_nonce_function_rfc6979,
262
- noncedata_ptr
263
- ) ,
254
+ |secp : & Secp256k1 < crate :: AllPreallocated > | {
255
+ ffi:: secp256k1_ecdsa_sign (
256
+ secp. ctx . as_ptr ( ) ,
257
+ & mut ret,
258
+ msg. as_c_ptr ( ) ,
259
+ sk. as_c_ptr ( ) ,
260
+ ffi:: secp256k1_nonce_function_rfc6979,
261
+ noncedata_ptr,
262
+ )
263
+ } ,
264
264
Some ( & sk. to_secret_bytes ( ) ) ,
265
265
) ;
266
266
267
267
assert_eq ! ( res, 1 ) ;
268
-
268
+
269
269
Signature :: from ( ret)
270
270
}
271
271
}
@@ -304,14 +304,16 @@ fn sign_grind_with_check(
304
304
// We can assume the return value because it's not possible to construct
305
305
// an invalid signature from a valid `Message` and `SecretKey`
306
306
let res = crate :: with_global_context (
307
- |secp : & Secp256k1 < crate :: AllPreallocated > | ffi:: secp256k1_ecdsa_sign (
308
- secp. ctx . as_ptr ( ) ,
309
- & mut ret,
310
- msg. as_c_ptr ( ) ,
311
- sk. as_c_ptr ( ) ,
312
- ffi:: secp256k1_nonce_function_rfc6979,
313
- entropy_p
314
- ) ,
307
+ |secp : & Secp256k1 < crate :: AllPreallocated > | {
308
+ ffi:: secp256k1_ecdsa_sign (
309
+ secp. ctx . as_ptr ( ) ,
310
+ & mut ret,
311
+ msg. as_c_ptr ( ) ,
312
+ sk. as_c_ptr ( ) ,
313
+ ffi:: secp256k1_nonce_function_rfc6979,
314
+ entropy_p,
315
+ )
316
+ } ,
315
317
Some ( & sk. to_secret_bytes ( ) ) ,
316
318
) ;
317
319
assert_eq ! ( res, 1 ) ;
@@ -337,11 +339,7 @@ fn sign_grind_with_check(
337
339
/// of signing operation performed by this function is exponential in the
338
340
/// number of bytes grinded.
339
341
/// Requires a signing capable context.
340
- pub fn sign_grind_r (
341
- msg : impl Into < Message > ,
342
- sk : & SecretKey ,
343
- bytes_to_grind : usize ,
344
- ) -> Signature {
342
+ pub fn sign_grind_r ( msg : impl Into < Message > , sk : & SecretKey , bytes_to_grind : usize ) -> Signature {
345
343
let len_check = |s : & ffi:: Signature | der_length_check ( s, 71 - bytes_to_grind) ;
346
344
sign_grind_with_check ( msg, sk, len_check)
347
345
}
@@ -377,21 +375,19 @@ pub fn sign_low_r(msg: impl Into<Message>, sk: &SecretKey) -> Signature {
377
375
/// # }
378
376
/// ```
379
377
#[ inline]
380
- pub fn verify (
381
- sig : & Signature ,
382
- msg : impl Into < Message > ,
383
- pk : & PublicKey ,
384
- ) -> Result < ( ) , Error > {
378
+ pub fn verify ( sig : & Signature , msg : impl Into < Message > , pk : & PublicKey ) -> Result < ( ) , Error > {
385
379
let msg = msg. into ( ) ;
386
380
unsafe {
387
381
let res = crate :: with_global_context (
388
- |secp : & Secp256k1 < crate :: AllPreallocated > | ffi:: secp256k1_ecdsa_verify (
389
- secp. ctx . as_ptr ( ) ,
390
- sig. as_c_ptr ( ) ,
391
- msg. as_c_ptr ( ) ,
392
- pk. as_c_ptr ( ) ,
393
- ) ,
394
- None , // FIXME: What goes here?
382
+ |secp : & Secp256k1 < crate :: AllPreallocated > | {
383
+ ffi:: secp256k1_ecdsa_verify (
384
+ secp. ctx . as_ptr ( ) ,
385
+ sig. as_c_ptr ( ) ,
386
+ msg. as_c_ptr ( ) ,
387
+ pk. as_c_ptr ( ) ,
388
+ )
389
+ } ,
390
+ None , // FIXME: What goes here?
395
391
) ;
396
392
if res == 0 {
397
393
Err ( Error :: IncorrectSignature )
0 commit comments