Enum KeyPair

pub enum KeyPair {
    Ed25519(KeyPair),
    P256(KeyPair),
}
Expand description

pair of cryptographic keys used to sign a token’s block

Variants§

§

Ed25519(KeyPair)

§

P256(KeyPair)

Implementations§

§

impl KeyPair

pub fn new() -> KeyPair

Create a new ed25519 keypair with the default OS RNG

pub fn new_with_algorithm(algorithm: Algorithm) -> KeyPair

Create a new keypair with a chosen algorithm and the default OS RNG

pub fn new_with_rng<T>(algorithm: Algorithm, rng: &mut T) -> KeyPair
where T: RngCore + CryptoRng,

pub fn from(key: &PrivateKey) -> KeyPair

pub fn from_bytes(bytes: &[u8], algorithm: Algorithm) -> Result<KeyPair, Format>

deserializes from a byte array

pub fn sign(&self, data: &[u8]) -> Result<Signature, Format>

pub fn from_private_key_der_with_algorithm( bytes: &[u8], algorithm: Algorithm, ) -> Result<KeyPair, Format>

pub fn from_private_key_der(bytes: &[u8]) -> Result<KeyPair, Format>

pub fn from_private_key_pem_with_algorithm( str: &str, algorithm: Algorithm, ) -> Result<KeyPair, Format>

pub fn from_private_key_pem(str: &str) -> Result<KeyPair, Format>

pub fn to_private_key_der(&self) -> Result<Zeroizing<Vec<u8>>, Format>

pub fn to_private_key_pem(&self) -> Result<Zeroizing<String>, Format>

pub fn private(&self) -> PrivateKey

pub fn public(&self) -> PublicKey

pub fn algorithm(&self) -> Algorithm

Trait Implementations§

§

impl Debug for KeyPair

§

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

Formats the value using the given formatter. Read more
§

impl Default for KeyPair

§

fn default() -> KeyPair

Returns the “default value” for a type. Read more
§

impl PartialEq for KeyPair

§

fn eq(&self, other: &KeyPair) -> 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.
§

impl StructuralPartialEq for KeyPair

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T