AsSharedKey

Trait AsSharedKey 

Source
pub trait AsSharedKey {
    type R: RngSingleton;

    // Required methods
    fn from_array(key: [u8; 32]) -> Self
       where Self: Sized;
    fn as_slice(&self) -> &[u8] ;

    // Provided methods
    fn generate() -> Self
       where Self: Sized { ... }
    fn to_chacha_key(
        &self,
    ) -> &GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>> { ... }
}
Expand description

32-byte key shared among sender and receiver secretly.

The reason why this is not a struct but a trait is:

  • shared key should be serialized and encrypted in order to be shared among peers
  • but this -core trait is serialization agnostic.

So, implementators of this trait is expected to have serde::{Serialize, Deserialize} and SerdeSerializePublicKey trait bounds.

Required Associated Types§

Source

type R: RngSingleton

RNG singleton

Required Methods§

Source

fn from_array(key: [u8; 32]) -> Self
where Self: Sized,

Constructor from secret bytes.

Source

fn as_slice(&self) -> &[u8]

Ref to 32-byte slice

Provided Methods§

Source

fn generate() -> Self
where Self: Sized,

Generates secure random key.

Random number generator which implements CryptRng is used internally.

Source

fn to_chacha_key( &self, ) -> &GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>

Makes chacha20poly1305::Key

Implementors§

Source§

impl AsSharedKey for SharedKey

Source§

type R = RngSingletonImpl