pub struct NoiseTranscoder<const LEN_SIZE: usize> {
    pub encryptor: NoiseEncryptor<LEN_SIZE>,
    pub decryptor: NoiseDecryptor<LEN_SIZE>,
}
Expand description

Returned after a successful handshake to encrypt and decrypt communication with peer nodes. It should not normally be manually instantiated. Automatically handles key rotation. For decryption, it is recommended to call decrypt_message_stream for automatic buffering.

Fields§

§encryptor: NoiseEncryptor<LEN_SIZE>§decryptor: NoiseDecryptor<LEN_SIZE>

Implementations§

source§

impl<const LEN_SIZE: usize> NoiseTranscoder<LEN_SIZE>

source

pub fn with(
sending_key: [u8; 32],
receiving_key: [u8; 32],
chaining_key: [u8; 32],
remote_pubkey: PublicKey
) -> Self

Instantiate a new Conduit with specified sending and receiving keys

source

pub fn remote_pubkey(&self) -> PublicKey

source

pub fn encrypt_buf(&mut self, buffer: &[u8]) -> Result<Vec<u8>, EncryptionError>

Encrypt data to be sent to peer

source

pub fn read_buf(&mut self, data: &[u8])

source

pub fn decrypt_single_message(
&mut self,
new_data: Option<&[u8]>
) -> Result<Option<Vec<u8>>, EncryptionError>

Decrypt a single message. If data containing more than one message has been received, only the first message will be returned, and the rest stored in the internal buffer. If a message pending in the buffer still hasn’t been decrypted, that message will be returned in lieu of anything new, even if new data is provided.

Trait Implementations§

source§

impl<const LEN_SIZE: usize> Bipolar for NoiseTranscoder<LEN_SIZE>

§

type Left = <NoiseTranscoder<LEN_SIZE> as Transcode>::Decryptor

First separable type (like reader)
§

type Right = <NoiseTranscoder<LEN_SIZE> as Transcode>::Encryptor

Second separable type (like writer)
source§

fn join(decryptor: Self::Left, encryptor: Self::Right) -> Self

Reconstruct the type from the halves
source§

fn split(self) -> (Self::Left, Self::Right)

Split the type into two
source§

impl<const LEN_SIZE: usize> Debug for NoiseTranscoder<LEN_SIZE>

source§

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

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

impl<const LEN_SIZE: usize> Decrypt for NoiseTranscoder<LEN_SIZE>

§

type Error = HandshakeError

source§

fn decrypt(&mut self, buffer: impl Borrow<[u8]>) -> Result<Vec<u8>, Self::Error>

source§

impl<const LEN_SIZE: usize> Encrypt for NoiseTranscoder<LEN_SIZE>

source§

fn encrypt(&mut self, buffer: impl Borrow<[u8]>) -> Vec<u8>

source§

impl<const LEN_SIZE: usize> Transcode for NoiseTranscoder<LEN_SIZE>

§

type Encryptor = NoiseEncryptor<LEN_SIZE>

§

type Decryptor = NoiseDecryptor<LEN_SIZE>

Auto Trait Implementations§

§

impl<const LEN_SIZE: usize> RefUnwindSafe for NoiseTranscoder<LEN_SIZE>

§

impl<const LEN_SIZE: usize> Send for NoiseTranscoder<LEN_SIZE>

§

impl<const LEN_SIZE: usize> Sync for NoiseTranscoder<LEN_SIZE>

§

impl<const LEN_SIZE: usize> Unpin for NoiseTranscoder<LEN_SIZE>

§

impl<const LEN_SIZE: usize> UnwindSafe for NoiseTranscoder<LEN_SIZE>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V