k256::schnorr

Struct SigningKey

Source
pub struct SigningKey { /* private fields */ }
Expand description

Taproot Schnorr signing key.

Implementations§

Source§

impl SigningKey

Source

pub fn random(rng: &mut impl CryptoRngCore) -> Self

Generate a cryptographically random SigningKey.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Parse signing key from big endian-encoded bytes.

Source

pub fn to_bytes(&self) -> FieldBytes

Serialize as bytes.

Source

pub fn verifying_key(&self) -> &VerifyingKey

Get the VerifyingKey that corresponds to this signing key.

Source

pub fn as_nonzero_scalar(&self) -> &NonZeroScalar

Borrow the secret NonZeroScalar value for this key.

§⚠️ Warning

This value is key material.

Please treat it with the care it deserves!

Source

pub fn sign_prehash_with_aux_rand( &self, msg_digest: &[u8; 32], aux_rand: &[u8; 32], ) -> Result<Signature>

Compute Schnorr signature.

§⚠️ Warning

This is a low-level interface intended only for unusual use cases involving signing pre-hashed messages.

The preferred interfaces are the Signer or RandomizedSigner traits.

Source

pub fn sign_raw(&self, msg: &[u8], aux_rand: &[u8; 32]) -> Result<Signature>

Compute Schnorr signature.

§⚠️ Warning

This is a low-level interface intended only for unusual use cases involving signing pre-hashed messages, or “raw” messages where the message is not hashed at all prior to being used to generate the Schnorr signature.

The preferred interfaces are the Signer or RandomizedSigner traits.

Trait Implementations§

Source§

impl AsRef<VerifyingKey> for SigningKey

Source§

fn as_ref(&self) -> &VerifyingKey

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for SigningKey

Source§

fn clone(&self) -> SigningKey

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D> DigestSigner<D, Signature> for SigningKey
where D: Digest + FixedOutput<OutputSize = U32>,

Source§

fn try_sign_digest(&self, digest: D) -> Result<Signature>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
Source§

fn sign_digest(&self, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl Drop for SigningKey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&SecretKey<Secp256k1>> for SigningKey

Source§

fn from(secret_key: &SecretKey) -> SigningKey

Converts to this type from the input type.
Source§

impl From<NonZeroScalar<Secp256k1>> for SigningKey

Source§

fn from(secret_key: NonZeroScalar) -> SigningKey

Converts to this type from the input type.
Source§

impl From<SecretKey<Secp256k1>> for SigningKey

Source§

fn from(secret_key: SecretKey) -> SigningKey

Converts to this type from the input type.
Source§

impl KeypairRef for SigningKey

Source§

type VerifyingKey = VerifyingKey

Verifying key type for this keypair.
Source§

impl PrehashSigner<Signature> for SigningKey

Source§

fn sign_prehash(&self, prehash: &[u8]) -> Result<Signature>

Attempt to sign the given message digest, returning a digital signature on success, or an error if something went wrong. Read more
Source§

impl<D> RandomizedDigestSigner<D, Signature> for SigningKey
where D: Digest + FixedOutput<OutputSize = U32>,

Source§

fn try_sign_digest_with_rng( &self, rng: &mut impl CryptoRngCore, digest: D, ) -> Result<Signature>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
Source§

fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl RandomizedPrehashSigner<Signature> for SigningKey

Source§

fn sign_prehash_with_rng( &self, rng: &mut impl CryptoRngCore, prehash: &[u8], ) -> Result<Signature>

Attempt to sign the given message digest, returning a digital signature on success, or an error if something went wrong. Read more
Source§

impl RandomizedSigner<Signature> for SigningKey

Source§

fn try_sign_with_rng( &self, rng: &mut impl CryptoRngCore, msg: &[u8], ) -> Result<Signature>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl Signer<Signature> for SigningKey

Source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl ZeroizeOnDrop for SigningKey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<K> Keypair for K
where K: KeypairRef,

Source§

type VerifyingKey = <K as KeypairRef>::VerifyingKey

Verifying key type for this keypair.
Source§

fn verifying_key(&self) -> <K as Keypair>::VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S, T> SignerMut<S> for T
where T: Signer<S>,

Source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.