pub struct Payload(/* private fields */);Implementations§
Source§impl Payload
impl Payload
Sourcepub fn encapsulate_message<K>(
plaintext_message: &[u8],
payload_keys: &[K],
payload_size: usize,
) -> Result<Self>where
K: for<'a> SphinxPayloadKey<'a>,
pub fn encapsulate_message<K>(
plaintext_message: &[u8],
payload_keys: &[K],
payload_size: usize,
) -> Result<Self>where
K: for<'a> SphinxPayloadKey<'a>,
Tries to encapsulate provided plaintext message inside a sphinx payload adding as many layers of encryption as there are keys provided. Note that the encryption layers are going to be added in reverse order!
Sourcepub fn unwrap<P: Borrow<PayloadKey>>(self, payload_key: P) -> Result<Self>
pub fn unwrap<P: Borrow<PayloadKey>>(self, payload_key: P) -> Result<Self>
Tries to remove single layer of encryption from self.
Sourcepub fn recover_plaintext(self) -> Result<Vec<u8>>
pub fn recover_plaintext(self) -> Result<Vec<u8>>
After calling [unwrap] required number of times with correct payload_keys, tries to parse
the resultant payload content into original encapsulated plaintext message.
pub fn len(&self) -> usize
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Convert this Payload as a vector of bytes.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Tries to recover Payload from a slice of bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Payload
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnwindSafe for Payload
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