Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/limit direct sphinx dependency + remove direct curve25519 dependency from wasm client #189

Merged
merged 15 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 49 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions common/clients/mix-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@ tokio = { version = "0.2", features = ["full"] }
## internal
nymsphinx = {path = "../../nymsphinx"}
topology = {path = "../../topology"}

## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="298c7fda6a577daf6d9bb955fa52c2bffecf6926" }
# sphinx = { path = "../../../../sphinx"}

2 changes: 1 addition & 1 deletion common/clients/mix-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use log::*;
use sphinx::SphinxPacket;
use nymsphinx::SphinxPacket;
use std::net::SocketAddr;
use tokio::prelude::*;

Expand Down
23 changes: 12 additions & 11 deletions common/clients/mix-client/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

use nymsphinx::addressing::nodes::{NymNodeRoutingAddress, NymNodeRoutingAddressError};
use sphinx::route::{Destination, DestinationAddressBytes, SURBIdentifier};
use sphinx::SphinxPacket;
use nymsphinx::{
delays, Destination, DestinationAddressBytes, SURBIdentifier, SphinxPacket, SphinxUnwrapError,
};
use std::convert::TryFrom;
use std::net::SocketAddr;
use std::time;
Expand All @@ -26,7 +27,7 @@ pub const LOOP_COVER_MESSAGE_PAYLOAD: &[u8] = b"The cake is a lie!";
pub enum SphinxPacketEncapsulationError {
NoValidProvidersError,
InvalidTopologyError,
SphinxEncapsulationError(sphinx::header::SphinxUnwrapError),
SphinxEncapsulationError(SphinxUnwrapError),
InvalidFirstMixAddress,
}

