@@ -459,7 +459,7 @@ impl PublicKey {
459459 let mut pk = ffi:: PublicKey :: new ( ) ;
460460 // We can assume the return value because it's not possible to construct
461461 // 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 ( ) ) ;
463463 debug_assert_eq ! ( res, 1 ) ;
464464 PublicKey ( pk)
465465 }
@@ -575,7 +575,7 @@ impl PublicKey {
575575 #[ must_use = "you forgot to use the negated public key" ]
576576 pub fn negate < C : Verification > ( mut self , secp : & Secp256k1 < C > ) -> PublicKey {
577577 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 ) ;
579579 debug_assert_eq ! ( res, 1 ) ;
580580 }
581581 self
@@ -593,7 +593,9 @@ impl PublicKey {
593593 tweak : & Scalar ,
594594 ) -> Result < PublicKey , Error > {
595595 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+ {
597599 Ok ( self )
598600 } else {
599601 Err ( Error :: InvalidTweak )
@@ -613,7 +615,9 @@ impl PublicKey {
613615 other : & Scalar ,
614616 ) -> Result < PublicKey , Error > {
615617 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+ {
617621 Ok ( self )
618622 } else {
619623 Err ( Error :: InvalidTweak )
@@ -817,7 +821,7 @@ impl KeyPair {
817821 pub fn from_secret_key < C : Signing > ( secp : & Secp256k1 < C > , sk : & SecretKey ) -> KeyPair {
818822 unsafe {
819823 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 {
821825 KeyPair ( kp)
822826 } else {
823827 panic ! ( "the provided secret key is invalid: it is corrupted or was not produced by Secp256k1 library" )
@@ -842,7 +846,7 @@ impl KeyPair {
842846
843847 unsafe {
844848 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 {
846850 Ok ( KeyPair ( kp) )
847851 } else {
848852 Err ( Error :: InvalidSecretKey )
@@ -895,7 +899,9 @@ impl KeyPair {
895899 let mut data = crate :: random_32_bytes ( rng) ;
896900 unsafe {
897901 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+ {
899905 data = crate :: random_32_bytes ( rng) ;
900906 }
901907 KeyPair ( keypair)
@@ -946,8 +952,11 @@ impl KeyPair {
946952 tweak : & Scalar ,
947953 ) -> Result < KeyPair , Error > {
948954 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+ ) ;
951960 if err != 1 {
952961 return Err ( Error :: InvalidTweak ) ;
953962 }
@@ -1243,7 +1252,7 @@ impl XOnlyPublicKey {
12431252 unsafe {
12441253 let mut pubkey = ffi:: PublicKey :: new ( ) ;
12451254 let mut err = ffi:: secp256k1_xonly_pubkey_tweak_add (
1246- secp. ctx ,
1255+ secp. ctx . as_ptr ( ) ,
12471256 & mut pubkey,
12481257 self . as_c_ptr ( ) ,
12491258 tweak. as_c_ptr ( ) ,
@@ -1253,7 +1262,7 @@ impl XOnlyPublicKey {
12531262 }
12541263
12551264 err = ffi:: secp256k1_xonly_pubkey_from_pubkey (
1256- secp. ctx ,
1265+ secp. ctx . as_ptr ( ) ,
12571266 & mut self . 0 ,
12581267 & mut pk_parity,
12591268 & pubkey,
@@ -1306,7 +1315,7 @@ impl XOnlyPublicKey {
13061315 let tweaked_ser = tweaked_key. serialize ( ) ;
13071316 unsafe {
13081317 let err = ffi:: secp256k1_xonly_pubkey_tweak_add_check (
1309- secp. ctx ,
1318+ secp. ctx . as_ptr ( ) ,
13101319 tweaked_ser. as_c_ptr ( ) ,
13111320 tweaked_parity. to_i32 ( ) ,
13121321 & self . 0 ,
0 commit comments