Skip to content

Commit

Permalink
Make clients call with their keypairs
Browse files Browse the repository at this point in the history
  • Loading branch information
neacsu committed Aug 11, 2021
1 parent e073998 commit b348f47
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clients/native/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl NymClient {
self.runtime.block_on(async {
let coconut_credential = Credential::init(
self.config.get_base().get_validator_rest_endpoints(),
*self.key_manager.identity_keypair().public_key(),
self.key_manager.identity_keypair(),
)
.await
.expect("Could not initialize coconut credential");
Expand Down
2 changes: 1 addition & 1 deletion clients/native/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async fn register_with_gateway(
validator_urls: Vec<String>,
) -> SharedKeys {
let timeout = Duration::from_millis(1500);
let coconut_credential = Credential::init(validator_urls, *our_identity.public_key())
let coconut_credential = Credential::init(validator_urls, Arc::clone(&our_identity))
.await
.expect("Could not initialize coconut credential");
let mut gateway_client = GatewayClient::new_init(
Expand Down
2 changes: 1 addition & 1 deletion clients/socks5/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl NymClient {
self.runtime.block_on(async {
let coconut_credential = Credential::init(
self.config.get_base().get_validator_rest_endpoints(),
*self.key_manager.identity_keypair().public_key(),
self.key_manager.identity_keypair(),
)
.await
.expect("Could not initialize coconut credential");
Expand Down
2 changes: 1 addition & 1 deletion clients/socks5/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async fn register_with_gateway(
validator_urls: Vec<String>,
) -> SharedKeys {
let timeout = Duration::from_millis(1500);
let coconut_credential = Credential::init(validator_urls, *our_identity.public_key())
let coconut_credential = Credential::init(validator_urls, Arc::clone(&our_identity))
.await
.expect("Could not initialize coconut credential");
let mut gateway_client = GatewayClient::new_init(
Expand Down
4 changes: 2 additions & 2 deletions clients/webassembly/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ impl NymClient {
// Right now it's impossible to have async exported functions to take `&self` rather than self
pub async fn initial_setup(self) -> Self {
let validator_server = self.validator_server.clone();
let identity_public_key = self.identity.public_key().clone();
let identity = Arc::clone(&self.identity);
let mut client = self.get_and_update_topology().await;
let gateway = client.choose_gateway();

let (mixnet_messages_sender, mixnet_messages_receiver) = mpsc::unbounded();
let (ack_sender, ack_receiver) = mpsc::unbounded();

let coconut_credential = Credential::init(vec![validator_server], identity_public_key)
let coconut_credential = Credential::init(vec![validator_server], identity)
.await
.expect("Could not initialize coconut credential");

Expand Down
8 changes: 5 additions & 3 deletions common/coconut-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use serde::{Deserialize, Serialize};
use sha2::digest::generic_array::typenum::Unsigned;
use sha2::Sha256;
use std::convert::TryFrom;
use std::sync::Arc;
use url::Url;

use crate::error::CoconutInterfaceError;
pub use coconut_rs::*;
use crypto::asymmetric::identity::PUBLIC_KEY_LENGTH;
pub use validator_client::validator_api::Client as ValidatorAPIClient;
use validator_client::validator_api::{
error::ValidatorAPIClientError, VALIDATOR_API_BLIND_SIGN, VALIDATOR_API_CACHE_VERSION,
Expand Down Expand Up @@ -47,9 +47,11 @@ impl Credential {

pub async fn init(
validator_urls: Vec<String>,
public_key: crypto::asymmetric::identity::PublicKey,
key_pair: Arc<crypto::asymmetric::identity::KeyPair>,
) -> Result<Self, CoconutInterfaceError> {
let mut state = State::init(Some(public_key));
let public_attributes = vec![hash_to_scalar(key_pair.public_key().to_bytes())];
let private_attributes = vec![hash_to_scalar(key_pair.private_key().to_bytes())];
let mut state = State::init(public_attributes, private_attributes)?;
let client = ValidatorAPIClient::new();
let signature = get_aggregated_signature(validator_urls.clone(), &state, &client).await?;

Expand Down
2 changes: 1 addition & 1 deletion validator-api/src/network_monitor/monitor/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl PacketSender {
"http://{}:{}",
DEFAULT_VALIDATOR_HOST, VALIDATOR_API_PORT
)],
identity,
Arc::clone(&fresh_gateway_client_data.local_identity),
)
.await
.expect("Could not initialize coconut credential");
Expand Down

0 comments on commit b348f47

Please sign in to comment.