Struct libp2p::noise::Keypair

source ·
pub struct Keypair<T>where
    T: Zeroize,{ /* private fields */ }
Expand description

DH keypair.

Implementations§

source§

impl Keypair<X25519>

source

pub fn new() -> Keypair<X25519>

Create a new X25519 keypair.

source

pub fn from_identity(id_keys: &Keypair) -> Option<AuthenticKeypair<X25519>>

Creates an X25519 Keypair from an identity::Keypair, if possible.

The returned keypair will be associated with the given identity keypair.

Returns None if the given identity keypair cannot be used as an X25519 keypair.

Note: If the identity keypair is already used in the context of other cryptographic protocols outside of Noise, it should be preferred to create a new static X25519 keypair for use in the Noise protocol.

See also:

source§

impl Keypair<X25519Spec>

source

pub fn new() -> Keypair<X25519Spec>

Create a new X25519 keypair.

source§

impl<T> Keypair<T>where T: Zeroize,

source

pub fn public(&self) -> &PublicKey<T>

The public key of the DH keypair.

source

pub fn secret(&self) -> &SecretKey<T>

The secret key of the DH keypair.

source

pub fn into_authentic( self, id_keys: &Keypair ) -> Result<AuthenticKeypair<T>, NoiseError>where T: AsRef<[u8]> + Protocol<T>,

Turn this DH keypair into a AuthenticKeypair, i.e. a DH keypair that is authentic w.r.t. the given identity keypair, by signing the DH public key.

Trait Implementations§

source§

impl<T> Clone for Keypair<T>where T: Clone + Zeroize,

source§

fn clone(&self) -> Keypair<T>

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 Default for Keypair<X25519>

source§

fn default() -> Keypair<X25519>

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

impl Default for Keypair<X25519Spec>

source§

fn default() -> Keypair<X25519Spec>

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

impl From<SecretKey<X25519>> for Keypair<X25519>

Promote a X25519 secret key into a keypair.

source§

fn from(secret: SecretKey<X25519>) -> Keypair<X25519>

Converts to this type from the input type.
source§

impl From<SecretKey<X25519Spec>> for Keypair<X25519Spec>

Promote a X25519 secret key into a keypair.

source§

fn from(secret: SecretKey<X25519Spec>) -> Keypair<X25519Spec>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Keypair<T>where T: RefUnwindSafe,

§

impl<T> Send for Keypair<T>where T: Send,

§

impl<T> Sync for Keypair<T>where T: Sync,

§

impl<T> Unpin for Keypair<T>where T: Unpin,

§

impl<T> UnwindSafe for Keypair<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

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

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

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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<T, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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