pub struct OnionReturn {
pub nonce: Nonce,
pub payload: Vec<u8>,
}
Expand description
Encrypted onion return addresses. Payload contains encrypted with symmetric
key IpPort
and possibly inner OnionReturn
.
When DHT node receives OnionRequest packet it appends OnionReturn
to the end
of the next request packet it will send. So when DHT node receives OnionResponse
packet it will know where to send the next response packet by decrypting
OnionReturn
from received packet. If node can’t decrypt OnionReturn
that
means that onion path is expired and packet should be dropped.
Serialized form:
Length | Content |
---|---|
24 | Nonce |
35 or 94 or 153 | Payload |
where payload is encrypted inner OnionReturn
Fields§
§nonce: Nonce
Nonce for the current encrypted payload
payload: Vec<u8>
Encrypted payload
Implementations§
Source§impl OnionReturn
impl OnionReturn
Sourcepub fn new(
symmetric_key: &Key,
ip_port: &IpPort,
inner: Option<&OnionReturn>,
) -> OnionReturn
pub fn new( symmetric_key: &Key, ip_port: &IpPort, inner: Option<&OnionReturn>, ) -> OnionReturn
Create new OnionReturn
object using symmetric key for encryption.
Sourcepub fn get_payload(
&self,
symmetric_key: &Key,
) -> Result<(IpPort, Option<OnionReturn>), Error>
pub fn get_payload( &self, symmetric_key: &Key, ) -> Result<(IpPort, Option<OnionReturn>), Error>
Decrypt payload with symmetric key and try to parse it as IpPort
with possibly inner OnionReturn
.
Returns Error
in case of failure:
- fails to decrypt
- fails to parse as
IpPort
with possibly innerOnionReturn
Trait Implementations§
Source§impl Clone for OnionReturn
impl Clone for OnionReturn
Source§fn clone(&self) -> OnionReturn
fn clone(&self) -> OnionReturn
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for OnionReturn
impl Debug for OnionReturn
Source§impl FromBytes for OnionReturn
impl FromBytes for OnionReturn
Source§fn from_bytes(i: &[u8]) -> IResult<&[u8], OnionReturn, (&[u8], ErrorKind)>
fn from_bytes(i: &[u8]) -> IResult<&[u8], OnionReturn, (&[u8], ErrorKind)>
nom
from raw bytes