@@ -11,28 +11,7 @@ use crate::to_hex;
11
11
macro_rules! impl_display_secret {
12
12
// Default hasher exists only in standard library and not alloc
13
13
( $thing: ident) => {
14
- #[ cfg( feature = "std" ) ]
15
- impl core:: fmt:: Debug for $thing {
16
- fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
17
- use core:: hash:: Hasher ;
18
- const DEBUG_HASH_TAG : & [ u8 ] = & [
19
- 0x66 , 0xa6 , 0x77 , 0x1b , 0x9b , 0x6d , 0xae , 0xa1 , 0xb2 , 0xee , 0x4e , 0x07 , 0x49 ,
20
- 0x4a , 0xac , 0x87 , 0xa9 , 0xb8 , 0x5b , 0x4b , 0x35 , 0x02 , 0xaa , 0x6d , 0x0f , 0x79 ,
21
- 0xcb , 0x63 , 0xe6 , 0xf8 , 0x66 , 0x22 ,
22
- ] ; // =SHA256(b"rust-secp256k1DEBUG");
23
-
24
- let mut hasher = std:: collections:: hash_map:: DefaultHasher :: new( ) ;
25
-
26
- hasher. write( DEBUG_HASH_TAG ) ;
27
- hasher. write( DEBUG_HASH_TAG ) ;
28
- hasher. write( & self . secret_bytes( ) ) ;
29
- let hash = hasher. finish( ) ;
30
-
31
- f. debug_tuple( stringify!( $thing) ) . field( & format_args!( "#{:016x}" , hash) ) . finish( )
32
- }
33
- }
34
-
35
- #[ cfg( all( not( feature = "std" ) , feature = "hashes" ) ) ]
14
+ #[ cfg( feature = "hashes" ) ]
36
15
impl :: core:: fmt:: Debug for $thing {
37
16
fn fmt( & self , f: & mut :: core:: fmt:: Formatter ) -> :: core:: fmt:: Result {
38
17
use hashes:: { sha256, Hash , HashEngine } ;
@@ -50,10 +29,13 @@ macro_rules! impl_display_secret {
50
29
}
51
30
}
52
31
53
- #[ cfg( all ( not( feature = "std" ) , not ( feature = " hashes") ) ) ]
32
+ #[ cfg( not( feature = "hashes" ) ) ]
54
33
impl :: core:: fmt:: Debug for $thing {
55
34
fn fmt( & self , f: & mut :: core:: fmt:: Formatter ) -> :: core:: fmt:: Result {
56
- write!( f, "<secret requires std or hashes feature to display>" )
35
+ write!(
36
+ f,
37
+ "<secret key; enable `hashes` feature of `secp256k1` to display fingerprint>"
38
+ )
57
39
}
58
40
}
59
41
} ;
0 commit comments