Struct BlsKeyPair

Source
pub struct BlsKeyPair<Pk: BlsPublicKeyType> { /* private fields */ }
Available on crate feature bls only.
Expand description

A BLS12-381 key pair

Implementations§

Source§

impl<Pk: BlsPublicKeyType> BlsKeyPair<Pk>

Source

pub fn from_seed(seed: &[u8]) -> Result<Self, Error>

Generate a new BLS key from a seed according to the KeyGen algorithm

Source

pub fn bls_public_key(&self) -> &Pk::Buffer

Accessor for the associated public key

Source

pub fn bls_secret_scalar(&self) -> Option<&Scalar>

Accessor for the associated secret key value, if any

Trait Implementations§

Source§

impl<Pk: Clone + BlsPublicKeyType> Clone for BlsKeyPair<Pk>
where Pk::Buffer: Clone,

Source§

fn clone(&self) -> BlsKeyPair<Pk>

Returns a duplicate 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<Pk: BlsPublicKeyType> Debug for BlsKeyPair<Pk>

Source§

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

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

impl From<&BlsKeyPair<G1G2>> for BlsKeyPair<G1>

Source§

fn from(kp: &BlsKeyPair<G1G2>) -> Self

Converts to this type from the input type.
Source§

impl From<&BlsKeyPair<G1G2>> for BlsKeyPair<G2>

Source§

fn from(kp: &BlsKeyPair<G1G2>) -> Self

Converts to this type from the input type.
Source§

impl<Pk: BlsPublicKeyType> FromJwk for BlsKeyPair<Pk>

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<Pk: BlsPublicKeyType> HasKeyAlg for BlsKeyPair<Pk>

Source§

fn algorithm(&self) -> KeyAlg

Get the corresponding key algorithm.
Source§

impl<Pk: BlsPublicKeyType> HasKeyBackend for BlsKeyPair<Pk>

Source§

fn key_backend(&self) -> KeyBackend

Get the corresponding key backend.
Source§

impl<Pk: BlsPublicKeyType> KeyGen for BlsKeyPair<Pk>

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<Pk: BlsPublicKeyType> KeyMeta for BlsKeyPair<Pk>

Source§

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

The size of the key secret bytes
Source§

impl<Pk: BlsPublicKeyType> KeyPublicBytes for BlsKeyPair<Pk>
where Self: KeypairMeta,

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<Pk: BlsPublicKeyType> KeySecretBytes for BlsKeyPair<Pk>

Source§

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

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<Pk> KeypairMeta for BlsKeyPair<Pk>

Source§

type PublicKeySize = <Pk as BlsPublicKeyType>::BufferSize

The size of the key public bytes
Source§

type KeypairSize = <<BlsKeyPair<Pk> as KeyMeta>::KeySize as Add<<Pk as BlsPublicKeyType>::BufferSize>>::Output

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

impl<Pk: BlsPublicKeyType> PartialEq for BlsKeyPair<Pk>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Pk: BlsPublicKeyType> ToJwk for BlsKeyPair<Pk>

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

impl<Pk: BlsPublicKeyType> Zeroize for BlsKeyPair<Pk>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<Pk: BlsPublicKeyType> Eq for BlsKeyPair<Pk>

Auto Trait Implementations§

§

impl<Pk> Freeze for BlsKeyPair<Pk>
where <Pk as BlsPublicKeyType>::Buffer: Freeze,

§

impl<Pk> RefUnwindSafe for BlsKeyPair<Pk>

§

impl<Pk> Send for BlsKeyPair<Pk>
where <Pk as BlsPublicKeyType>::Buffer: Send,

§

impl<Pk> Sync for BlsKeyPair<Pk>
where <Pk as BlsPublicKeyType>::Buffer: Sync,

§

impl<Pk> Unpin for BlsKeyPair<Pk>
where <Pk as BlsPublicKeyType>::Buffer: Unpin,

§

impl<Pk> UnwindSafe for BlsKeyPair<Pk>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Source§

type Output = T

Should always be Self
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<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>,

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

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

Source§

fn vzip(self) -> V