pub struct Secp256k1 { /* private fields */ }
Expand description
The secp256k1 engine, used to execute all signature operations
Implementations
sourceimpl Secp256k1
impl Secp256k1
sourceimpl Secp256k1
impl Secp256k1
sourcepub fn with_caps(caps: ContextFlag) -> Secp256k1
pub fn with_caps(caps: ContextFlag) -> Secp256k1
Creates a new Secp256k1 context with the specified capabilities
sourcepub fn without_caps() -> Secp256k1
pub fn without_caps() -> Secp256k1
Creates a new Secp256k1 context with no capabilities (just de/serialization)
sourcepub fn randomize<R: Rng>(&mut self, rng: &mut R)
pub fn randomize<R: Rng>(&mut self, rng: &mut R)
(Re)randomizes the Secp256k1 context for cheap sidechannel resistence; see comment in libsecp256k1 commit d2275795f by Gregory Maxwell
sourcepub fn generate_keypair<R: Rng>(
&self,
rng: &mut R
) -> Result<(SecretKey, PublicKey), Error>
pub fn generate_keypair<R: Rng>(
&self,
rng: &mut R
) -> Result<(SecretKey, PublicKey), Error>
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.
sourcepub fn sign(&self, msg: &Message, sk: &SecretKey) -> Result<Signature, Error>
pub fn sign(&self, msg: &Message, sk: &SecretKey) -> Result<Signature, Error>
Constructs a signature for msg
using the secret key sk
and RFC6979 nonce
Requires a signing-capable context.
sourcepub fn sign_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> Result<RecoverableSignature, Error>
pub fn sign_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> Result<RecoverableSignature, Error>
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>
pub fn recover(
&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 verify(
&self,
msg: &Message,
sig: &Signature,
pk: &PublicKey
) -> Result<(), Error>
pub fn verify(
&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(true)
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.
Trait Implementations
impl Eq for Secp256k1
impl Send for Secp256k1
impl Sync for Secp256k1
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub 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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more