Struct sapio_secp256k1::global::GlobalContext
source · [−]pub struct GlobalContext { /* private fields */ }
global-context
and std
only.Expand description
Proxy struct for global SECP256K1
context.
Methods from Deref<Target = Secp256k1<All>>
sourcepub fn sign_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> RecoverableSignature
👎 Deprecated since 0.21.0: Use sign_ecdsa_recoverable instead.
pub fn sign_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> RecoverableSignature
Use sign_ecdsa_recoverable instead.
Constructs a signature for msg
using the secret key sk
and RFC6979 nonce.
Requires a signing-capable context.
sourcepub fn sign_ecdsa_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> RecoverableSignature
pub fn sign_ecdsa_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> RecoverableSignature
Constructs a signature for msg
using the secret key sk
and RFC6979 nonce
Requires a signing-capable context.
sourcepub fn recover(
&self,
msg: &Message,
sig: &RecoverableSignature
) -> Result<PublicKey, Error>
👎 Deprecated since 0.21.0: Use recover_ecdsa instead.
pub fn recover(
&self,
msg: &Message,
sig: &RecoverableSignature
) -> Result<PublicKey, Error>
Use recover_ecdsa instead.
Determines the public key for which sig
is a valid signature for
msg
. Requires a verify-capable context.
sourcepub fn recover_ecdsa(
&self,
msg: &Message,
sig: &RecoverableSignature
) -> Result<PublicKey, Error>
pub fn recover_ecdsa(
&self,
msg: &Message,
sig: &RecoverableSignature
) -> Result<PublicKey, Error>
Determines the public key for which sig
is a valid signature for
msg
. Requires a verify-capable context.
sourcepub fn sign(&self, msg: &Message, sk: &SecretKey) -> Signature
👎 Deprecated since 0.21.0: Use sign_ecdsa instead.
pub fn sign(&self, msg: &Message, sk: &SecretKey) -> Signature
Use sign_ecdsa instead.
Constructs a signature for msg
using the secret key sk
and RFC6979 nonce
Requires a signing-capable context.
sourcepub fn sign_ecdsa(&self, msg: &Message, sk: &SecretKey) -> Signature
pub fn sign_ecdsa(&self, msg: &Message, sk: &SecretKey) -> Signature
Constructs a signature for msg
using the secret key sk
and RFC6979 nonce
Requires a signing-capable context.
sourcepub fn sign_grind_r(
&self,
msg: &Message,
sk: &SecretKey,
bytes_to_grind: usize
) -> Signature
👎 Deprecated since 0.21.0: Use sign_ecdsa_grind_r instead.
pub fn sign_grind_r(
&self,
msg: &Message,
sk: &SecretKey,
bytes_to_grind: usize
) -> Signature
Use sign_ecdsa_grind_r instead.
Constructs a signature for msg
using the secret key sk
, RFC6979 nonce
and “grinds” the nonce by passing extra entropy if necessary to produce
a signature that is less than 71 - bytes_to_grind
bytes. The number
of signing operation performed by this function is exponential in the
number of bytes grinded.
Requires a signing capable context.
sourcepub fn sign_ecdsa_grind_r(
&self,
msg: &Message,
sk: &SecretKey,
bytes_to_grind: usize
) -> Signature
pub fn sign_ecdsa_grind_r(
&self,
msg: &Message,
sk: &SecretKey,
bytes_to_grind: usize
) -> Signature
Constructs a signature for msg
using the secret key sk
, RFC6979 nonce
and “grinds” the nonce by passing extra entropy if necessary to produce
a signature that is less than 71 - bytes_to_grind
bytes. The number
of signing operation performed by this function is exponential in the
number of bytes grinded.
Requires a signing capable context.
sourcepub fn sign_low_r(&self, msg: &Message, sk: &SecretKey) -> Signature
👎 Deprecated since 0.21.0: Use sign_ecdsa_grind_r instead.
pub fn sign_low_r(&self, msg: &Message, sk: &SecretKey) -> Signature
Use sign_ecdsa_grind_r instead.
Constructs a signature for msg
using the secret key sk
, RFC6979 nonce
and “grinds” the nonce by passing extra entropy if necessary to produce
a signature that is less than 71 bytes and compatible with the low r
signature implementation of bitcoin core. In average, this function
will perform two signing operations.
Requires a signing capable context.
sourcepub fn sign_ecdsa_low_r(&self, msg: &Message, sk: &SecretKey) -> Signature
pub fn sign_ecdsa_low_r(&self, msg: &Message, sk: &SecretKey) -> Signature
Constructs a signature for msg
using the secret key sk
, RFC6979 nonce
and “grinds” the nonce by passing extra entropy if necessary to produce
a signature that is less than 71 bytes and compatible with the low r
signature implementation of bitcoin core. In average, this function
will perform two signing operations.
Requires a signing capable context.
sourcepub fn verify(
&self,
msg: &Message,
sig: &Signature,
pk: &PublicKey
) -> Result<(), Error>
👎 Deprecated since 0.21.0: Use verify_ecdsa instead
pub fn verify(
&self,
msg: &Message,
sig: &Signature,
pk: &PublicKey
) -> Result<(), Error>
Use verify_ecdsa instead
Checks that sig
is a valid ECDSA signature for msg
using the public
key pubkey
. Returns Ok(())
on success. Note that this function cannot
be used for Bitcoin consensus checking since there may exist signatures
which OpenSSL would verify but not libsecp256k1, or vice-versa. Requires a
verify-capable context.
let message = Message::from_slice(&[0xab; 32]).expect("32 bytes");
let sig = secp.sign(&message, &secret_key);
assert_eq!(secp.verify(&message, &sig, &public_key), Ok(()));
let message = Message::from_slice(&[0xcd; 32]).expect("32 bytes");
assert_eq!(secp.verify(&message, &sig, &public_key), Err(Error::IncorrectSignature));
sourcepub fn verify_ecdsa(
&self,
msg: &Message,
sig: &Signature,
pk: &PublicKey
) -> Result<(), Error>
pub fn verify_ecdsa(
&self,
msg: &Message,
sig: &Signature,
pk: &PublicKey
) -> Result<(), Error>
Checks that sig
is a valid ECDSA signature for msg
using the public
key pubkey
. Returns Ok(())
on success. Note that this function cannot
be used for Bitcoin consensus checking since there may exist signatures
which OpenSSL would verify but not libsecp256k1, or vice-versa. Requires a
verify-capable context.
let message = Message::from_slice(&[0xab; 32]).expect("32 bytes");
let sig = secp.sign_ecdsa(&message, &secret_key);
assert_eq!(secp.verify_ecdsa(&message, &sig, &public_key), Ok(()));
let message = Message::from_slice(&[0xcd; 32]).expect("32 bytes");
assert_eq!(secp.verify_ecdsa(&message, &sig, &public_key), Err(Error::IncorrectSignature));
sourcepub fn schnorrsig_sign(&self, msg: &Message, keypair: &KeyPair) -> Signature
👎 Deprecated since 0.21.0: Use sign_schnorr instead.
Available on crate feature rand-std
only.
pub fn schnorrsig_sign(&self, msg: &Message, keypair: &KeyPair) -> Signature
Use sign_schnorr instead.
rand-std
only.Create a schnorr signature internally using the ThreadRng random number generator to generate the auxiliary random data.
sourcepub fn sign_schnorr(&self, msg: &Message, keypair: &KeyPair) -> Signature
Available on crate feature rand-std
only.
pub fn sign_schnorr(&self, msg: &Message, keypair: &KeyPair) -> Signature
rand-std
only.Create a schnorr signature internally using the ThreadRng random number generator to generate the auxiliary random data.
sourcepub fn schnorrsig_sign_no_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair
) -> Signature
👎 Deprecated since 0.21.0: Use sign_schnorr_no_aux_rand instead.
pub fn schnorrsig_sign_no_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair
) -> Signature
Use sign_schnorr_no_aux_rand instead.
Create a schnorr signature without using any auxiliary random data.
sourcepub fn sign_schnorr_no_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair
) -> Signature
pub fn sign_schnorr_no_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair
) -> Signature
Create a schnorr signature without using any auxiliary random data.
sourcepub fn schnorrsig_sign_with_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair,
aux_rand: &[u8; 32]
) -> Signature
👎 Deprecated since 0.21.0: Use sign_schnorr_with_aux_rand instead.
pub fn schnorrsig_sign_with_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair,
aux_rand: &[u8; 32]
) -> Signature
Use sign_schnorr_with_aux_rand instead.
Create a Schnorr signature using the given auxiliary random data.
sourcepub fn sign_schnorr_with_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair,
aux_rand: &[u8; 32]
) -> Signature
pub fn sign_schnorr_with_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair,
aux_rand: &[u8; 32]
) -> Signature
Create a Schnorr signature using the given auxiliary random data.
sourcepub fn schnorrsig_sign_with_rng<R: Rng + CryptoRng>(
&self,
msg: &Message,
keypair: &KeyPair,
rng: &mut R
) -> Signature
👎 Deprecated since 0.21.0: Use sign_schnorr_with_rng instead.
Available on crate feature rand
only.
pub fn schnorrsig_sign_with_rng<R: Rng + CryptoRng>(
&self,
msg: &Message,
keypair: &KeyPair,
rng: &mut R
) -> Signature
Use sign_schnorr_with_rng instead.
rand
only.Create a schnorr signature using the given random number generator to generate the auxiliary random data.
sourcepub fn schnorrsig_verify(
&self,
sig: &Signature,
msg: &Message,
pubkey: &XOnlyPublicKey
) -> Result<(), Error>
👎 Deprecated since 0.21.0: Use verify_schnorr instead.
pub fn schnorrsig_verify(
&self,
sig: &Signature,
msg: &Message,
pubkey: &XOnlyPublicKey
) -> Result<(), Error>
Use verify_schnorr instead.
Verify a Schnorr signature.
sourcepub fn verify_schnorr(
&self,
sig: &Signature,
msg: &Message,
pubkey: &XOnlyPublicKey
) -> Result<(), Error>
pub fn verify_schnorr(
&self,
sig: &Signature,
msg: &Message,
pubkey: &XOnlyPublicKey
) -> Result<(), Error>
Verify a Schnorr signature.
sourcepub fn generate_schnorrsig_keypair<R: Rng + ?Sized>(
&self,
rng: &mut R
) -> (KeyPair, XOnlyPublicKey)
👎 Deprecated since 0.21.0: Use kp = KeyPair::new() and kp.public_key()
Available on crate feature rand
only.
pub fn generate_schnorrsig_keypair<R: Rng + ?Sized>(
&self,
rng: &mut R
) -> (KeyPair, XOnlyPublicKey)
Use kp = KeyPair::new() and kp.public_key()
rand
only.Generates a random Schnorr KeyPair
and its associated Schnorr XOnlyPublicKey
.
Convenience function for KeyPair::new and KeyPair::public_key. Requires a signing-capable context.
sourcepub fn generate_keypair<R: Rng + ?Sized>(
&self,
rng: &mut R
) -> (SecretKey, PublicKey)
Available on crate feature rand
only.
pub fn generate_keypair<R: Rng + ?Sized>(
&self,
rng: &mut R
) -> (SecretKey, PublicKey)
rand
only.Generates a random keypair. Convenience function for SecretKey::new
and
PublicKey::from_secret_key
.
Trait Implementations
sourceimpl Clone for GlobalContext
impl Clone for GlobalContext
sourcefn clone(&self) -> GlobalContext
fn clone(&self) -> GlobalContext
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for GlobalContext
impl Debug for GlobalContext
sourceimpl Deref for GlobalContext
impl Deref for GlobalContext
impl Copy for GlobalContext
Auto Trait Implementations
impl RefUnwindSafe for GlobalContext
impl Send for GlobalContext
impl Sync for GlobalContext
impl Unpin for GlobalContext
impl UnwindSafe for GlobalContext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more