@@ -721,7 +721,7 @@ impl Keypair {
721
721
let sk = SecretKey :: test_random ( ) ;
722
722
crate :: with_global_context (
723
723
|secp : & Secp256k1 < crate :: AllPreallocated > | Self :: from_secret_key ( secp, & sk) ,
724
- Some ( & sk. secret_bytes ( ) ) ,
724
+ Some ( & sk. to_secret_bytes ( ) ) ,
725
725
)
726
726
}
727
727
}
@@ -1347,7 +1347,7 @@ impl<'a> Arbitrary<'a> for SecretKey {
1347
1347
}
1348
1348
u. fill_buffer ( & mut bytes[ ..] ) ?;
1349
1349
1350
- if let Ok ( sk) = SecretKey :: from_byte_array ( bytes) {
1350
+ if let Ok ( sk) = SecretKey :: from_secret_bytes ( bytes) {
1351
1351
return Ok ( sk) ;
1352
1352
}
1353
1353
}
@@ -1391,16 +1391,6 @@ mod test {
1391
1391
use crate :: Error :: { InvalidPublicKey , InvalidSecretKey } ;
1392
1392
use crate :: { constants, from_hex, to_hex, Scalar } ;
1393
1393
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
-
1404
1394
#[ test]
1405
1395
fn pubkey_from_slice ( ) {
1406
1396
assert_eq ! ( PublicKey :: from_slice( & [ ] ) , Err ( InvalidPublicKey ) ) ;
@@ -1424,7 +1414,7 @@ mod test {
1424
1414
#[ test]
1425
1415
fn keypair_slice_round_trip ( ) {
1426
1416
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) ) ;
1428
1418
assert_eq ! ( PublicKey :: from_slice( & pk1. serialize( ) [ ..] ) , Ok ( pk1) ) ;
1429
1419
assert_eq ! ( PublicKey :: from_slice( & pk1. serialize_uncompressed( ) [ ..] ) , Ok ( pk1) ) ;
1430
1420
}
@@ -1443,22 +1433,22 @@ mod test {
1443
1433
#[ rustfmt:: skip]
1444
1434
fn invalid_secret_key ( ) {
1445
1435
// Zero
1446
- assert_eq ! ( SecretKey :: from_byte_array ( [ 0 ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
1436
+ assert_eq ! ( SecretKey :: from_secret_bytes ( [ 0 ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
1447
1437
assert_eq ! (
1448
1438
SecretKey :: from_str( "0000000000000000000000000000000000000000000000000000000000000000" ) ,
1449
1439
Err ( InvalidSecretKey )
1450
1440
) ;
1451
1441
// -1
1452
- assert_eq ! ( SecretKey :: from_byte_array ( [ 0xff ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
1442
+ assert_eq ! ( SecretKey :: from_secret_bytes ( [ 0xff ; 32 ] ) , Err ( InvalidSecretKey ) ) ;
1453
1443
// Top of range
1454
- assert ! ( SecretKey :: from_byte_array ( [
1444
+ assert ! ( SecretKey :: from_secret_bytes ( [
1455
1445
0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
1456
1446
0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFE ,
1457
1447
0xBA , 0xAE , 0xDC , 0xE6 , 0xAF , 0x48 , 0xA0 , 0x3B ,
1458
1448
0xBF , 0xD2 , 0x5E , 0x8C , 0xD0 , 0x36 , 0x41 , 0x40 ,
1459
1449
] ) . is_ok( ) ) ;
1460
1450
// One past top of range
1461
- assert ! ( SecretKey :: from_byte_array ( [
1451
+ assert ! ( SecretKey :: from_secret_bytes ( [
1462
1452
0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
1463
1453
0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFE ,
1464
1454
0xBA , 0xAE , 0xDC , 0xE6 , 0xAF , 0x48 , 0xA0 , 0x3B ,
@@ -1526,30 +1516,6 @@ mod test {
1526
1516
assert_eq ! ( PublicKey :: from_slice( & [ ] ) , Err ( InvalidPublicKey ) ) ;
1527
1517
}
1528
1518
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
-
1553
1519
#[ test]
1554
1520
#[ cfg( all( feature = "rand" , feature = "alloc" ) ) ]
1555
1521
fn test_debug_output ( ) {
@@ -1578,7 +1544,7 @@ mod test {
1578
1544
1579
1545
#[ cfg( not( secp256k1_fuzz) ) ]
1580
1546
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" ) ;
1582
1548
1583
1549
// In fuzzing mode secret->public key derivation is different, so
1584
1550
// hard-code the expected result.
@@ -1925,7 +1891,7 @@ mod test {
1925
1891
1926
1892
#[ cfg( not( secp256k1_fuzz) ) ]
1927
1893
let s = Secp256k1 :: new ( ) ;
1928
- let sk = SecretKey :: from_byte_array ( SK_BYTES ) . unwrap ( ) ;
1894
+ let sk = SecretKey :: from_secret_bytes ( SK_BYTES ) . unwrap ( ) ;
1929
1895
1930
1896
// In fuzzing mode secret->public key derivation is different, so
1931
1897
// hard-code the expected result.
@@ -2064,7 +2030,7 @@ mod test {
2064
2030
pk_bytes[ 0 ] = 0x02 ; // Use positive Y co-ordinate.
2065
2031
pk_bytes[ 1 ..] . clone_from_slice ( & PK_BYTES ) ;
2066
2032
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" ) ;
2068
2034
let pk = PublicKey :: from_slice ( & pk_bytes) . expect ( "failed to create pk from iterator" ) ;
2069
2035
let kp = Keypair :: from_secret_key ( & secp, & sk) ;
2070
2036
let xonly =
@@ -2227,7 +2193,7 @@ mod test {
2227
2193
fn test_keypair_from_str ( ) {
2228
2194
let keypair = Keypair :: test_random ( ) ;
2229
2195
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 ( ) ;
2231
2197
let parsed_key = Keypair :: from_str ( s) . unwrap ( ) ;
2232
2198
assert_eq ! ( parsed_key, keypair) ;
2233
2199
}
@@ -2240,7 +2206,7 @@ mod test {
2240
2206
2241
2207
serde_test:: assert_tokens ( & keypair. readable ( ) , & [ Token :: String ( sec_key_str) ] ) ;
2242
2208
2243
- let sec_key_bytes = keypair. secret_key ( ) . secret_bytes ( ) ;
2209
+ let sec_key_bytes = keypair. secret_key ( ) . to_secret_bytes ( ) ;
2244
2210
let tokens = std:: iter:: once ( Token :: Tuple { len : 32 } )
2245
2211
. chain ( sec_key_bytes. iter ( ) . copied ( ) . map ( Token :: U8 ) )
2246
2212
. chain ( std:: iter:: once ( Token :: TupleEnd ) )
0 commit comments