File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -466,6 +466,20 @@ impl PublicKey {
466
466
}
467
467
}
468
468
469
+ /// This is just a demo of the new _global API
470
+ pub fn _from_secret_key ( sk : & SecretKey ) -> PublicKey {
471
+ unsafe {
472
+ crate :: context:: _global:: with_global_signing_context ( |ctx| {
473
+ let mut pk = ffi:: PublicKey :: new ( ) ;
474
+ // We can assume the return value because it's not possible to construct
475
+ // an invalid `SecretKey` without transmute trickery or something.
476
+ let res = ffi:: secp256k1_ec_pubkey_create ( ctx, & mut pk, sk. as_c_ptr ( ) ) ;
477
+ debug_assert_eq ! ( res, 1 ) ;
478
+ PublicKey ( pk)
479
+ } )
480
+ }
481
+ }
482
+
469
483
/// Creates a new public key from a [`SecretKey`] and the global [`SECP256K1`] context.
470
484
#[ inline]
471
485
#[ cfg( feature = "global-context" ) ]
You can’t perform that action at this time.
0 commit comments