pub struct SphinxPacket(/* private fields */);Expand description
Fixed-size (32KB) encrypted packet: [Header: 1024][Nonce: 12][Ciphertext + Tag].
Implementations§
Source§impl SphinxPacket
impl SphinxPacket
Sourcepub fn new(
payload: &[u8],
key: &[u8; 32],
nonce: &[u8; 12],
) -> Result<Self, PacketError>
pub fn new( payload: &[u8], key: &[u8; 32], nonce: &[u8; 12], ) -> Result<Self, PacketError>
Encrypts a variable-length payload into a fixed-size 32KB packet.
Sourcepub fn unwrap(&self, key: &[u8; 32]) -> Result<Vec<u8>, PacketError>
pub fn unwrap(&self, key: &[u8; 32]) -> Result<Vec<u8>, PacketError>
Decrypts and unpads the packet to recover the original payload.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consumes the packet, returning the underlying buffer.
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Self, PacketError>
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, PacketError>
Creates a SphinxPacket from raw bytes. Fails if not exactly PACKET_SIZE.
Sourcepub fn header_mut(&mut self) -> &mut [u8] ⓘ
pub fn header_mut(&mut self) -> &mut [u8] ⓘ
Mutable access to the header section for Sphinx routing info.
Trait Implementations§
Source§impl Clone for SphinxPacket
impl Clone for SphinxPacket
Source§fn clone(&self) -> SphinxPacket
fn clone(&self) -> SphinxPacket
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SphinxPacket
impl RefUnwindSafe for SphinxPacket
impl Send for SphinxPacket
impl Sync for SphinxPacket
impl Unpin for SphinxPacket
impl UnsafeUnpin for SphinxPacket
impl UnwindSafe for SphinxPacket
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,
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