Skip to content

Commit

Permalink
Guard gateway server code from compiling for wasm (client)
Browse files Browse the repository at this point in the history
  • Loading branch information
neacsu committed Aug 5, 2021
1 parent d7a4982 commit b4f5f6a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 3 additions & 0 deletions gateway/gateway-requests/src/registration/handshake/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use self::client::ClientHandshake;
use self::error::HandshakeError;
#[cfg(not(target_arch = "wasm32"))]
use self::gateway::GatewayHandshake;
pub use self::shared_key::{SharedKeySize, SharedKeys};
use crypto::asymmetric::identity;
Expand All @@ -14,6 +15,7 @@ pub(crate) type WsItem = Result<WsMessage, WsError>;

mod client;
pub mod error;
#[cfg(not(target_arch = "wasm32"))]
mod gateway;
pub mod shared_key;
mod state;
Expand All @@ -36,6 +38,7 @@ where
ClientHandshake::new(rng, ws_stream, identity, gateway_pubkey, coconut_credential).await
}

#[cfg(not(target_arch = "wasm32"))]
pub async fn gateway_handshake<'a, S>(
rng: &mut (impl RngCore + CryptoRng),
ws_stream: &'a mut S,
Expand Down
6 changes: 6 additions & 0 deletions gateway/gateway-requests/src/registration/handshake/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ impl InitMessage {
}
}

#[cfg(not(target_arch = "wasm32"))]
pub fn local_id_pubkey(&self) -> identity::PublicKey {
identity::PublicKey::from_bytes(&self.local_id_pubkey).unwrap()
}

#[cfg(not(target_arch = "wasm32"))]
pub fn ephemeral_key(&self) -> encryption::PublicKey {
encryption::PublicKey::from_bytes(&self.ephemeral_key).unwrap()
}

#[cfg(not(target_arch = "wasm32"))]
pub fn credential(&self) -> Credential {
self.credential.clone().unwrap()
}
Expand Down Expand Up @@ -107,6 +110,7 @@ impl<'a, S> State<'a, S> {
}
}

#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn local_ephemeral_key(&self) -> &encryption::PublicKey {
self.ephemeral_keypair.public_key()
}
Expand All @@ -124,6 +128,7 @@ impl<'a, S> State<'a, S> {
}

// this will need to be adjusted when REMOTE_ID_PUBKEY is removed
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn parse_init_message(init_message: Vec<u8>) -> Result<InitMessage, HandshakeError> {
match InitMessage::try_from(init_message.as_slice()) {
Ok(init_message) => Ok(init_message),
Expand Down Expand Up @@ -225,6 +230,7 @@ impl<'a, S> State<'a, S> {
.map_err(|_| HandshakeError::InvalidSignature)
}

#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn update_remote_identity(&mut self, remote_pubkey: identity::PublicKey) {
self.remote_pubkey = Some(remote_pubkey)
}
Expand Down
1 change: 0 additions & 1 deletion validator-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ coconut-rs = { git = "https://github.com/nymtech/coconut.git", branch = "0.4.0"
config = { path = "../common/config" }
crypto = { path = "../common/crypto" }
gateway-client = { path = "../common/client-libs/gateway-client" }
gateway-requests = { path = "../gateway/gateway-requests" }
mixnet-contract = { path = "../common/mixnet-contract" }
nymsphinx = { path = "../common/nymsphinx" }
topology = { path = "../common/topology" }
Expand Down

0 comments on commit b4f5f6a

Please sign in to comment.