pub struct Envelope {
pub ephemeral_pub: [u8; 32],
pub nonce: [u8; 12],
pub ciphertext: Vec<u8>,
}Expand description
Decrypt-able envelope produced by encrypt. Carries the sender’s
ephemeral X25519 pubkey + the AEAD nonce + the ciphertext-with-tag.
Envelope::to_bytes / Envelope::from_bytes handle the
substrate-stable wire shape; storage callers persist the bytes
verbatim into the encrypted_envelope column.
Fields§
§ephemeral_pub: [u8; 32]§nonce: [u8; 12]§ciphertext: Vec<u8>Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialise the envelope to its on-disk byte layout. See module docs for the layout. Length = 1 + 32 + 12 + ciphertext.len().
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Parse the envelope back out of its on-disk byte layout. Refuses unknown versions and truncated buffers with a typed error so a corrupted row surfaces cleanly instead of decrypting garbage.
§Errors
- Returns
Errwhen the buffer is too short to contain the fixed header (version + ephemeral_pub + nonce) plus at least one byte of ciphertext-with-tag. - Returns
Errwhen the leading version byte is notENVELOPE_VERSION.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more