pub struct K256KeyPair { /* private fields */ }
Available on crate feature k256 only.
Expand description

A K-256 (secp256k1) public key or keypair

Implementations§

source§

impl K256KeyPair

source

pub fn sign(&self, message: &[u8]) -> Option<[u8; 64]>

Sign a message with the secret key

source

pub fn verify_signature(&self, message: &[u8], signature: &[u8]) -> bool

Verify a signature with the public key

Trait Implementations§

source§

impl Clone for K256KeyPair

source§

fn clone(&self) -> K256KeyPair

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 Debug for K256KeyPair

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromJwk for K256KeyPair

source§

fn from_jwk_parts(jwk: JwkParts<'_>) -> Result<Self, Error>

Import the key from a pre-parsed JWK
source§

fn from_jwk(jwk: &str) -> Result<Self, Error>

Import the key from a JWK string reference
source§

fn from_jwk_slice(jwk: &[u8]) -> Result<Self, Error>

Import the key from a JWK byte slice
source§

impl HasKeyAlg for K256KeyPair

source§

fn algorithm(&self) -> KeyAlg

Get the corresponding key algorithm.
source§

impl KeyExchange for K256KeyPair

source§

fn write_key_exchange( &self, other: &Self, out: &mut dyn WriteBuffer ) -> Result<(), Error>

Perform a key exchange, writing the result to the provided buffer.
source§

fn key_exchange_bytes(&self, other: &Rhs) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Perform a key exchange and return a new allocated buffer.
source§

impl KeyGen for K256KeyPair

source§

fn generate(rng: impl KeyMaterial) -> Result<Self, Error>

Create a new key from a key material generator.
source§

fn random() -> Result<Self, Error>

Generate a new random key.
source§

impl KeyMeta for K256KeyPair

§

type KeySize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

The size of the key secret bytes
source§

impl KeyPublicBytes for K256KeyPair

source§

fn from_public_bytes(key: &[u8]) -> Result<Self, Error>

Create a new key instance from a slice of public key bytes.
source§

fn with_public_bytes<O>(&self, f: impl FnOnce(&[u8]) -> O) -> O

Access a temporary slice of the key public bytes.
source§

impl KeySecretBytes for K256KeyPair

source§

fn from_secret_bytes(key: &[u8]) -> Result<Self, Error>

Create a new key instance from a slice of key secret bytes.
source§

fn with_secret_bytes<O>(&self, f: impl FnOnce(Option<&[u8]>) -> O) -> O

Access a temporary slice of the key secret bytes, if any.
source§

impl KeySigVerify for K256KeyPair

source§

fn verify_signature( &self, message: &[u8], signature: &[u8], sig_type: Option<SignatureType> ) -> Result<bool, Error>

Check the validity of signature over a message with the specified signature type.
source§

impl KeySign for K256KeyPair

source§

fn write_signature( &self, message: &[u8], sig_type: Option<SignatureType>, out: &mut dyn WriteBuffer ) -> Result<(), Error>

Create a signature of the requested type and write it to the provided buffer.
source§

fn create_signature( &self, message: &[u8], sig_type: Option<SignatureType> ) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Create a signature of the requested type and return an allocated buffer.
source§

impl KeypairBytes for K256KeyPair

source§

fn from_keypair_bytes(kp: &[u8]) -> Result<Self, Error>

Create a new key instance from a slice of keypair bytes.
source§

fn with_keypair_bytes<O>(&self, f: impl FnOnce(Option<&[u8]>) -> O) -> O

Create a new key instance from a slice of keypair bytes.
source§

fn to_keypair_bytes_buffer<B: WriteBuffer>( &self, out: &mut B ) -> Result<(), Error>

Write the keypair bytes to a buffer.
source§

fn to_keypair_bytes(&self) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Write the keypair bytes to a new allocated buffer.
source§

impl KeypairMeta for K256KeyPair

§

type PublicKeySize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B1>

The size of the key public bytes
§

type KeypairSize = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B1>

The size of the secret bytes and public bytes combined
source§

impl ToJwk for K256KeyPair

source§

fn encode_jwk(&self, enc: &mut dyn JwkEncoder) -> Result<(), Error>

Write the JWK representation to an encoder
source§

fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>

Available on crate feature alloc only.
Create the JWK thumbprint of the key
source§

fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>

Available on crate feature alloc only.
Create a JWK of the public key
source§

fn to_jwk_secret(&self, alg: Option<KeyAlg>) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Create a JWK of the secret key

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> 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<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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<K> ToPublicBytes for K
where K: KeyPublicBytes,

source§

fn public_bytes_length(&self) -> Result<usize, Error>

Get the length of a public key
source§

fn write_public_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>

Write the key public bytes to a buffer.
source§

fn to_public_bytes(&self) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Write the key public bytes to a new allocated buffer.
source§

impl<K> ToSecretBytes for K
where K: KeySecretBytes,

source§

fn secret_bytes_length(&self) -> Result<usize, Error>

Get the length of a secret key
source§

fn write_secret_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>

Write the key secret bytes to a buffer.
source§

fn to_secret_bytes(&self) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Write the key secret bytes to a new allocated buffer.
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V