Skip to content

Commit ef20979

Browse files
authored
Merge pull request #100 from nymtech/feature/fix-sphinx-unwraps-65
Feature/fix sphinx unwraps
2 parents 18be267 + a187399 commit ef20979

File tree

11 files changed

+27
-16
lines changed

11 files changed

+27
-16
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/clients/mix-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ addressing = {path = "../../addressing"}
1818
topology = {path = "../../topology"}
1919

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

common/clients/provider-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ tokio = { version = "0.2", features = ["full"] }
1616
sfw-provider-requests = { path = "../../../sfw-provider/sfw-provider-requests" }
1717

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

common/healthcheck/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sfw-provider-requests = { path = "../../sfw-provider/sfw-provider-requests" }
2525
topology = {path = "../topology" }
2626

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

3131
[dev-dependencies]

common/topology/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ addressing = {path = "../addressing"}
2020
version-checker = {path = "../version-checker" }
2121

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

mixnode/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ addressing = {path = "../common/addressing" }
2222
directory-client = { path = "../common/clients/directory-client" }
2323

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

2727
[build-dependencies]
2828
built = "0.3.2"

mixnode/src/node/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl Config {
3939
pub enum MixProcessingError {
4040
SphinxRecoveryError,
4141
ReceivedFinalHopError,
42+
SphinxProcessingError,
4243
}
4344

4445
impl From<sphinx::ProcessingError> for MixProcessingError {
@@ -115,10 +116,14 @@ impl PacketProcessor {
115116
let packet = SphinxPacket::from_bytes(packet_data.to_vec())?;
116117
let (next_packet, next_hop_address, delay) =
117118
match packet.process(processing_data.secret_key) {
118-
ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => {
119+
Ok(ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay)) => {
119120
(packet, address, delay)
120121
}
121-
_ => return Err(MixProcessingError::ReceivedFinalHopError),
122+
Ok(_) => return Err(MixProcessingError::ReceivedFinalHopError),
123+
Err(e) => {
124+
warn!("Failed to unwrap Sphinx pakcet: {:?}", e);
125+
return Err(MixProcessingError::SphinxProcessingError);
126+
}
122127
};
123128

124129
let next_mix = MixPeer::new(next_hop_address);

nym-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sfw-provider-requests = { path = "../sfw-provider/sfw-provider-requests" }
4040
topology = {path = "../common/topology" }
4141

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

4646
# putting this explicitly below everything and most likely, the next time we look into it, it will already have a proper release

sfw-provider/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ directory-client = { path = "../common/clients/directory-client" }
2929
sfw-provider-requests = { path = "./sfw-provider-requests" }
3030

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

3434
[build-dependencies]
3535
built = "0.3.2"

sfw-provider/sfw-provider-requests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ edition = "2018"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
sphinx = { git = "https://github.com/nymtech/sphinx", rev="47c4fbba8272c4aee03cc8165220f33572a96602" }
10+
sphinx = { git = "https://github.com/nymtech/sphinx", rev="c3ba1447d61d6eb900fcdea0c20b3070a22bf11a" }

sfw-provider/src/provider/mix_handling/mod.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::provider::storage::StoreData;
22
use crypto::identity::DummyMixIdentityPrivateKey;
3+
use log::warn;
34
use sphinx::{ProcessedPacket, SphinxPacket};
45
use std::path::PathBuf;
56
use std::sync::{Arc, RwLock};
@@ -8,11 +9,12 @@ use std::sync::{Arc, RwLock};
89
// DUPLICATE WITH MIXNODE CODE!!!
910
#[derive(Debug)]
1011
pub enum MixProcessingError {
11-
SphinxRecoveryError,
12-
ReceivedForwardHopError,
12+
FileIOFailure,
1313
InvalidPayload,
1414
NonMatchingRecipient,
15-
FileIOFailure,
15+
ReceivedForwardHopError,
16+
SphinxRecoveryError,
17+
SphinxProcessingError,
1618
}
1719

1820
impl From<sphinx::ProcessingError> for MixProcessingError {
@@ -63,10 +65,14 @@ impl MixPacketProcessor {
6365
let read_processing_data = processing_data.read().unwrap();
6466
let (client_address, client_surb_id, payload) =
6567
match packet.process(read_processing_data.secret_key.as_scalar()) {
66-
ProcessedPacket::ProcessedPacketFinalHop(client_address, surb_id, payload) => {
68+
Ok(ProcessedPacket::ProcessedPacketFinalHop(client_address, surb_id, payload)) => {
6769
(client_address, surb_id, payload)
6870
}
69-
_ => return Err(MixProcessingError::ReceivedForwardHopError),
71+
Ok(_) => return Err(MixProcessingError::ReceivedForwardHopError),
72+
Err(e) => {
73+
warn!("Error unwrapping Sphinx packet: {:?}", e);
74+
return Err(MixProcessingError::SphinxProcessingError);
75+
}
7076
};
7177

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

0 commit comments

Comments
 (0)