@@ -459,7 +459,7 @@ impl PublicKey {
459
459
let mut pk = ffi:: PublicKey :: new ( ) ;
460
460
// We can assume the return value because it's not possible to construct
461
461
// an invalid `SecretKey` without transmute trickery or something.
462
- let res = ffi:: secp256k1_ec_pubkey_create ( secp. ctx , & mut pk, sk. as_c_ptr ( ) ) ;
462
+ let res = ffi:: secp256k1_ec_pubkey_create ( secp. ctx . as_ptr ( ) , & mut pk, sk. as_c_ptr ( ) ) ;
463
463
debug_assert_eq ! ( res, 1 ) ;
464
464
PublicKey ( pk)
465
465
}
@@ -575,7 +575,7 @@ impl PublicKey {
575
575
#[ must_use = "you forgot to use the negated public key" ]
576
576
pub fn negate < C : Verification > ( mut self , secp : & Secp256k1 < C > ) -> PublicKey {
577
577
unsafe {
578
- let res = ffi:: secp256k1_ec_pubkey_negate ( secp. ctx , & mut self . 0 ) ;
578
+ let res = ffi:: secp256k1_ec_pubkey_negate ( secp. ctx . as_ptr ( ) , & mut self . 0 ) ;
579
579
debug_assert_eq ! ( res, 1 ) ;
580
580
}
581
581
self
@@ -593,7 +593,9 @@ impl PublicKey {
593
593
tweak : & Scalar ,
594
594
) -> Result < PublicKey , Error > {
595
595
unsafe {
596
- if ffi:: secp256k1_ec_pubkey_tweak_add ( secp. ctx , & mut self . 0 , tweak. as_c_ptr ( ) ) == 1 {
596
+ if ffi:: secp256k1_ec_pubkey_tweak_add ( secp. ctx . as_ptr ( ) , & mut self . 0 , tweak. as_c_ptr ( ) )
597
+ == 1
598
+ {
597
599
Ok ( self )
598
600
} else {
599
601
Err ( Error :: InvalidTweak )
@@ -613,7 +615,9 @@ impl PublicKey {
613
615
other : & Scalar ,
614
616
) -> Result < PublicKey , Error > {
615
617
unsafe {
616
- if ffi:: secp256k1_ec_pubkey_tweak_mul ( secp. ctx , & mut self . 0 , other. as_c_ptr ( ) ) == 1 {
618
+ if ffi:: secp256k1_ec_pubkey_tweak_mul ( secp. ctx . as_ptr ( ) , & mut self . 0 , other. as_c_ptr ( ) )
619
+ == 1
620
+ {
617
621
Ok ( self )
618
622
} else {
619
623
Err ( Error :: InvalidTweak )
@@ -817,7 +821,7 @@ impl KeyPair {
817
821
pub fn from_secret_key < C : Signing > ( secp : & Secp256k1 < C > , sk : & SecretKey ) -> KeyPair {
818
822
unsafe {
819
823
let mut kp = ffi:: KeyPair :: new ( ) ;
820
- if ffi:: secp256k1_keypair_create ( secp. ctx , & mut kp, sk. as_c_ptr ( ) ) == 1 {
824
+ if ffi:: secp256k1_keypair_create ( secp. ctx . as_ptr ( ) , & mut kp, sk. as_c_ptr ( ) ) == 1 {
821
825
KeyPair ( kp)
822
826
} else {
823
827
panic ! ( "the provided secret key is invalid: it is corrupted or was not produced by Secp256k1 library" )
@@ -842,7 +846,7 @@ impl KeyPair {
842
846
843
847
unsafe {
844
848
let mut kp = ffi:: KeyPair :: new ( ) ;
845
- if ffi:: secp256k1_keypair_create ( secp. ctx , & mut kp, data. as_c_ptr ( ) ) == 1 {
849
+ if ffi:: secp256k1_keypair_create ( secp. ctx . as_ptr ( ) , & mut kp, data. as_c_ptr ( ) ) == 1 {
846
850
Ok ( KeyPair ( kp) )
847
851
} else {
848
852
Err ( Error :: InvalidSecretKey )
@@ -895,7 +899,9 @@ impl KeyPair {
895
899
let mut data = crate :: random_32_bytes ( rng) ;
896
900
unsafe {
897
901
let mut keypair = ffi:: KeyPair :: new ( ) ;
898
- while ffi:: secp256k1_keypair_create ( secp. ctx , & mut keypair, data. as_c_ptr ( ) ) == 0 {
902
+ while ffi:: secp256k1_keypair_create ( secp. ctx . as_ptr ( ) , & mut keypair, data. as_c_ptr ( ) )
903
+ == 0
904
+ {
899
905
data = crate :: random_32_bytes ( rng) ;
900
906
}
901
907
KeyPair ( keypair)
@@ -946,8 +952,11 @@ impl KeyPair {
946
952
tweak : & Scalar ,
947
953
) -> Result < KeyPair , Error > {
948
954
unsafe {
949
- let err =
950
- ffi:: secp256k1_keypair_xonly_tweak_add ( secp. ctx , & mut self . 0 , tweak. as_c_ptr ( ) ) ;
955
+ let err = ffi:: secp256k1_keypair_xonly_tweak_add (
956
+ secp. ctx . as_ptr ( ) ,
957
+ & mut self . 0 ,
958
+ tweak. as_c_ptr ( ) ,
959
+ ) ;
951
960
if err != 1 {
952
961
return Err ( Error :: InvalidTweak ) ;
953
962
}
@@ -1243,7 +1252,7 @@ impl XOnlyPublicKey {
1243
1252
unsafe {
1244
1253
let mut pubkey = ffi:: PublicKey :: new ( ) ;
1245
1254
let mut err = ffi:: secp256k1_xonly_pubkey_tweak_add (
1246
- secp. ctx ,
1255
+ secp. ctx . as_ptr ( ) ,
1247
1256
& mut pubkey,
1248
1257
self . as_c_ptr ( ) ,
1249
1258
tweak. as_c_ptr ( ) ,
@@ -1253,7 +1262,7 @@ impl XOnlyPublicKey {
1253
1262
}
1254
1263
1255
1264
err = ffi:: secp256k1_xonly_pubkey_from_pubkey (
1256
- secp. ctx ,
1265
+ secp. ctx . as_ptr ( ) ,
1257
1266
& mut self . 0 ,
1258
1267
& mut pk_parity,
1259
1268
& pubkey,
@@ -1306,7 +1315,7 @@ impl XOnlyPublicKey {
1306
1315
let tweaked_ser = tweaked_key. serialize ( ) ;
1307
1316
unsafe {
1308
1317
let err = ffi:: secp256k1_xonly_pubkey_tweak_add_check (
1309
- secp. ctx ,
1318
+ secp. ctx . as_ptr ( ) ,
1310
1319
tweaked_ser. as_c_ptr ( ) ,
1311
1320
tweaked_parity. to_i32 ( ) ,
1312
1321
& self . 0 ,
0 commit comments