@@ -16,9 +16,7 @@ use crate::ffi::{self, CPtr};
1616use crate :: Error :: { self , InvalidPublicKey , InvalidPublicKeySum , InvalidSecretKey } ;
1717#[ cfg( feature = "global-context" ) ]
1818use crate :: SECP256K1 ;
19- use crate :: {
20- constants, ecdsa, from_hex, schnorr, Message , Scalar , Secp256k1 , Signing , Verification ,
21- } ;
19+ use crate :: { constants, ecdsa, hex, schnorr, Message , Scalar , Secp256k1 , Signing , Verification } ;
2220#[ cfg( feature = "hashes" ) ]
2321use crate :: { hashes, ThirtyTwoByteHash } ;
2422
@@ -114,7 +112,7 @@ impl str::FromStr for SecretKey {
114112 type Err = Error ;
115113 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
116114 let mut res = [ 0u8 ; constants:: SECRET_KEY_SIZE ] ;
117- match from_hex ( s, & mut res) {
115+ match hex :: from_hex ( s, & mut res) {
118116 Ok ( constants:: SECRET_KEY_SIZE ) => SecretKey :: from_slice ( & res) ,
119117 _ => Err ( Error :: InvalidSecretKey ) ,
120118 }
@@ -167,7 +165,7 @@ impl str::FromStr for PublicKey {
167165 type Err = Error ;
168166 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
169167 let mut res = [ 0u8 ; constants:: UNCOMPRESSED_PUBLIC_KEY_SIZE ] ;
170- match from_hex ( s, & mut res) {
168+ match hex :: from_hex ( s, & mut res) {
171169 Ok ( constants:: PUBLIC_KEY_SIZE ) =>
172170 PublicKey :: from_slice ( & res[ 0 ..constants:: PUBLIC_KEY_SIZE ] ) ,
173171 Ok ( constants:: UNCOMPRESSED_PUBLIC_KEY_SIZE ) => PublicKey :: from_slice ( & res) ,
@@ -385,7 +383,7 @@ impl serde::Serialize for SecretKey {
385383 fn serialize < S : serde:: Serializer > ( & self , s : S ) -> Result < S :: Ok , S :: Error > {
386384 if s. is_human_readable ( ) {
387385 let mut buf = [ 0u8 ; constants:: SECRET_KEY_SIZE * 2 ] ;
388- s. serialize_str ( crate :: to_hex ( & self . 0 , & mut buf) . expect ( "fixed-size hex serialization" ) )
386+ s. serialize_str ( hex :: to_hex ( & self . 0 , & mut buf) . expect ( "fixed-size hex serialization" ) )
389387 } else {
390388 let mut tuple = s. serialize_tuple ( constants:: SECRET_KEY_SIZE ) ?;
391389 for byte in self . 0 . iter ( ) {
@@ -859,7 +857,7 @@ impl Keypair {
859857 #[ inline]
860858 pub fn from_seckey_str < C : Signing > ( secp : & Secp256k1 < C > , s : & str ) -> Result < Keypair , Error > {
861859 let mut res = [ 0u8 ; constants:: SECRET_KEY_SIZE ] ;
862- match from_hex ( s, & mut res) {
860+ match hex :: from_hex ( s, & mut res) {
863861 Ok ( constants:: SECRET_KEY_SIZE ) =>
864862 Keypair :: from_seckey_slice ( secp, & res[ 0 ..constants:: SECRET_KEY_SIZE ] ) ,
865863 _ => Err ( Error :: InvalidPublicKey ) ,
@@ -1041,8 +1039,7 @@ impl serde::Serialize for Keypair {
10411039 if s. is_human_readable ( ) {
10421040 let mut buf = [ 0u8 ; constants:: SECRET_KEY_SIZE * 2 ] ;
10431041 s. serialize_str (
1044- crate :: to_hex ( & self . secret_bytes ( ) , & mut buf)
1045- . expect ( "fixed-size hex serialization" ) ,
1042+ hex:: to_hex ( & self . secret_bytes ( ) , & mut buf) . expect ( "fixed-size hex serialization" ) ,
10461043 )
10471044 } else {
10481045 let mut tuple = s. serialize_tuple ( constants:: SECRET_KEY_SIZE ) ?;
@@ -1134,7 +1131,7 @@ impl str::FromStr for XOnlyPublicKey {
11341131 type Err = Error ;
11351132 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
11361133 let mut res = [ 0u8 ; constants:: SCHNORR_PUBLIC_KEY_SIZE ] ;
1137- match from_hex ( s, & mut res) {
1134+ match hex :: from_hex ( s, & mut res) {
11381135 Ok ( constants:: SCHNORR_PUBLIC_KEY_SIZE ) =>
11391136 XOnlyPublicKey :: from_slice ( & res[ 0 ..constants:: SCHNORR_PUBLIC_KEY_SIZE ] ) ,
11401137 _ => Err ( Error :: InvalidPublicKey ) ,
@@ -1559,13 +1556,13 @@ mod test {
15591556
15601557 use super :: { Keypair , Parity , PublicKey , Secp256k1 , SecretKey , XOnlyPublicKey , * } ;
15611558 use crate :: Error :: { InvalidPublicKey , InvalidSecretKey } ;
1562- use crate :: { constants, from_hex , to_hex , Scalar } ;
1559+ use crate :: { constants, hex , Scalar } ;
15631560
15641561 #[ cfg( not( secp256k1_fuzz) ) ]
15651562 macro_rules! hex {
15661563 ( $hex: expr) => { {
15671564 let mut result = vec![ 0 ; $hex. len( ) / 2 ] ;
1568- from_hex( $hex, & mut result) . expect( "valid hex string" ) ;
1565+ hex :: from_hex( $hex, & mut result) . expect( "valid hex string" ) ;
15691566 result
15701567 } } ;
15711568 }
@@ -1745,7 +1742,7 @@ mod test {
17451742
17461743 let mut buf = [ 0u8 ; constants:: SECRET_KEY_SIZE * 2 ] ;
17471744 assert_eq ! (
1748- to_hex( & sk[ ..] , & mut buf) . unwrap( ) ,
1745+ hex :: to_hex( & sk[ ..] , & mut buf) . unwrap( ) ,
17491746 "0100000000000000020000000000000003000000000000000400000000000000"
17501747 ) ;
17511748 }
@@ -2422,7 +2419,7 @@ mod test {
24222419 let ctx = crate :: Secp256k1 :: new ( ) ;
24232420 let keypair = Keypair :: new ( & ctx, & mut rand:: thread_rng ( ) ) ;
24242421 let mut buf = [ 0_u8 ; constants:: SECRET_KEY_SIZE * 2 ] ; // Holds hex digits.
2425- let s = to_hex ( & keypair. secret_key ( ) . secret_bytes ( ) , & mut buf) . unwrap ( ) ;
2422+ let s = hex :: to_hex ( & keypair. secret_key ( ) . secret_bytes ( ) , & mut buf) . unwrap ( ) ;
24262423 let parsed_key = Keypair :: from_str ( s) . unwrap ( ) ;
24272424 assert_eq ! ( parsed_key, keypair) ;
24282425 }
0 commit comments