Struct secp256k1::global::GlobalContext[][src]

pub struct GlobalContext { /* fields omitted */ }

Proxy struct for global SECP256K1 context

Methods from Deref<Target = Secp256k1<All>>

pub fn sign_recoverable(
    &self,
    msg: &Message,
    sk: &SecretKey
) -> RecoverableSignature
[src]

Constructs a signature for msg using the secret key sk and RFC6979 nonce Requires a signing-capable context.

pub fn recover(
    &self,
    msg: &Message,
    sig: &RecoverableSignature
) -> Result<PublicKey, Error>
[src]

Determines the public key for which sig is a valid signature for msg. Requires a verify-capable context.

pub fn ctx(&self) -> &*mut Context[src]

Getter for the raw pointer to the underlying secp256k1 context. This shouldn’t be needed with normal usage of the library. It enables extending the Secp256k1 with more cryptographic algorithms outside of this crate.

pub fn sign(&self, msg: &Message, sk: &SecretKey) -> Signature[src]

Constructs a signature for msg using the secret key sk and RFC6979 nonce Requires a signing-capable context.

pub fn generate_keypair<R: Rng + ?Sized>(
    &self,
    rng: &mut R
) -> (SecretKey, PublicKey)
[src]

Generates a random keypair. Convenience function for key::SecretKey::new and key::PublicKey::from_secret_key; call those functions directly for batch key generation. Requires a signing-capable context. Requires compilation with the “rand” feature.

pub fn verify(
    &self,
    msg: &Message,
    sig: &Signature,
    pk: &PublicKey
) -> Result<(), Error>
[src]

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));

Trait Implementations

impl Deref for GlobalContext[src]

type Target = Secp256k1<All>

The resulting type after dereferencing.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.