We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8cb222f commit e086afdCopy full SHA for e086afd
src/key.rs
@@ -466,6 +466,20 @@ impl PublicKey {
466
}
467
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
+
483
/// Creates a new public key from a [`SecretKey`] and the global [`SECP256K1`] context.
484
#[inline]
485
#[cfg(feature = "global-context")]
0 commit comments