Expand All @@ -39,8 +40,8 @@ impl From<topology::NymTopologyError> for SphinxPacketEncapsulationError {

// it is correct error we're converting from, it just has an unfortunate name
// related issue: https://github.com/nymtech/sphinx/issues/40
impl From<sphinx::header::SphinxUnwrapError> for SphinxPacketEncapsulationError {
fn from(err: sphinx::header::SphinxUnwrapError) -> Self {
impl From<SphinxUnwrapError> for SphinxPacketEncapsulationError {
fn from(err: SphinxUnwrapError) -> Self {
use SphinxPacketEncapsulationError::*;
SphinxEncapsulationError(err)
}
Expand Down Expand Up @@ -74,7 +75,7 @@ pub fn loop_cover_message<T: NymTopology>(
pub fn loop_cover_message_route(
our_address: DestinationAddressBytes,
surb_id: SURBIdentifier,
route: Vec<sphinx::route::Node>,
route: Vec<nymsphinx::Node>,
average_delay: time::Duration,
) -> Result<(SocketAddr, SphinxPacket), SphinxPacketEncapsulationError> {
let destination = Destination::new(our_address, surb_id);
Expand Down Expand Up @@ -103,10 +104,10 @@ pub fn encapsulate_message<T: NymTopology>(

let route = topology.route_to(provider)?;

let delays = sphinx::header::delays::generate_from_average_duration(route.len(), average_delay);
let delays = delays::generate_from_average_duration(route.len(), average_delay);

// build the packet
let packet = sphinx::SphinxPacket::new(message, &route[..], &recipient, &delays)?;
let packet = SphinxPacket::new(message, &route[..], &recipient, &delays)?;

// we know the mix route must be valid otherwise we would have already returned an error
let first_node_address =
Expand All @@ -118,13 +119,13 @@ pub fn encapsulate_message<T: NymTopology>(
pub fn encapsulate_message_route(
recipient: Destination,
message: Vec<u8>,
route: Vec<sphinx::route::Node>,
route: Vec<nymsphinx::Node>,
average_delay: time::Duration,
) -> Result<(SocketAddr, SphinxPacket), SphinxPacketEncapsulationError> {
let delays = sphinx::header::delays::generate_from_average_duration(route.len(), average_delay);
let delays = delays::generate_from_average_duration(route.len(), average_delay);

// build the packet
let packet = sphinx::SphinxPacket::new(message, &route[..], &recipient, &delays)?;
let packet = SphinxPacket::new(message, &route[..], &recipient, &delays)?;

let first_node_address =
NymNodeRoutingAddress::try_from(route.first().unwrap().address.clone())?;
Expand Down
6 changes: 2 additions & 4 deletions common/clients/provider-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ pretty_env_logger = "0.3"
tokio = { version = "0.2", features = ["full"] }

## internal
sfw-provider-requests = { path = "../../../sfw-provider/sfw-provider-requests" }

## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="298c7fda6a577daf6d9bb955fa52c2bffecf6926" }
nymsphinx = { path = "../../nymsphinx" }
sfw-provider-requests = { path = "../../../sfw-provider/sfw-provider-requests" }
2 changes: 1 addition & 1 deletion common/clients/provider-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

use futures::io::Error;
use log::*;
use nymsphinx::DestinationAddressBytes;
use sfw_provider_requests::auth_token::AuthToken;
use sfw_provider_requests::requests::{
async_io::TokioAsyncRequestWriter, ProviderRequest, PullRequest, RegisterRequest,
};
use sfw_provider_requests::responses::{
async_io::TokioAsyncResponseReader, ProviderResponse, ProviderResponseError,
};
use sphinx::route::DestinationAddressBytes;
use std::net::SocketAddr;
use tokio::prelude::*;

Expand Down
4 changes: 2 additions & 2 deletions common/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ pretty_env_logger = "0.3"
rand = "0.7.2"
rand_core = "0.5"

## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="298c7fda6a577daf6d9bb955fa52c2bffecf6926" }
# internal
nymsphinx = { path = "../nymsphinx" }
2 changes: 1 addition & 1 deletion common/crypto/src/identity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use crate::{encryption, PemStorableKey, PemStorableKeyPair};
use bs58;
use curve25519_dalek::scalar::Scalar;
use sphinx::route::DestinationAddressBytes;
use nymsphinx::DestinationAddressBytes;

// for time being define a dummy identity using x25519 encryption keys (as we've done so far)
// and replace it with proper keys, like ed25519 later on
Expand Down
4 changes: 0 additions & 4 deletions common/healthcheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@ provider-client = { path = "../clients/provider-client" }
sfw-provider-requests = { path = "../../sfw-provider/sfw-provider-requests" }
topology = {path = "../topology" }

## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="298c7fda6a577daf6d9bb955fa52c2bffecf6926" }
# sphinx = { path = "../../../sphinx"}

[dev-dependencies]
5 changes: 2 additions & 3 deletions common/healthcheck/src/path_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ use crypto::identity::MixIdentityKeyPair;
use itertools::Itertools;
use log::{debug, error, info, trace, warn};
use nymsphinx::addressing::nodes::NymNodeRoutingAddress;
use nymsphinx::{Delay, Destination, Node as SphinxNode};
use provider_client::{ProviderClient, ProviderClientError};
use sphinx::header::delays::Delay;
use sphinx::route::{Destination, Node as SphinxNode};
use std::collections::HashMap;
use std::convert::TryFrom;
use std::net::SocketAddr;
Expand Down Expand Up @@ -255,7 +254,7 @@ impl PathChecker {
let delays: Vec<_> = path.iter().map(|_| Delay::new_from_nanos(0)).collect();

// all of the data used to create the packet was created by us
let packet = sphinx::SphinxPacket::new(
let packet = nymsphinx::SphinxPacket::new(
path_identifier.clone(),
&path[..],
&self.our_destination,
Expand Down
2 changes: 1 addition & 1 deletion common/healthcheck/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use crate::path_check::{PathChecker, PathStatus};
use crate::score::NodeScore;
use crypto::identity::MixIdentityKeyPair;
use log::{debug, error, warn};
use nymsphinx::NodeAddressBytes;
use rand_os::rand_core::RngCore;
use sphinx::route::NodeAddressBytes;
use std::collections::HashMap;
use std::fmt::{Error, Formatter};
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion common/healthcheck/src/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use log::error;
use sphinx::route::NodeAddressBytes;
use nymsphinx::NodeAddressBytes;
use std::cmp::Ordering;
use std::fmt::Error;
use std::fmt::Formatter;
Expand Down
3 changes: 1 addition & 2 deletions common/nymsphinx/src/addressing/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

pub use sphinx::constants::NODE_ADDRESS_LENGTH;
use sphinx::route::NodeAddressBytes;
use crate::{NodeAddressBytes, NODE_ADDRESS_LENGTH};
use std::convert::{TryFrom, TryInto};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};

Expand Down
Loading