@@ -721,7 +721,7 @@ impl Keypair {
721721 let sk = SecretKey :: test_random ( ) ;
722722 crate :: with_global_context (
723723 |secp : & Secp256k1 < crate :: AllPreallocated > | Self :: from_secret_key ( secp, & sk) ,
724- Some ( & sk. secret_bytes ( ) ) ,
724+ Some ( & sk. to_secret_bytes ( ) ) ,
725725 )
726726 }
727727}
@@ -1347,7 +1347,7 @@ impl<'a> Arbitrary<'a> for SecretKey {
13471347 }
13481348 u. fill_buffer ( & mut bytes[ ..] ) ?;
13491349
1350- if let Ok ( sk) = SecretKey :: from_byte_array ( bytes) {
1350+ if let Ok ( sk) = SecretKey :: from_secret_bytes ( bytes) {
13511351 return Ok ( sk) ;
13521352 }
13531353 }
@@ -1391,16 +1391,6 @@ mod test {
13911391 use crate :: Error :: { InvalidPublicKey , InvalidSecretKey } ;
13921392 use crate :: { constants, from_hex, to_hex, Scalar } ;
13931393
1394- #[ test]
1395- #[ allow( deprecated) ]
1396- fn skey_from_slice ( ) {
1397- let sk = SecretKey :: from_slice ( & [ 1 ; 31 ] ) ;
1398- assert_eq ! ( sk, Err ( InvalidSecretKey ) ) ;
1399-
1400- let sk = SecretKey :: from_slice ( & [ 1 ; 32 ] ) ;
1401- assert ! ( sk. is_ok( ) ) ;
1402- }
1403-
14041394 #[ test]
14051395 fn pubkey_from_slice ( ) {
14061396 assert_eq ! ( PublicKey :: from_slice( & [ ] ) , Err ( InvalidPublicKey ) ) ;
@@ -1424,7 +1414,7 @@ mod test {
14241414 #[ test]
14251415 fn keypair_slice_round_trip ( ) {
14261416 let ( sk1, pk1) = crate :: test_random_keypair ( ) ;
1427- assert_eq ! ( SecretKey :: from_byte_array ( sk1. secret_bytes ( ) ) , Ok ( sk1) ) ;
1417+ assert_eq ! ( SecretKey :: from_secret_bytes ( sk1. to_secret_bytes ( ) ) , Ok ( sk1) ) ;
14281418 assert_eq ! ( PublicKey :: from_slice( & pk1. serialize( ) [ ..] ) , Ok ( pk1) ) ;
14291419 assert_eq ! ( PublicKey :: from_slice( & pk1. serialize_uncompressed( ) [ ..] ) , Ok ( pk1) ) ;
14301420 }
@@ -1443,22 +1433,22 @@ mod test {
14431433 #[ rustfmt:: skip]
14441434 fn invalid_secret_key ( ) {
14451435 // Zero
1446- assert_eq ! ( SecretKey :: from_byte_array ( [ 0 ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
1436+ assert_eq ! ( SecretKey :: from_secret_bytes ( [ 0 ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
14471437 assert_eq ! (
14481438 SecretKey :: from_str( "0000000000000000000000000000000000000000000000000000000000000000" ) ,
14491439 Err ( InvalidSecretKey )
14501440 ) ;
14511441 // -1
1452- assert_eq ! ( SecretKey :: from_byte_array ( [ 0xff ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
1442+ assert_eq ! ( SecretKey :: from_secret_bytes ( [ 0xff ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
14531443 // Top of range
1454- assert ! ( SecretKey :: from_byte_array ( [
1444+ assert ! ( SecretKey :: from_secret_bytes ( [
14551445 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
14561446 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFE ,
14571447 0xBA , 0xAE , 0xDC , 0xE6 , 0xAF , 0x48 , 0xA0 , 0x3B ,
14581448 0xBF , 0xD2 , 0x5E , 0x8C , 0xD0 , 0x36 , 0x41 , 0x40 ,
14591449 ] ) . is_ok( ) ) ;
14601450 // One past top of range
1461- assert ! ( SecretKey :: from_byte_array ( [
1451+ assert ! ( SecretKey :: from_secret_bytes ( [
14621452 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
14631453 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFE ,
14641454 0xBA , 0xAE , 0xDC , 0xE6 , 0xAF , 0x48 , 0xA0 , 0x3B ,
@@ -1526,30 +1516,6 @@ mod test {
15261516 assert_eq ! ( PublicKey :: from_slice( & [ ] ) , Err ( InvalidPublicKey ) ) ;
15271517 }
15281518
1529- #[ test]
1530- #[ allow( deprecated) ]
1531- fn test_seckey_from_bad_slice ( ) {
1532- // Bad sizes
1533- assert_eq ! (
1534- SecretKey :: from_slice( & [ 0 ; constants:: SECRET_KEY_SIZE - 1 ] ) ,
1535- Err ( InvalidSecretKey )
1536- ) ;
1537- assert_eq ! (
1538- SecretKey :: from_slice( & [ 0 ; constants:: SECRET_KEY_SIZE + 1 ] ) ,
1539- Err ( InvalidSecretKey )
1540- ) ;
1541- // Bad parse
1542- assert_eq ! (
1543- SecretKey :: from_slice( & [ 0xff ; constants:: SECRET_KEY_SIZE ] ) ,
1544- Err ( InvalidSecretKey )
1545- ) ;
1546- assert_eq ! (
1547- SecretKey :: from_slice( & [ 0x00 ; constants:: SECRET_KEY_SIZE ] ) ,
1548- Err ( InvalidSecretKey )
1549- ) ;
1550- assert_eq ! ( SecretKey :: from_slice( & [ ] ) , Err ( InvalidSecretKey ) ) ;
1551- }
1552-
15531519 #[ test]
15541520 #[ cfg( all( feature = "rand" , feature = "alloc" ) ) ]
15551521 fn test_debug_output ( ) {
@@ -1578,7 +1544,7 @@ mod test {
15781544
15791545 #[ cfg( not( secp256k1_fuzz) ) ]
15801546 let s = Secp256k1 :: signing_only ( ) ;
1581- let sk = SecretKey :: from_byte_array ( SK_BYTES ) . expect ( "sk" ) ;
1547+ let sk = SecretKey :: from_secret_bytes ( SK_BYTES ) . expect ( "sk" ) ;
15821548
15831549 // In fuzzing mode secret->public key derivation is different, so
15841550 // hard-code the expected result.
@@ -1925,7 +1891,7 @@ mod test {
19251891
19261892 #[ cfg( not( secp256k1_fuzz) ) ]
19271893 let s = Secp256k1 :: new ( ) ;
1928- let sk = SecretKey :: from_byte_array ( SK_BYTES ) . unwrap ( ) ;
1894+ let sk = SecretKey :: from_secret_bytes ( SK_BYTES ) . unwrap ( ) ;
19291895
19301896 // In fuzzing mode secret->public key derivation is different, so
19311897 // hard-code the expected result.
@@ -2064,7 +2030,7 @@ mod test {
20642030 pk_bytes[ 0 ] = 0x02 ; // Use positive Y co-ordinate.
20652031 pk_bytes[ 1 ..] . clone_from_slice ( & PK_BYTES ) ;
20662032
2067- let sk = SecretKey :: from_byte_array ( SK_BYTES ) . expect ( "failed to parse sk bytes" ) ;
2033+ let sk = SecretKey :: from_secret_bytes ( SK_BYTES ) . expect ( "failed to parse sk bytes" ) ;
20682034 let pk = PublicKey :: from_slice ( & pk_bytes) . expect ( "failed to create pk from iterator" ) ;
20692035 let kp = Keypair :: from_secret_key ( & secp, & sk) ;
20702036 let xonly =
@@ -2227,7 +2193,7 @@ mod test {
22272193 fn test_keypair_from_str ( ) {
22282194 let keypair = Keypair :: test_random ( ) ;
22292195 let mut buf = [ 0_u8 ; constants:: SECRET_KEY_SIZE * 2 ] ; // Holds hex digits.
2230- let s = to_hex ( & keypair. secret_key ( ) . secret_bytes ( ) , & mut buf) . unwrap ( ) ;
2196+ let s = to_hex ( & keypair. secret_key ( ) . to_secret_bytes ( ) , & mut buf) . unwrap ( ) ;
22312197 let parsed_key = Keypair :: from_str ( s) . unwrap ( ) ;
22322198 assert_eq ! ( parsed_key, keypair) ;
22332199 }
@@ -2240,7 +2206,7 @@ mod test {
22402206
22412207 serde_test:: assert_tokens ( & keypair. readable ( ) , & [ Token :: String ( sec_key_str) ] ) ;
22422208
2243- let sec_key_bytes = keypair. secret_key ( ) . secret_bytes ( ) ;
2209+ let sec_key_bytes = keypair. secret_key ( ) . to_secret_bytes ( ) ;
22442210 let tokens = std:: iter:: once ( Token :: Tuple { len : 32 } )
22452211 . chain ( sec_key_bytes. iter ( ) . copied ( ) . map ( Token :: U8 ) )
22462212 . chain ( std:: iter:: once ( Token :: TupleEnd ) )
0 commit comments