Outfox framing
This commit is contained in:
Generated
-15
@@ -370,15 +370,6 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bip32"
|
||||
version = "0.3.0"
|
||||
@@ -4060,7 +4051,6 @@ dependencies = [
|
||||
name = "nym-outfox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"blake3",
|
||||
"chacha20",
|
||||
"chacha20poly1305",
|
||||
@@ -4069,7 +4059,6 @@ dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.2.9",
|
||||
"rayon",
|
||||
"serde",
|
||||
"sphinx-packet",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
@@ -4353,11 +4342,9 @@ dependencies = [
|
||||
name = "nym-sphinx-framing"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytes",
|
||||
"nym-sphinx-params",
|
||||
"nym-sphinx-types",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"tokio-util",
|
||||
]
|
||||
@@ -4367,7 +4354,6 @@ name = "nym-sphinx-params"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"nym-crypto",
|
||||
"nym-outfox",
|
||||
"nym-sphinx-types",
|
||||
"serde",
|
||||
"thiserror",
|
||||
@@ -4387,7 +4373,6 @@ name = "nym-sphinx-types"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"nym-outfox",
|
||||
"serde",
|
||||
"sphinx-packet",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@@ -11,8 +11,6 @@ repository = { workspace = true }
|
||||
bytes = "1.0"
|
||||
tokio-util = { version = "0.7.4", features = ["codec"] }
|
||||
thiserror = "1.0.37"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
bincode = "1"
|
||||
|
||||
nym-sphinx-types = { path = "../types" }
|
||||
nym-sphinx-params = { path = "../params" }
|
||||
|
||||
@@ -5,8 +5,9 @@ use crate::packet::{FramedNymPacket, Header};
|
||||
use bytes::{Buf, BufMut, BytesMut};
|
||||
use nym_sphinx_params::packet_modes::InvalidPacketMode;
|
||||
use nym_sphinx_params::packet_sizes::{InvalidPacketSize, PacketSize};
|
||||
use nym_sphinx_types::SphinxPacket;
|
||||
use nym_sphinx_params::PacketMode;
|
||||
use nym_sphinx_types::{NymPacket, NymPacketError, SphinxError};
|
||||
use nym_sphinx_types::{OutfoxError, OutfoxPacket, SphinxPacket};
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
use tokio_util::codec::{Decoder, Encoder};
|
||||
@@ -22,6 +23,9 @@ pub enum NymCodecError {
|
||||
#[error("the actual sphinx packet was malformed - {0}")]
|
||||
MalformedSphinxPacket(#[from] SphinxError),
|
||||
|
||||
#[error("the actual outfox packet was malformed - {0}")]
|
||||
MalformedOutfoxPacket(#[from] OutfoxError),
|
||||
|
||||
#[error("encountered an IO error - {0}")]
|
||||
IoError(#[from] io::Error),
|
||||
|
||||
@@ -55,7 +59,8 @@ impl Encoder<FramedNymPacket> for NymCodec {
|
||||
|
||||
fn encode(&mut self, item: FramedNymPacket, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
||||
item.header.encode(dst);
|
||||
dst.put(item.packet.to_bytes()?.as_slice());
|
||||
let packet_bytes = item.packet.to_bytes()?;
|
||||
dst.put(packet_bytes.as_slice());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -123,16 +128,21 @@ impl Decoder for NymCodec {
|
||||
|
||||
// advance buffer past the header - at this point we have enough bytes
|
||||
src.advance(header.size());
|
||||
let sphinx_packet_bytes = src.split_to(packet_size);
|
||||
|
||||
// here it could be debatable whether stream is corrupt or not,
|
||||
// but let's go with the safer approach and assume it is.
|
||||
let packet = SphinxPacket::from_bytes(&sphinx_packet_bytes)?;
|
||||
let nymsphinx_packet = FramedNymPacket {
|
||||
header,
|
||||
packet: NymPacket::Sphinx(packet),
|
||||
let packet_bytes = src.split_to(packet_size);
|
||||
let packet = if let Some(slice) = packet_bytes.get(..) {
|
||||
// here it could be debatable whether stream is corrupt or not,
|
||||
// but let's go with the safer approach and assume it is.
|
||||
match header.packet_mode {
|
||||
PacketMode::Outfox => NymPacket::Outfox(OutfoxPacket::try_from(slice)?),
|
||||
_ => NymPacket::Sphinx(SphinxPacket::from_bytes(slice)?),
|
||||
}
|
||||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
// let packet = SphinxPacket::from_bytes(&sphinx_packet_bytes)?;
|
||||
let nymsphinx_packet = FramedNymPacket { header, packet };
|
||||
|
||||
// As per docs:
|
||||
// Before returning from the function, implementations should ensure that the buffer
|
||||
// has appropriate capacity in anticipation of future calls to decode.
|
||||
@@ -159,7 +169,6 @@ impl Decoder for NymCodec {
|
||||
};
|
||||
}
|
||||
src.reserve(allocate_for_next_packet);
|
||||
|
||||
Ok(Some(nymsphinx_packet))
|
||||
}
|
||||
}
|
||||
@@ -170,9 +179,33 @@ mod packet_encoding {
|
||||
use nym_sphinx_types::builder::SphinxPacketBuilder;
|
||||
use nym_sphinx_types::{
|
||||
crypto, Delay as SphinxDelay, Destination, DestinationAddressBytes, Node, NodeAddressBytes,
|
||||
DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, NODE_ADDRESS_LENGTH,
|
||||
DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, NODE_ADDRESS_LENGTH, OUTFOX_PACKET_OVERHEAD,
|
||||
};
|
||||
|
||||
fn make_valid_outfox_packet(size: PacketSize) -> OutfoxPacket {
|
||||
let (_, node1_pk) = crypto::keygen();
|
||||
let node1 = Node::new(
|
||||
NodeAddressBytes::from_bytes([5u8; NODE_ADDRESS_LENGTH]),
|
||||
node1_pk,
|
||||
);
|
||||
let (_, node2_pk) = crypto::keygen();
|
||||
let node2 = Node::new(
|
||||
NodeAddressBytes::from_bytes([4u8; NODE_ADDRESS_LENGTH]),
|
||||
node2_pk,
|
||||
);
|
||||
let (_, node3_pk) = crypto::keygen();
|
||||
let node3 = Node::new(
|
||||
NodeAddressBytes::from_bytes([2u8; NODE_ADDRESS_LENGTH]),
|
||||
node3_pk,
|
||||
);
|
||||
|
||||
let route = [node1, node2, node3];
|
||||
|
||||
let payload = vec![1; 48];
|
||||
|
||||
OutfoxPacket::build(&payload, &route, Some(size.size() - OUTFOX_PACKET_OVERHEAD)).unwrap()
|
||||
}
|
||||
|
||||
fn make_valid_sphinx_packet(size: PacketSize) -> SphinxPacket {
|
||||
let (_, node1_pk) = crypto::keygen();
|
||||
let node1 = Node::new(
|
||||
@@ -225,6 +258,27 @@ mod packet_encoding {
|
||||
assert_eq!(decoded.packet.to_bytes().unwrap(), sphinx_bytes)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn whole_outfox_can_be_decoded_from_a_valid_encoded_instance() {
|
||||
let header = Header::outfox();
|
||||
let packet = make_valid_outfox_packet(PacketSize::OutfoxRegularPacket);
|
||||
let packet_bytes = packet.to_bytes().unwrap();
|
||||
|
||||
OutfoxPacket::try_from(packet_bytes.as_slice()).unwrap();
|
||||
|
||||
let packet = FramedNymPacket {
|
||||
header,
|
||||
packet: NymPacket::Outfox(packet),
|
||||
};
|
||||
|
||||
let mut bytes = BytesMut::new();
|
||||
NymCodec.encode(packet, &mut bytes).unwrap();
|
||||
let decoded = NymCodec.decode(&mut bytes).unwrap().unwrap();
|
||||
|
||||
assert_eq!(decoded.header, header);
|
||||
assert_eq!(decoded.packet.to_bytes().unwrap(), packet_bytes)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod decode_will_allocate_enough_bytes_for_next_call {
|
||||
use super::*;
|
||||
|
||||
@@ -7,10 +7,9 @@ use nym_sphinx_params::packet_sizes::PacketSize;
|
||||
use nym_sphinx_params::packet_version::PacketVersion;
|
||||
use nym_sphinx_params::PacketMode;
|
||||
use nym_sphinx_types::NymPacket;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct FramedNymPacket {
|
||||
/// Contains any metadata helping receiver to handle the underlying packet.
|
||||
pub(crate) header: Header,
|
||||
@@ -55,7 +54,7 @@ impl FramedNymPacket {
|
||||
// Contains any metadata that might be useful for sending between mix nodes.
|
||||
// TODO: in theory all those data could be put in a single `u8` by setting appropriate bits,
|
||||
// but would that really be worth it?
|
||||
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
|
||||
pub struct Header {
|
||||
/// Represents the wire format version used to construct this packet.
|
||||
pub(crate) packet_version: PacketVersion,
|
||||
@@ -79,6 +78,14 @@ impl Header {
|
||||
pub(crate) const LEGACY_SIZE: usize = 2;
|
||||
pub(crate) const VERSIONED_SIZE: usize = 3;
|
||||
|
||||
pub fn outfox() -> Header {
|
||||
Header {
|
||||
packet_version: PacketVersion::default(),
|
||||
packet_size: PacketSize::OutfoxRegularPacket,
|
||||
packet_mode: PacketMode::Outfox,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn size(&self) -> usize {
|
||||
if self.packet_version.is_legacy() {
|
||||
Self::LEGACY_SIZE
|
||||
|
||||
@@ -13,4 +13,3 @@ serde = { workspace = true, features = ["derive"] }
|
||||
|
||||
nym-crypto = { path = "../../crypto", features = ["hashing", "symmetric"] }
|
||||
nym-sphinx-types = { path = "../types" }
|
||||
nym-outfox = { "path" = "../../../nym-outfox" }
|
||||
|
||||
@@ -22,6 +22,9 @@ pub enum PacketMode {
|
||||
/// Represents a VPN packet that should not be delayed and ideally cached pre-computed keys
|
||||
/// should be used for unwrapping data. Note that it does not offer the same level of anonymity.
|
||||
Vpn = 1,
|
||||
|
||||
/// Abusing this to add Outfox support
|
||||
Outfox = 2,
|
||||
}
|
||||
|
||||
impl PacketMode {
|
||||
@@ -32,6 +35,10 @@ impl PacketMode {
|
||||
pub fn is_old_vpn(self) -> bool {
|
||||
self == PacketMode::Vpn
|
||||
}
|
||||
|
||||
pub fn is_outfox(self) -> bool {
|
||||
self == PacketMode::Outfox
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for PacketMode {
|
||||
@@ -41,6 +48,7 @@ impl TryFrom<u8> for PacketMode {
|
||||
match value {
|
||||
_ if value == (PacketMode::Mix as u8) => Ok(Self::Mix),
|
||||
_ if value == (PacketMode::Vpn as u8) => Ok(Self::Vpn),
|
||||
_ if value == (PacketMode::Outfox as u8) => Ok(Self::Outfox),
|
||||
v => Err(InvalidPacketMode { received: v }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::FRAG_ID_LEN;
|
||||
use nym_outfox::packet::OUTFOX_PACKET_OVERHEAD;
|
||||
use nym_sphinx_types::header::HEADER_SIZE;
|
||||
use nym_sphinx_types::PAYLOAD_OVERHEAD_SIZE;
|
||||
use nym_sphinx_types::{OUTFOX_PACKET_OVERHEAD, PAYLOAD_OVERHEAD_SIZE};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::convert::TryFrom;
|
||||
@@ -164,6 +163,17 @@ impl TryFrom<u8> for PacketSize {
|
||||
_ if value == (PacketSize::ExtendedPacket8 as u8) => Ok(Self::ExtendedPacket8),
|
||||
_ if value == (PacketSize::ExtendedPacket16 as u8) => Ok(Self::ExtendedPacket16),
|
||||
_ if value == (PacketSize::ExtendedPacket32 as u8) => Ok(Self::ExtendedPacket32),
|
||||
_ if value == (PacketSize::OutfoxRegularPacket as u8) => Ok(Self::OutfoxRegularPacket),
|
||||
_ if value == (PacketSize::OutfoxAckPacket as u8) => Ok(Self::OutfoxAckPacket),
|
||||
_ if value == (PacketSize::OutfoxExtendedPacket8 as u8) => {
|
||||
Ok(Self::OutfoxExtendedPacket8)
|
||||
}
|
||||
_ if value == (PacketSize::OutfoxExtendedPacket16 as u8) => {
|
||||
Ok(Self::OutfoxExtendedPacket16)
|
||||
}
|
||||
_ if value == (PacketSize::OutfoxExtendedPacket32 as u8) => {
|
||||
Ok(Self::OutfoxExtendedPacket32)
|
||||
}
|
||||
v => Err(InvalidPacketSize::UnknownPacketTag { received: v }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,5 @@ repository = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
sphinx-packet = { version = "0.1.0" }
|
||||
serde = "1"
|
||||
nym-outfox = { path = "../../../nym-outfox" }
|
||||
thiserror = "1"
|
||||
|
||||
[patch.crates-io]
|
||||
sphinx-packet = { path = "../../../../sphinx" }
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub use nym_outfox::{error::OutfoxError, packet::OutfoxPacket};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
pub use nym_outfox::{error::OutfoxError, packet::OutfoxPacket, packet::OUTFOX_PACKET_OVERHEAD};
|
||||
// re-exporting types and constants available in sphinx
|
||||
pub use sphinx_packet::{
|
||||
constants::{
|
||||
@@ -17,6 +16,7 @@ pub use sphinx_packet::{
|
||||
surb::{SURBMaterial, SURB},
|
||||
Error as SphinxError, ProcessedPacket, SphinxPacket,
|
||||
};
|
||||
use std::fmt;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -75,50 +75,3 @@ impl NymPacket {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for NymPacket {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_bytes(&self.to_bytes().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::de::{self, Visitor};
|
||||
|
||||
struct NymPacketVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for NymPacketVisitor {
|
||||
type Value = NymPacket;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("Byte encoded NymPacket")
|
||||
}
|
||||
|
||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
match SphinxPacket::from_bytes(v) {
|
||||
Ok(packet) => Ok(NymPacket::Sphinx(packet)),
|
||||
Err(_) => match OutfoxPacket::from_bytes(v) {
|
||||
Ok(packet) => Ok(NymPacket::Outfox(packet)),
|
||||
Err(_) => Err(E::custom(
|
||||
"Could not deserialize Outfox nor Sphinx packet from bytes",
|
||||
)),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for NymPacket {
|
||||
fn deserialize<D>(deserializer: D) -> Result<NymPacket, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
deserializer.deserialize_bytes(NymPacketVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+459
@@ -3,13 +3,30 @@
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "aead"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "aes"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
<<<<<<< HEAD
|
||||
"cipher",
|
||||
=======
|
||||
"cipher 0.3.0",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"cpufeatures",
|
||||
"ctr",
|
||||
"opaque-debug 0.3.0",
|
||||
@@ -21,7 +38,11 @@ version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"getrandom 0.2.8",
|
||||
=======
|
||||
"getrandom 0.2.9",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
@@ -39,6 +60,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545"
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "arrayvec"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -87,12 +117,42 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "blake3"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"constant_time_eq",
|
||||
"digest 0.10.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "block-buffer"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -151,12 +211,54 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "chacha20"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cipher 0.4.4",
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chacha20poly1305"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
|
||||
dependencies = [
|
||||
"aead",
|
||||
"chacha20",
|
||||
"cipher 0.4.4",
|
||||
"poly1305",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "cipher"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"inout",
|
||||
"zeroize",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -191,6 +293,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3"
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "constant_time_eq"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b"
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "cosmwasm-crypto"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -251,14 +362,66 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
<<<<<<< HEAD
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
|
||||
=======
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -270,13 +433,31 @@ version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"rand_core 0.6.4",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
"rand_core 0.6.4",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "crypto-mac"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -292,7 +473,11 @@ version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
@@ -302,7 +487,11 @@ version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"cipher",
|
||||
=======
|
||||
"cipher 0.3.0",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -498,7 +687,22 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
|
||||
dependencies = [
|
||||
"block-buffer 0.10.4",
|
||||
"crypto-common",
|
||||
"subtle 2.4.1",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -536,7 +740,11 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"ed25519",
|
||||
<<<<<<< HEAD
|
||||
"rand 0.7.3",
|
||||
=======
|
||||
"rand",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"serde",
|
||||
"sha2",
|
||||
"zeroize",
|
||||
@@ -573,7 +781,11 @@ dependencies = [
|
||||
"crypto-bigint",
|
||||
"der",
|
||||
"ff",
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"group",
|
||||
"rand_core 0.6.4",
|
||||
"sec1",
|
||||
@@ -663,6 +875,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e"
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "futures"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -758,6 +971,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
=======
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -768,9 +983,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
<<<<<<< HEAD
|
||||
version = "0.14.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
|
||||
=======
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
@@ -791,6 +1012,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
<<<<<<< HEAD
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||
@@ -798,6 +1020,17 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
=======
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -847,6 +1080,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||
@@ -904,6 +1149,18 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "inout"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -918,7 +1175,11 @@ version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"hermit-abi",
|
||||
=======
|
||||
"hermit-abi 0.3.1",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
@@ -1019,9 +1280,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
<<<<<<< HEAD
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f"
|
||||
=======
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
|
||||
[[package]]
|
||||
name = "lioness"
|
||||
@@ -1045,10 +1312,20 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
=======
|
||||
name = "memoffset"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
|
||||
[[package]]
|
||||
name = "mixnet-vesting-integration-tests"
|
||||
@@ -1077,6 +1354,19 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "num_cpus"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
|
||||
dependencies = [
|
||||
"hermit-abi 0.2.6",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "nym-coconut-bandwidth"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
@@ -1146,17 +1436,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-crypto"
|
||||
<<<<<<< HEAD
|
||||
version = "0.3.0"
|
||||
=======
|
||||
version = "0.2.0"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"ed25519-dalek",
|
||||
"nym-pemstore",
|
||||
"nym-sphinx-types",
|
||||
<<<<<<< HEAD
|
||||
"rand 0.7.3",
|
||||
"subtle-encoding",
|
||||
"thiserror",
|
||||
"x25519-dalek",
|
||||
"zeroize",
|
||||
=======
|
||||
"rand",
|
||||
"subtle-encoding",
|
||||
"thiserror",
|
||||
"x25519-dalek",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1223,6 +1524,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "nym-name-service"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
@@ -1250,6 +1552,21 @@ dependencies = [
|
||||
"cosmwasm-std",
|
||||
"schemars",
|
||||
"serde",
|
||||
=======
|
||||
name = "nym-outfox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"chacha20",
|
||||
"chacha20poly1305",
|
||||
"curve25519-dalek",
|
||||
"fastrand",
|
||||
"getrandom 0.2.9",
|
||||
"rayon",
|
||||
"sphinx-packet",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1283,7 +1600,10 @@ name = "nym-service-provider-directory-common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
<<<<<<< HEAD
|
||||
"schemars",
|
||||
=======
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -1291,7 +1611,13 @@ dependencies = [
|
||||
name = "nym-sphinx-types"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"sphinx-packet",
|
||||
=======
|
||||
"nym-outfox",
|
||||
"sphinx-packet",
|
||||
"thiserror",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1364,6 +1690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1376,6 +1703,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
=======
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "pkcs8"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1393,6 +1722,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "poly1305"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
|
||||
dependencies = [
|
||||
"cpufeatures",
|
||||
"opaque-debug 0.3.0",
|
||||
"universal-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1424,9 +1767,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
<<<<<<< HEAD
|
||||
version = "1.0.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
|
||||
=======
|
||||
version = "1.0.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -1483,6 +1832,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1494,6 +1844,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
=======
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1528,7 +1880,11 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"getrandom 0.2.8",
|
||||
=======
|
||||
"getrandom 0.2.9",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1538,7 +1894,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
<<<<<<< HEAD
|
||||
"rand 0.7.3",
|
||||
=======
|
||||
"rand",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1551,6 +1911,31 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "rayon"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1586,6 +1971,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "rstest"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1612,6 +1998,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
=======
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1622,9 +2010,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
<<<<<<< HEAD
|
||||
version = "0.37.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
|
||||
=======
|
||||
version = "0.37.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
@@ -1683,13 +2077,26 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "sec1"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1"
|
||||
dependencies = [
|
||||
"der",
|
||||
<<<<<<< HEAD
|
||||
"generic-array 0.14.6",
|
||||
=======
|
||||
"generic-array 0.14.7",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"pkcs8",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
@@ -1727,7 +2134,11 @@ checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
<<<<<<< HEAD
|
||||
"syn 2.0.12",
|
||||
=======
|
||||
"syn 2.0.15",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1760,7 +2171,11 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
<<<<<<< HEAD
|
||||
"syn 2.0.12",
|
||||
=======
|
||||
"syn 2.0.15",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1769,7 +2184,11 @@ version = "0.9.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
|
||||
dependencies = [
|
||||
<<<<<<< HEAD
|
||||
"block-buffer",
|
||||
=======
|
||||
"block-buffer 0.9.0",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
@@ -1787,6 +2206,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "slab"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1796,6 +2216,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
=======
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "sphinx-packet"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -1813,7 +2235,11 @@ dependencies = [
|
||||
"hmac",
|
||||
"lioness",
|
||||
"log",
|
||||
<<<<<<< HEAD
|
||||
"rand 0.7.3",
|
||||
=======
|
||||
"rand",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
"rand_distr",
|
||||
"sha2",
|
||||
"subtle 2.4.1",
|
||||
@@ -1869,9 +2295,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
<<<<<<< HEAD
|
||||
version = "2.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927"
|
||||
=======
|
||||
version = "2.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1908,7 +2340,11 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
<<<<<<< HEAD
|
||||
"syn 2.0.12",
|
||||
=======
|
||||
"syn 2.0.15",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1973,9 +2409,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
<<<<<<< HEAD
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d502c968c6a838ead8e69b2ee18ec708802f99db92a0d156705ec9ef801993b"
|
||||
=======
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
@@ -1993,6 +2435,19 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
name = "universal-hash"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
name = "url"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
@@ -2267,5 +2722,9 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
<<<<<<< HEAD
|
||||
"syn 2.0.12",
|
||||
=======
|
||||
"syn 2.0.15",
|
||||
>>>>>>> 8c48dccac (Outfox framing)
|
||||
]
|
||||
|
||||
Generated
+1
-15
@@ -217,15 +217,6 @@ version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bip32"
|
||||
version = "0.3.0"
|
||||
@@ -3567,14 +3558,13 @@ dependencies = [
|
||||
name = "nym-outfox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"blake3",
|
||||
"chacha20",
|
||||
"chacha20poly1305",
|
||||
"curve25519-dalek",
|
||||
"fastrand",
|
||||
"getrandom 0.2.8",
|
||||
"rayon",
|
||||
"serde",
|
||||
"sphinx-packet",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
@@ -3767,11 +3757,9 @@ dependencies = [
|
||||
name = "nym-sphinx-framing"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytes",
|
||||
"nym-sphinx-params",
|
||||
"nym-sphinx-types",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"tokio-util",
|
||||
]
|
||||
@@ -3781,7 +3769,6 @@ name = "nym-sphinx-params"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"nym-crypto",
|
||||
"nym-outfox",
|
||||
"nym-sphinx-types",
|
||||
"serde",
|
||||
"thiserror",
|
||||
@@ -3801,7 +3788,6 @@ name = "nym-sphinx-types"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"nym-outfox",
|
||||
"serde",
|
||||
"sphinx-packet",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@@ -15,8 +15,7 @@ chacha20poly1305 = "0.10.1"
|
||||
# Need this star over here to pull in js into getrandom
|
||||
getrandom = { version = "*", features = ["js"] }
|
||||
thiserror = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
bincode = "1"
|
||||
fastrand = "1.8"
|
||||
|
||||
sphinx-packet = "0.1.0"
|
||||
|
||||
@@ -26,4 +25,3 @@ sphinx-packet = { path = "../../../../sphinx" }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.4"
|
||||
fastrand = "1.8"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::array::TryFromSliceError;
|
||||
|
||||
use crate::format::MIX_PARAMS_LEN;
|
||||
use crate::lion::MIN_MESSAGE_LEN;
|
||||
use chacha20::cipher::InvalidLength;
|
||||
use thiserror::Error;
|
||||
@@ -24,6 +25,6 @@ pub enum OutfoxError {
|
||||
#[from]
|
||||
source: TryFromSliceError,
|
||||
},
|
||||
#[error("Could not serialize OutfoxPacket!")]
|
||||
Bincode,
|
||||
#[error("Header length must be {MIX_PARAMS_LEN}, got {0}")]
|
||||
InvalidHeaderLength(usize),
|
||||
}
|
||||
|
||||
+98
-30
@@ -62,14 +62,21 @@ use chacha20poly1305::Tag;
|
||||
use curve25519_dalek::constants::ED25519_BASEPOINT_TABLE;
|
||||
use curve25519_dalek::montgomery::MontgomeryPoint;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sphinx_packet::route::Node;
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub const GROUPELEMENTBYTES: usize = 32;
|
||||
pub const TAGBYTES: usize = 16;
|
||||
pub const GROUPELEMENTBYTES: u8 = 32;
|
||||
pub const TAGBYTES: u8 = 16;
|
||||
pub const MIX_PARAMS_LEN: usize = 5;
|
||||
|
||||
pub const fn groupelementbytes() -> usize {
|
||||
GROUPELEMENTBYTES as usize
|
||||
}
|
||||
|
||||
pub const fn tagbytes() -> usize {
|
||||
TAGBYTES as usize
|
||||
}
|
||||
|
||||
use std::ops::Range;
|
||||
use std::u8;
|
||||
@@ -77,21 +84,48 @@ use std::u8;
|
||||
use crate::error::OutfoxError;
|
||||
use crate::lion::*;
|
||||
use crate::packet::DEFAULT_ROUTING_INFO_SIZE;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
/// A structure that holds mix packet construction parameters. These incluse the length
|
||||
/// of the routing information at each hop, the number of hops, and the payload length.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Eq, PartialEq, Debug)]
|
||||
pub struct MixCreationParameters {
|
||||
/// The routing length is inner first, so \[0\] is the innermost routing length, etc (in bytes)
|
||||
/// In our stratified topology this will always be 3
|
||||
pub routing_information_length_by_stage: [usize; 3],
|
||||
pub routing_information_length_by_stage: [u8; 3],
|
||||
/// The payload length (in bytes)
|
||||
pub payload_length_bytes: usize,
|
||||
pub payload_length_bytes: u16,
|
||||
}
|
||||
|
||||
impl TryFrom<&[u8]> for MixCreationParameters {
|
||||
type Error = OutfoxError;
|
||||
|
||||
fn try_from(v: &[u8]) -> Result<Self, Self::Error> {
|
||||
if v.len() != MIX_PARAMS_LEN {
|
||||
return Err(OutfoxError::InvalidHeaderLength(v.len()));
|
||||
}
|
||||
let (routing, payload) = v.split_at(3);
|
||||
Ok(MixCreationParameters {
|
||||
routing_information_length_by_stage: routing.try_into()?,
|
||||
payload_length_bytes: u16::from_le_bytes(payload.try_into()?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl MixCreationParameters {
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut bytes = Vec::with_capacity(5);
|
||||
bytes.extend_from_slice(self.routing_information_length_by_stage.as_slice());
|
||||
bytes.extend_from_slice(&self.payload_length_bytes.to_le_bytes());
|
||||
bytes
|
||||
}
|
||||
|
||||
pub fn payload_length_bytes(&self) -> usize {
|
||||
self.payload_length_bytes as usize
|
||||
}
|
||||
|
||||
/// Create a set of parameters for a mix packet format.
|
||||
pub fn new(payload_length_bytes: usize) -> MixCreationParameters {
|
||||
pub fn new(payload_length_bytes: u16) -> MixCreationParameters {
|
||||
MixCreationParameters {
|
||||
routing_information_length_by_stage: [DEFAULT_ROUTING_INFO_SIZE; 3],
|
||||
payload_length_bytes,
|
||||
@@ -106,9 +140,9 @@ impl MixCreationParameters {
|
||||
|
||||
/// The length of the buffer needed to build a packet.
|
||||
pub fn total_packet_length(&self) -> usize {
|
||||
let mut len = self.payload_length_bytes;
|
||||
let mut len = self.payload_length_bytes();
|
||||
for stage_len in &self.routing_information_length_by_stage {
|
||||
len += stage_len + GROUPELEMENTBYTES + TAGBYTES
|
||||
len += *stage_len as usize + groupelementbytes() + tagbytes()
|
||||
}
|
||||
len
|
||||
}
|
||||
@@ -131,7 +165,7 @@ impl MixCreationParameters {
|
||||
|
||||
return (total_size - inner_size..total_size, params);
|
||||
} else {
|
||||
remaining_header_length_bytes += stage_len + GROUPELEMENTBYTES + TAGBYTES;
|
||||
remaining_header_length_bytes += (stage_len + GROUPELEMENTBYTES + TAGBYTES) as u16;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,47 +176,59 @@ impl MixCreationParameters {
|
||||
/// A structure representing the parameters of a single stage of mixing.
|
||||
pub struct MixStageParameters {
|
||||
/// The routing information length for this stage of mixing
|
||||
pub routing_information_length_bytes: usize,
|
||||
pub routing_information_length_bytes: u8,
|
||||
/// The reamining header length for this stage of mixing
|
||||
pub remaining_header_length_bytes: usize,
|
||||
pub remaining_header_length_bytes: u16,
|
||||
/// The payload length
|
||||
pub payload_length_bytes: usize,
|
||||
pub payload_length_bytes: u16,
|
||||
}
|
||||
|
||||
impl MixStageParameters {
|
||||
pub fn routing_information_length_bytes(&self) -> usize {
|
||||
self.routing_information_length_bytes as usize
|
||||
}
|
||||
|
||||
pub fn remaining_header_length_bytes(&self) -> usize {
|
||||
self.remaining_header_length_bytes as usize
|
||||
}
|
||||
|
||||
pub fn payload_length_bytes(&self) -> usize {
|
||||
self.payload_length_bytes as usize
|
||||
}
|
||||
|
||||
pub fn incoming_packet_length(&self) -> usize {
|
||||
GROUPELEMENTBYTES + TAGBYTES + self.outgoing_packet_length()
|
||||
groupelementbytes() + tagbytes() + self.outgoing_packet_length()
|
||||
}
|
||||
|
||||
pub fn outgoing_packet_length(&self) -> usize {
|
||||
self.routing_information_length_bytes
|
||||
+ self.remaining_header_length_bytes
|
||||
+ self.payload_length_bytes
|
||||
self.routing_information_length_bytes()
|
||||
+ self.remaining_header_length_bytes()
|
||||
+ self.payload_length_bytes()
|
||||
}
|
||||
|
||||
pub fn pub_element_range(&self) -> Range<usize> {
|
||||
0..GROUPELEMENTBYTES
|
||||
0..groupelementbytes()
|
||||
}
|
||||
|
||||
pub fn tag_range(&self) -> Range<usize> {
|
||||
GROUPELEMENTBYTES..GROUPELEMENTBYTES + TAGBYTES
|
||||
groupelementbytes()..groupelementbytes() + tagbytes()
|
||||
}
|
||||
|
||||
pub fn routing_data_range(&self) -> Range<usize> {
|
||||
GROUPELEMENTBYTES + TAGBYTES
|
||||
..GROUPELEMENTBYTES + TAGBYTES + self.routing_information_length_bytes
|
||||
groupelementbytes() + tagbytes()
|
||||
..groupelementbytes() + tagbytes() + self.routing_information_length_bytes()
|
||||
}
|
||||
|
||||
pub fn header_range(&self) -> Range<usize> {
|
||||
GROUPELEMENTBYTES + TAGBYTES
|
||||
..GROUPELEMENTBYTES
|
||||
+ TAGBYTES
|
||||
+ self.routing_information_length_bytes
|
||||
+ self.remaining_header_length_bytes
|
||||
groupelementbytes() + tagbytes()
|
||||
..groupelementbytes()
|
||||
+ tagbytes()
|
||||
+ self.routing_information_length_bytes()
|
||||
+ self.remaining_header_length_bytes()
|
||||
}
|
||||
|
||||
pub fn payload_range(&self) -> Range<usize> {
|
||||
self.incoming_packet_length() - self.payload_length_bytes..self.incoming_packet_length()
|
||||
self.incoming_packet_length() - self.payload_length_bytes()..self.incoming_packet_length()
|
||||
}
|
||||
|
||||
pub fn encode_mix_layer(
|
||||
@@ -202,10 +248,10 @@ impl MixStageParameters {
|
||||
});
|
||||
}
|
||||
|
||||
if routing_data.len() != self.routing_information_length_bytes {
|
||||
if routing_data.len() != self.routing_information_length_bytes() {
|
||||
return Err(OutfoxError::LenMismatch {
|
||||
expected: routing_data.len(),
|
||||
got: self.routing_information_length_bytes,
|
||||
got: self.routing_information_length_bytes(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -277,3 +323,25 @@ impl MixStageParameters {
|
||||
Ok(shared_key)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::MixCreationParameters;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
#[test]
|
||||
fn test_to_bytes() {
|
||||
let mix_params = MixCreationParameters::new(1024);
|
||||
assert_eq!(mix_params.to_bytes(), vec![32, 32, 32, 0, 4])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_bytes() {
|
||||
let params_bytes = vec![32, 32, 32, 0, 4];
|
||||
let mix_params = MixCreationParameters::new(1024);
|
||||
assert_eq!(
|
||||
mix_params,
|
||||
MixCreationParameters::try_from(params_bytes.as_slice()).unwrap()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
use std::iter::repeat_with;
|
||||
|
||||
pub mod error;
|
||||
pub mod format;
|
||||
pub mod lion;
|
||||
pub mod packet;
|
||||
|
||||
pub fn randombytes(n: usize) -> Vec<u8> {
|
||||
repeat_with(|| fastrand::u8(..)).take(n).collect()
|
||||
}
|
||||
|
||||
+30
-20
@@ -1,52 +1,62 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::Range;
|
||||
use std::{convert::TryFrom, ops::Range};
|
||||
|
||||
use crate::{
|
||||
error::OutfoxError,
|
||||
format::{MixCreationParameters, MixStageParameters, GROUPELEMENTBYTES, TAGBYTES},
|
||||
format::{
|
||||
groupelementbytes, tagbytes, MixCreationParameters, MixStageParameters, MIX_PARAMS_LEN,
|
||||
},
|
||||
randombytes,
|
||||
};
|
||||
|
||||
use sphinx_packet::{packet::builder::DEFAULT_PAYLOAD_SIZE, route::Node};
|
||||
|
||||
pub const OUTFOX_PACKET_OVERHEAD: usize =
|
||||
3 * DEFAULT_ROUTING_INFO_SIZE + GROUPELEMENTBYTES + TAGBYTES;
|
||||
MIX_PARAMS_LEN + (groupelementbytes() + tagbytes() + DEFAULT_ROUTING_INFO_SIZE as usize) * 3;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Debug)]
|
||||
pub struct OutfoxPacket {
|
||||
mix_params: MixCreationParameters,
|
||||
payload: Vec<u8>,
|
||||
}
|
||||
|
||||
pub const DEFAULT_ROUTING_INFO_SIZE: usize = 32;
|
||||
pub const DEFAULT_ROUTING_INFO_SIZE: u8 = 32;
|
||||
|
||||
impl TryFrom<&[u8]> for OutfoxPacket {
|
||||
type Error = OutfoxError;
|
||||
|
||||
fn try_from(v: &[u8]) -> Result<Self, Self::Error> {
|
||||
let (header, payload) = v.split_at(MIX_PARAMS_LEN);
|
||||
Ok(OutfoxPacket {
|
||||
mix_params: MixCreationParameters::try_from(header)?,
|
||||
payload: payload.to_vec(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl OutfoxPacket {
|
||||
pub fn len(&self) -> usize {
|
||||
self.mix_params().total_packet_length() + self.payload.len()
|
||||
self.mix_params().total_packet_length()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
||||
// TODO: Replace with lightweight methods
|
||||
pub fn to_bytes(&self) -> Result<Vec<u8>, OutfoxError> {
|
||||
bincode::serialize(self).map_err(|_e| OutfoxError::Bincode)
|
||||
}
|
||||
|
||||
pub fn from_bytes(v: &[u8]) -> Result<Self, OutfoxError> {
|
||||
bincode::deserialize(v).map_err(|_| OutfoxError::Bincode)
|
||||
let mut bytes = vec![];
|
||||
bytes.extend(self.mix_params.to_bytes());
|
||||
bytes.extend(self.payload.as_slice());
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
pub fn build(
|
||||
payload: &[u8],
|
||||
route: &[Node; 3],
|
||||
user_secret_key: &[u8],
|
||||
packet_size: Option<usize>,
|
||||
) -> Result<OutfoxPacket, OutfoxError> {
|
||||
let mix_params = MixCreationParameters::new(DEFAULT_PAYLOAD_SIZE);
|
||||
|
||||
// for node in route.iter() {
|
||||
// mix_params.add_outer_layer(node.address.as_bytes_ref().len());
|
||||
// }
|
||||
let secret_key = randombytes(32);
|
||||
let packet_size = packet_size.unwrap_or(DEFAULT_PAYLOAD_SIZE);
|
||||
let mix_params = MixCreationParameters::new(packet_size as u16);
|
||||
|
||||
let padding = mix_params.total_packet_length() - payload.len();
|
||||
let mut buffer = vec![0; padding];
|
||||
@@ -54,7 +64,7 @@ impl OutfoxPacket {
|
||||
|
||||
for (idx, node) in route.iter().rev().enumerate() {
|
||||
let (range, stage_params) = mix_params.get_stage_params(idx);
|
||||
stage_params.encode_mix_layer(&mut buffer[range], user_secret_key, node)?;
|
||||
stage_params.encode_mix_layer(&mut buffer[range], &secret_key, node)?;
|
||||
}
|
||||
|
||||
Ok(OutfoxPacket {
|
||||
|
||||
@@ -6,22 +6,17 @@ mod tests {
|
||||
use curve25519_dalek::constants::ED25519_BASEPOINT_TABLE;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
use nym_outfox::packet::OutfoxPacket;
|
||||
use nym_outfox::randombytes;
|
||||
use sphinx_packet::constants::NODE_ADDRESS_LENGTH;
|
||||
use sphinx_packet::crypto::PublicKey;
|
||||
use sphinx_packet::packet::builder::DEFAULT_PAYLOAD_SIZE;
|
||||
use sphinx_packet::route::Node;
|
||||
use sphinx_packet::route::NodeAddressBytes;
|
||||
use std::convert::TryFrom;
|
||||
use std::convert::TryInto;
|
||||
|
||||
use nym_outfox::format::*;
|
||||
use nym_outfox::lion::*;
|
||||
|
||||
use std::iter::repeat_with;
|
||||
|
||||
pub fn randombytes(n: usize) -> Vec<u8> {
|
||||
repeat_with(|| fastrand::u8(..)).take(n).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_encode_decode() {
|
||||
let mix_params = MixStageParameters {
|
||||
@@ -81,8 +76,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_packet_params() {
|
||||
let user_secret = randombytes(32);
|
||||
|
||||
let (node1_pk, node1_pub) = sphinx_packet::crypto::keygen();
|
||||
let node1 = Node::new(
|
||||
NodeAddressBytes::from_bytes([0u8; NODE_ADDRESS_LENGTH]),
|
||||
@@ -101,9 +94,17 @@ mod tests {
|
||||
|
||||
let route = [node1, node2, node3];
|
||||
|
||||
let payload = randombytes(DEFAULT_PAYLOAD_SIZE);
|
||||
let payload = randombytes(2048);
|
||||
|
||||
let mut packet = OutfoxPacket::build(&payload, &route, &user_secret).unwrap();
|
||||
let packet = OutfoxPacket::build(&payload, &route, Some(2048)).unwrap();
|
||||
let packet_bytes = packet.to_bytes().unwrap();
|
||||
println!(
|
||||
"packet bytes length, {}, declared {}",
|
||||
packet_bytes.len(),
|
||||
packet.len()
|
||||
);
|
||||
|
||||
let mut packet = OutfoxPacket::try_from(packet_bytes.as_slice()).unwrap();
|
||||
|
||||
packet.decode_mix_layer(2, &node1_pk.to_bytes()).unwrap();
|
||||
packet.decode_mix_layer(1, &node2_pk.to_bytes()).unwrap();
|
||||
|
||||
Generated
+563
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user