Struct secp256k1::Secp256k1 [−][src]
The secp256k1 engine, used to execute all signature operations
Implementations
impl<C: Context> Secp256k1<C>
[src]
impl Secp256k1<All>
[src]
impl Secp256k1<SignOnly>
[src]
pub fn signing_only() -> Secp256k1<SignOnly>
[src]
Creates a new Secp256k1 context that can only be used for signing
impl Secp256k1<VerifyOnly>
[src]
pub fn verification_only() -> Secp256k1<VerifyOnly>
[src]
Creates a new Secp256k1 context that can only be used for verification
impl<'buf, C: Context + 'buf> Secp256k1<C>
[src]
pub fn preallocated_gen_new(buf: &'buf mut [u8]) -> Result<Secp256k1<C>, Error>
[src]
Lets you create a context with preallocated buffer in a generic manner(sign/verify/all)
impl<'buf> Secp256k1<AllPreallocated<'buf>>
[src]
pub fn preallocated_new(
buf: &'buf mut [u8]
) -> Result<Secp256k1<AllPreallocated<'buf>>, Error>
[src]
buf: &'buf mut [u8]
) -> Result<Secp256k1<AllPreallocated<'buf>>, Error>
Creates a new Secp256k1 context with all capabilities
pub fn preallocate_size() -> usize
[src]
Uses the ffi secp256k1_context_preallocated_size
to check the memory size needed for a context
pub unsafe fn from_raw_all(
raw_ctx: *mut Context
) -> ManuallyDrop<Secp256k1<AllPreallocated<'buf>>>
[src]
raw_ctx: *mut Context
) -> ManuallyDrop<Secp256k1<AllPreallocated<'buf>>>
Create a context from a raw context.
Safety
This is highly unsafe, due to the number of conditions that aren’t checked.
raw_ctx
needs to be a valid Secp256k1 context pointer. that was generated by exactly the same code/version of the libsecp256k1 used here.- The capabilities (All/SignOnly/VerifyOnly) of the context must match the flags passed to libsecp256k1 when generating the context.
- The user must handle the freeing of the context(using the correct functions) by himself.
- Violating these may lead to Undefined Behavior.
impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>>
[src]
pub fn preallocated_signing_only(
buf: &'buf mut [u8]
) -> Result<Secp256k1<SignOnlyPreallocated<'buf>>, Error>
[src]
buf: &'buf mut [u8]
) -> Result<Secp256k1<SignOnlyPreallocated<'buf>>, Error>
Creates a new Secp256k1 context that can only be used for signing
pub fn preallocate_signing_size() -> usize
[src]
Uses the ffi secp256k1_context_preallocated_size
to check the memory size needed for the context
pub unsafe fn from_raw_signining_only(
raw_ctx: *mut Context
) -> ManuallyDrop<Secp256k1<SignOnlyPreallocated<'buf>>>
[src]
raw_ctx: *mut Context
) -> ManuallyDrop<Secp256k1<SignOnlyPreallocated<'buf>>>
Create a context from a raw context.
Safety
This is highly unsafe, due to the number of conditions that aren’t checked.
raw_ctx
needs to be a valid Secp256k1 context pointer. that was generated by exactly the same code/version of the libsecp256k1 used here.- The capabilities (All/SignOnly/VerifyOnly) of the context must match the flags passed to libsecp256k1 when generating the context.
- The user must handle the freeing of the context(using the correct functions) by himself.
- This list is not exhaustive, and any violation may lead to Undefined Behavior.,
impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>>
[src]
pub fn preallocated_verification_only(
buf: &'buf mut [u8]
) -> Result<Secp256k1<VerifyOnlyPreallocated<'buf>>, Error>
[src]
buf: &'buf mut [u8]
) -> Result<Secp256k1<VerifyOnlyPreallocated<'buf>>, Error>
Creates a new Secp256k1 context that can only be used for verification
pub fn preallocate_verification_size() -> usize
[src]
Uses the ffi secp256k1_context_preallocated_size
to check the memory size needed for the context
pub unsafe fn from_raw_verification_only(
raw_ctx: *mut Context
) -> ManuallyDrop<Secp256k1<VerifyOnlyPreallocated<'buf>>>
[src]
raw_ctx: *mut Context
) -> ManuallyDrop<Secp256k1<VerifyOnlyPreallocated<'buf>>>
Create a context from a raw context.
Safety
This is highly unsafe, due to the number of conditions that aren’t checked.
raw_ctx
needs to be a valid Secp256k1 context pointer. that was generated by exactly the same code/version of the libsecp256k1 used here.- The capabilities (All/SignOnly/VerifyOnly) of the context must match the flags passed to libsecp256k1 when generating the context.
- The user must handle the freeing of the context(using the correct functions) by himself.
- This list is not exhaustive, and any violation may lead to Undefined Behavior.,
impl<C: Signing> Secp256k1<C>
[src]
pub fn sign_recoverable(
&self,
msg: &Message,
sk: &SecretKey
) -> RecoverableSignature
[src]
&self,
msg: &Message,
sk: &SecretKey
) -> RecoverableSignature
Constructs a signature for msg
using the secret key sk
and RFC6979 nonce
Requires a signing-capable context.
impl<C: Verification> Secp256k1<C>
[src]
pub fn recover(
&self,
msg: &Message,
sig: &RecoverableSignature
) -> Result<PublicKey, Error>
[src]
&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.
impl<C: Context> Secp256k1<C>
[src]
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 preallocate_size_gen() -> usize
[src]
Returns the required memory for a preallocated context buffer in a generic manner(sign/verify/all)
pub fn randomize<R: Rng + ?Sized>(&mut self, rng: &mut R)
[src]
(Re)randomizes the Secp256k1 context for cheap sidechannel resistance; see comment in libsecp256k1 commit d2275795f by Gregory Maxwell. Requires compilation with “rand” feature.
impl<C: Signing> Secp256k1<C>
[src]
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]
&self,
rng: &mut R
) -> (SecretKey, PublicKey)
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.
impl<C: Verification> Secp256k1<C>
[src]
pub fn verify(
&self,
msg: &Message,
sig: &Signature,
pk: &PublicKey
) -> Result<(), Error>
[src]
&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(&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<C: Context> Clone for Secp256k1<C>
[src]
impl<C: Context> Debug for Secp256k1<C>
[src]
impl Default for Secp256k1<All>
[src]
impl<C: Context> Drop for Secp256k1<C>
[src]
impl<C: Context> Eq for Secp256k1<C>
[src]
impl<C: Context> PartialEq<Secp256k1<C>> for Secp256k1<C>
[src]
fn eq(&self, _other: &Secp256k1<C>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<C: Context> Send for Secp256k1<C>
[src]
impl<C: Context> Sync for Secp256k1<C>
[src]
Auto Trait Implementations
impl<C> RefUnwindSafe for Secp256k1<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Unpin for Secp256k1<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for Secp256k1<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,