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/fix sphinx unwraps #100

Merged
merged 2 commits into from
Jan 24, 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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion common/clients/mix-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ addressing = {path = "../../addressing"}
topology = {path = "../../topology"}

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

2 changes: 1 addition & 1 deletion common/clients/provider-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ tokio = { version = "0.2", features = ["full"] }
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="47c4fbba8272c4aee03cc8165220f33572a96602" }
sphinx = { git = "https://github.com/nymtech/sphinx", rev="c3ba1447d61d6eb900fcdea0c20b3070a22bf11a" }
2 changes: 1 addition & 1 deletion common/healthcheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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="47c4fbba8272c4aee03cc8165220f33572a96602" }
sphinx = { git = "https://github.com/nymtech/sphinx", rev="c3ba1447d61d6eb900fcdea0c20b3070a22bf11a" }
# sphinx = { path = "../../../sphinx"}

[dev-dependencies]
2 changes: 1 addition & 1 deletion common/topology/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ addressing = {path = "../addressing"}
version-checker = {path = "../version-checker" }

## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="47c4fbba8272c4aee03cc8165220f33572a96602" }
sphinx = { git = "https://github.com/nymtech/sphinx", rev="c3ba1447d61d6eb900fcdea0c20b3070a22bf11a" }
# sphinx = { path = "../../../sphinx"}
2 changes: 1 addition & 1 deletion mixnode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ addressing = {path = "../common/addressing" }
directory-client = { path = "../common/clients/directory-client" }

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

[build-dependencies]
built = "0.3.2"
9 changes: 7 additions & 2 deletions mixnode/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Config {
pub enum MixProcessingError {
SphinxRecoveryError,
ReceivedFinalHopError,
SphinxProcessingError,
}

impl From<sphinx::ProcessingError> for MixProcessingError {
Expand Down Expand Up @@ -115,10 +116,14 @@ impl PacketProcessor {
let packet = SphinxPacket::from_bytes(packet_data.to_vec())?;
let (next_packet, next_hop_address, delay) =
match packet.process(processing_data.secret_key) {
ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => {
Ok(ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay)) => {
(packet, address, delay)
}
_ => return Err(MixProcessingError::ReceivedFinalHopError),
Ok(_) => return Err(MixProcessingError::ReceivedFinalHopError),
Err(e) => {
warn!("Failed to unwrap Sphinx pakcet: {:?}", e);
return Err(MixProcessingError::SphinxProcessingError);
}
};

let next_mix = MixPeer::new(next_hop_address);
Expand Down
2 changes: 1 addition & 1 deletion nym-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sfw-provider-requests = { path = "../sfw-provider/sfw-provider-requests" }
topology = {path = "../common/topology" }

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

# putting this explicitly below everything and most likely, the next time we look into it, it will already have a proper release
Expand Down
2 changes: 1 addition & 1 deletion sfw-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ directory-client = { path = "../common/clients/directory-client" }
sfw-provider-requests = { path = "./sfw-provider-requests" }

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

[build-dependencies]
built = "0.3.2"
2 changes: 1 addition & 1 deletion sfw-provider/sfw-provider-requests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sphinx = { git = "https://github.com/nymtech/sphinx", rev="47c4fbba8272c4aee03cc8165220f33572a96602" }
sphinx = { git = "https://github.com/nymtech/sphinx", rev="c3ba1447d61d6eb900fcdea0c20b3070a22bf11a" }
16 changes: 11 additions & 5 deletions sfw-provider/src/provider/mix_handling/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::provider::storage::StoreData;
use crypto::identity::DummyMixIdentityPrivateKey;
use log::warn;
use sphinx::{ProcessedPacket, SphinxPacket};
use std::path::PathBuf;
use std::sync::{Arc, RwLock};
Expand All @@ -8,11 +9,12 @@ use std::sync::{Arc, RwLock};
// DUPLICATE WITH MIXNODE CODE!!!
#[derive(Debug)]
pub enum MixProcessingError {
SphinxRecoveryError,
ReceivedForwardHopError,
FileIOFailure,
InvalidPayload,
NonMatchingRecipient,
FileIOFailure,
ReceivedForwardHopError,
SphinxRecoveryError,
SphinxProcessingError,
}

impl From<sphinx::ProcessingError> for MixProcessingError {
Expand Down Expand Up @@ -63,10 +65,14 @@ impl MixPacketProcessor {
let read_processing_data = processing_data.read().unwrap();
let (client_address, client_surb_id, payload) =
match packet.process(read_processing_data.secret_key.as_scalar()) {
ProcessedPacket::ProcessedPacketFinalHop(client_address, surb_id, payload) => {
Ok(ProcessedPacket::ProcessedPacketFinalHop(client_address, surb_id, payload)) => {
(client_address, surb_id, payload)
}
_ => return Err(MixProcessingError::ReceivedForwardHopError),
Ok(_) => return Err(MixProcessingError::ReceivedForwardHopError),
Err(e) => {
warn!("Error unwrapping Sphinx packet: {:?}", e);
return Err(MixProcessingError::SphinxProcessingError);
}
};

// TODO: should provider try to be recovering plaintext? this would potentially make client retrieve messages of non-constant length,
Expand Down