diff --git a/Cargo.lock b/Cargo.lock index 090c0ae3f7d..27f61ec5a61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2098,7 +2098,7 @@ dependencies = [ [[package]] name = "sphinx" version = "0.1.0" -source = "git+https://github.com/nymtech/sphinx?rev=47c4fbba8272c4aee03cc8165220f33572a96602#47c4fbba8272c4aee03cc8165220f33572a96602" +source = "git+https://github.com/nymtech/sphinx?rev=c3ba1447d61d6eb900fcdea0c20b3070a22bf11a#c3ba1447d61d6eb900fcdea0c20b3070a22bf11a" dependencies = [ "aes-ctr", "arrayref", diff --git a/common/clients/mix-client/Cargo.toml b/common/clients/mix-client/Cargo.toml index ccfba9d9e36..dcd16d33d5d 100644 --- a/common/clients/mix-client/Cargo.toml +++ b/common/clients/mix-client/Cargo.toml @@ -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"} diff --git a/common/clients/provider-client/Cargo.toml b/common/clients/provider-client/Cargo.toml index 07c368f9d6f..1c1d87b7b11 100644 --- a/common/clients/provider-client/Cargo.toml +++ b/common/clients/provider-client/Cargo.toml @@ -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" } diff --git a/common/healthcheck/Cargo.toml b/common/healthcheck/Cargo.toml index 834a72c65e2..aaacb88d660 100644 --- a/common/healthcheck/Cargo.toml +++ b/common/healthcheck/Cargo.toml @@ -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] diff --git a/common/topology/Cargo.toml b/common/topology/Cargo.toml index 6e0e65bf508..905df9f2da2 100644 --- a/common/topology/Cargo.toml +++ b/common/topology/Cargo.toml @@ -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"} diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index d02f8bcc225..52db3fa9b6b 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -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" diff --git a/mixnode/src/node/mod.rs b/mixnode/src/node/mod.rs index 1ae4b6e65db..78f49f33f13 100644 --- a/mixnode/src/node/mod.rs +++ b/mixnode/src/node/mod.rs @@ -39,6 +39,7 @@ impl Config { pub enum MixProcessingError { SphinxRecoveryError, ReceivedFinalHopError, + SphinxProcessingError, } impl From for MixProcessingError { @@ -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); diff --git a/nym-client/Cargo.toml b/nym-client/Cargo.toml index 24f30726df8..eade92dd4b0 100644 --- a/nym-client/Cargo.toml +++ b/nym-client/Cargo.toml @@ -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 diff --git a/sfw-provider/Cargo.toml b/sfw-provider/Cargo.toml index bce8917ad10..7bea6173d0e 100644 --- a/sfw-provider/Cargo.toml +++ b/sfw-provider/Cargo.toml @@ -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" diff --git a/sfw-provider/sfw-provider-requests/Cargo.toml b/sfw-provider/sfw-provider-requests/Cargo.toml index 0f31948e501..9b207791e38 100644 --- a/sfw-provider/sfw-provider-requests/Cargo.toml +++ b/sfw-provider/sfw-provider-requests/Cargo.toml @@ -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" } diff --git a/sfw-provider/src/provider/mix_handling/mod.rs b/sfw-provider/src/provider/mix_handling/mod.rs index 1670311dd16..c7a4e8cc02d 100644 --- a/sfw-provider/src/provider/mix_handling/mod.rs +++ b/sfw-provider/src/provider/mix_handling/mod.rs @@ -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}; @@ -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 for MixProcessingError { @@ -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,