Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea67a9376 | |||
| f566dffc5b | |||
| 05f8beedad | |||
| 2fff051e28 |
@@ -12,6 +12,7 @@ use cosmwasm_std::Addr;
|
||||
use nym_coconut_dkg_common::msg::ExecuteMsg as DkgExecuteMsg;
|
||||
use nym_coconut_dkg_common::types::{EncodedBTEPublicKeyWithProof, PartialContractDealing};
|
||||
use nym_coconut_dkg_common::verification_key::VerificationKeyShare;
|
||||
use nym_contracts_common::IdentityKey;
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
|
||||
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
|
||||
@@ -41,12 +42,14 @@ pub trait DkgSigningClient {
|
||||
async fn register_dealer(
|
||||
&self,
|
||||
bte_key: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: IdentityKey,
|
||||
announce_address: String,
|
||||
resharing: bool,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NyxdError> {
|
||||
let req = DkgExecuteMsg::RegisterDealer {
|
||||
bte_key_with_proof: bte_key,
|
||||
identity_key,
|
||||
announce_address,
|
||||
resharing,
|
||||
};
|
||||
@@ -144,10 +147,17 @@ mod tests {
|
||||
match msg {
|
||||
DkgExecuteMsg::RegisterDealer {
|
||||
bte_key_with_proof,
|
||||
identity_key,
|
||||
announce_address,
|
||||
resharing,
|
||||
} => client
|
||||
.register_dealer(bte_key_with_proof, announce_address, resharing, None)
|
||||
.register_dealer(
|
||||
bte_key_with_proof,
|
||||
identity_key,
|
||||
announce_address,
|
||||
resharing,
|
||||
None,
|
||||
)
|
||||
.ignore(),
|
||||
DkgExecuteMsg::CommitDealing { dealing, resharing } => client
|
||||
.submit_dealing_bytes(dealing, resharing, None)
|
||||
|
||||
@@ -12,6 +12,7 @@ use cosmwasm_std::Addr;
|
||||
pub struct DealerDetails {
|
||||
pub address: Addr,
|
||||
pub bte_public_key_with_proof: EncodedBTEPublicKeyWithProof,
|
||||
pub ed25519_identity: String,
|
||||
pub announce_address: String,
|
||||
pub assigned_index: NodeIndex,
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use crate::{
|
||||
types::{Epoch, InitialReplacementData, State},
|
||||
verification_key::PagedVKSharesResponse,
|
||||
};
|
||||
use contracts_common::IdentityKey;
|
||||
#[cfg(feature = "schema")]
|
||||
use cosmwasm_schema::QueryResponses;
|
||||
|
||||
@@ -35,6 +36,7 @@ pub struct InstantiateMsg {
|
||||
pub enum ExecuteMsg {
|
||||
RegisterDealer {
|
||||
bte_key_with_proof: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: IdentityKey,
|
||||
announce_address: String,
|
||||
resharing: bool,
|
||||
},
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
"required": [
|
||||
"announce_address",
|
||||
"bte_key_with_proof",
|
||||
"identity_key",
|
||||
"resharing"
|
||||
],
|
||||
"properties": {
|
||||
@@ -111,6 +112,9 @@
|
||||
"bte_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"identity_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"resharing": {
|
||||
"type": "boolean"
|
||||
}
|
||||
@@ -590,7 +594,8 @@
|
||||
"address",
|
||||
"announce_address",
|
||||
"assigned_index",
|
||||
"bte_public_key_with_proof"
|
||||
"bte_public_key_with_proof",
|
||||
"ed25519_identity"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
@@ -606,6 +611,9 @@
|
||||
},
|
||||
"bte_public_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"ed25519_identity": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@@ -854,7 +862,8 @@
|
||||
"address",
|
||||
"announce_address",
|
||||
"assigned_index",
|
||||
"bte_public_key_with_proof"
|
||||
"bte_public_key_with_proof",
|
||||
"ed25519_identity"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
@@ -870,6 +879,9 @@
|
||||
},
|
||||
"bte_public_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"ed25519_identity": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@@ -1121,7 +1133,8 @@
|
||||
"address",
|
||||
"announce_address",
|
||||
"assigned_index",
|
||||
"bte_public_key_with_proof"
|
||||
"bte_public_key_with_proof",
|
||||
"ed25519_identity"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
@@ -1137,6 +1150,9 @@
|
||||
},
|
||||
"bte_public_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"ed25519_identity": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"required": [
|
||||
"announce_address",
|
||||
"bte_key_with_proof",
|
||||
"identity_key",
|
||||
"resharing"
|
||||
],
|
||||
"properties": {
|
||||
@@ -22,6 +23,9 @@
|
||||
"bte_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"identity_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"resharing": {
|
||||
"type": "boolean"
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
"address",
|
||||
"announce_address",
|
||||
"assigned_index",
|
||||
"bte_public_key_with_proof"
|
||||
"bte_public_key_with_proof",
|
||||
"ed25519_identity"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
@@ -58,6 +59,9 @@
|
||||
},
|
||||
"bte_public_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"ed25519_identity": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
"address",
|
||||
"announce_address",
|
||||
"assigned_index",
|
||||
"bte_public_key_with_proof"
|
||||
"bte_public_key_with_proof",
|
||||
"ed25519_identity"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
@@ -48,6 +49,9 @@
|
||||
},
|
||||
"bte_public_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"ed25519_identity": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
"address",
|
||||
"announce_address",
|
||||
"assigned_index",
|
||||
"bte_public_key_with_proof"
|
||||
"bte_public_key_with_proof",
|
||||
"ed25519_identity"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
@@ -58,6 +59,9 @@
|
||||
},
|
||||
"bte_public_key_with_proof": {
|
||||
"type": "string"
|
||||
},
|
||||
"ed25519_identity": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -78,9 +78,17 @@ pub fn execute(
|
||||
match msg {
|
||||
ExecuteMsg::RegisterDealer {
|
||||
bte_key_with_proof,
|
||||
identity_key,
|
||||
announce_address,
|
||||
resharing,
|
||||
} => try_add_dealer(deps, info, bte_key_with_proof, announce_address, resharing),
|
||||
} => try_add_dealer(
|
||||
deps,
|
||||
info,
|
||||
bte_key_with_proof,
|
||||
identity_key,
|
||||
announce_address,
|
||||
resharing,
|
||||
),
|
||||
ExecuteMsg::CommitDealing { dealing, resharing } => {
|
||||
try_commit_dealings(deps, info, dealing, resharing)
|
||||
}
|
||||
@@ -268,6 +276,7 @@ mod tests {
|
||||
coconut_dkg_contract_addr.clone(),
|
||||
&RegisterDealer {
|
||||
bte_key_with_proof: "bte_key_with_proof".to_string(),
|
||||
identity_key: "identity".to_string(),
|
||||
announce_address: "127.0.0.1:8000".to_string(),
|
||||
resharing: false,
|
||||
},
|
||||
@@ -282,6 +291,7 @@ mod tests {
|
||||
coconut_dkg_contract_addr.clone(),
|
||||
&RegisterDealer {
|
||||
bte_key_with_proof: "bte_key_with_proof".to_string(),
|
||||
identity_key: "identity".to_string(),
|
||||
announce_address: "127.0.0.1:8000".to_string(),
|
||||
resharing: false,
|
||||
},
|
||||
@@ -298,6 +308,7 @@ mod tests {
|
||||
coconut_dkg_contract_addr,
|
||||
&RegisterDealer {
|
||||
bte_key_with_proof: "bte_key_with_proof".to_string(),
|
||||
identity_key: "identity".to_string(),
|
||||
announce_address: "127.0.0.1:8000".to_string(),
|
||||
resharing: false,
|
||||
},
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn try_add_dealer(
|
||||
mut deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
bte_key_with_proof: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: String,
|
||||
announce_address: String,
|
||||
resharing: bool,
|
||||
) -> Result<Response, ContractError> {
|
||||
@@ -65,6 +66,7 @@ pub fn try_add_dealer(
|
||||
let dealer_details = DealerDetails {
|
||||
address: info.sender.clone(),
|
||||
bte_public_key_with_proof: bte_key_with_proof,
|
||||
ed25519_identity: identity_key,
|
||||
announce_address,
|
||||
assigned_index: node_index,
|
||||
};
|
||||
@@ -141,6 +143,7 @@ pub(crate) mod tests {
|
||||
let mut env = mock_env();
|
||||
let info = mock_info(owner.as_str(), &[]);
|
||||
let bte_key_with_proof = String::from("bte_key_with_proof");
|
||||
let identity = String::from("identity");
|
||||
let announce_address = String::from("localhost:8000");
|
||||
|
||||
env.block.time = env
|
||||
@@ -155,6 +158,7 @@ pub(crate) mod tests {
|
||||
deps.as_mut(),
|
||||
info,
|
||||
bte_key_with_proof,
|
||||
identity,
|
||||
announce_address,
|
||||
false,
|
||||
)
|
||||
|
||||
@@ -108,6 +108,7 @@ pub(crate) mod tests {
|
||||
let dealer_details = DealerDetails {
|
||||
address: owner.clone(),
|
||||
bte_public_key_with_proof: String::new(),
|
||||
ed25519_identity: String::new(),
|
||||
announce_address: String::new(),
|
||||
assigned_index: 1,
|
||||
};
|
||||
|
||||
@@ -813,6 +813,7 @@ pub(crate) mod tests {
|
||||
&DealerDetails {
|
||||
address: address.clone(),
|
||||
bte_public_key_with_proof: "bte_public_key_with_proof".to_string(),
|
||||
ed25519_identity: "identity".to_string(),
|
||||
announce_address: "127.0.0.1".to_string(),
|
||||
assigned_index: i,
|
||||
},
|
||||
|
||||
@@ -34,6 +34,7 @@ pub fn dealer_details_fixture(assigned_index: u64) -> DealerDetails {
|
||||
DealerDetails {
|
||||
address: Addr::unchecked(format!("owner{}", assigned_index)),
|
||||
bte_public_key_with_proof: "".to_string(),
|
||||
ed25519_identity: "".to_string(),
|
||||
announce_address: "".to_string(),
|
||||
assigned_index,
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ pub fn add_fixture_dealer(deps: DepsMut<'_>) {
|
||||
&DealerDetails {
|
||||
address: owner.clone(),
|
||||
bte_public_key_with_proof: String::new(),
|
||||
ed25519_identity: String::new(),
|
||||
announce_address: String::new(),
|
||||
assigned_index: 100,
|
||||
},
|
||||
|
||||
@@ -122,6 +122,7 @@ mod tests {
|
||||
let dealer_details = DealerDetails {
|
||||
address: dealer.clone(),
|
||||
bte_public_key_with_proof: String::new(),
|
||||
ed25519_identity: String::new(),
|
||||
announce_address: announce_address.clone(),
|
||||
assigned_index: 1,
|
||||
};
|
||||
@@ -193,6 +194,7 @@ mod tests {
|
||||
let dealer_details = DealerDetails {
|
||||
address: dealer.clone(),
|
||||
bte_public_key_with_proof: String::new(),
|
||||
ed25519_identity: String::new(),
|
||||
announce_address: String::new(),
|
||||
assigned_index: 1,
|
||||
};
|
||||
@@ -300,6 +302,7 @@ mod tests {
|
||||
let dealer_details = DealerDetails {
|
||||
address: owner.clone(),
|
||||
bte_public_key_with_proof: String::new(),
|
||||
ed25519_identity: String::new(),
|
||||
announce_address: String::new(),
|
||||
assigned_index: 1,
|
||||
};
|
||||
|
||||
@@ -105,6 +105,7 @@ fn dkg_proposal() {
|
||||
coconut_dkg_contract_addr.clone(),
|
||||
&RegisterDealer {
|
||||
bte_key_with_proof: "bte_key_with_proof".to_string(),
|
||||
identity_key: "identity".to_string(),
|
||||
announce_address: "127.0.0.1:8000".to_string(),
|
||||
resharing: false,
|
||||
},
|
||||
|
||||
@@ -11,6 +11,7 @@ use nym_coconut_dkg_common::types::{
|
||||
PartialContractDealing, State,
|
||||
};
|
||||
use nym_coconut_dkg_common::verification_key::{ContractVKShare, VerificationKeyShare};
|
||||
use nym_contracts_common::IdentityKey;
|
||||
use nym_dkg::Threshold;
|
||||
use nym_validator_client::nyxd::cosmwasm_client::types::ExecuteResult;
|
||||
use nym_validator_client::nyxd::{AccountId, Fee, Hash, TxResponse};
|
||||
@@ -52,6 +53,7 @@ pub trait Client {
|
||||
async fn register_dealer(
|
||||
&self,
|
||||
bte_key: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: IdentityKey,
|
||||
announce_address: String,
|
||||
resharing: bool,
|
||||
) -> Result<ExecuteResult>;
|
||||
|
||||
@@ -11,6 +11,7 @@ use nym_coconut_dkg_common::types::{
|
||||
PartialContractDealing, State as ContractState,
|
||||
};
|
||||
use nym_coconut_dkg_common::verification_key::{ContractVKShare, VerificationKeyShare};
|
||||
use nym_contracts_common::IdentityKey;
|
||||
use nym_dkg::Threshold;
|
||||
use nym_validator_client::nyxd::cosmwasm_client::logs::{find_attribute, NODE_INDEX};
|
||||
use nym_validator_client::nyxd::cosmwasm_client::types::ExecuteResult;
|
||||
@@ -152,12 +153,13 @@ impl DkgClient {
|
||||
pub(crate) async fn register_dealer(
|
||||
&self,
|
||||
bte_key: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: IdentityKey,
|
||||
announce_address: String,
|
||||
resharing: bool,
|
||||
) -> Result<NodeIndex, CoconutError> {
|
||||
let res = self
|
||||
.inner
|
||||
.register_dealer(bte_key, announce_address, resharing)
|
||||
.register_dealer(bte_key, identity_key, announce_address, resharing)
|
||||
.await?;
|
||||
let node_index = find_attribute(&res.logs, "wasm", NODE_INDEX)
|
||||
.ok_or(CoconutError::NodeIndexRecoveryError {
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::nyxd;
|
||||
use crate::support::config;
|
||||
use anyhow::{bail, Result};
|
||||
use nym_coconut_dkg_common::types::EpochState;
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use nym_dkg::bte::keys::KeyPair as DkgKeyPair;
|
||||
use nym_task::{TaskClient, TaskManager};
|
||||
use rand::rngs::OsRng;
|
||||
@@ -51,6 +52,7 @@ impl<R: RngCore + CryptoRng + Clone> DkgController<R> {
|
||||
config: &config::CoconutSigner,
|
||||
nyxd_client: nyxd::Client,
|
||||
coconut_keypair: CoconutKeyPair,
|
||||
identity_key: identity::PublicKey,
|
||||
rng: R,
|
||||
) -> Result<Self> {
|
||||
let Some(announce_address) = &config.announce_address else {
|
||||
@@ -82,6 +84,7 @@ impl<R: RngCore + CryptoRng + Clone> DkgController<R> {
|
||||
persistent_state,
|
||||
announce_address.clone(),
|
||||
dkg_keypair,
|
||||
identity_key,
|
||||
coconut_keypair,
|
||||
),
|
||||
rng,
|
||||
@@ -208,6 +211,7 @@ impl<R: RngCore + CryptoRng + Clone> DkgController<R> {
|
||||
config: &config::CoconutSigner,
|
||||
nyxd_client: nyxd::Client,
|
||||
coconut_keypair: CoconutKeyPair,
|
||||
identity_key: identity::PublicKey,
|
||||
rng: R,
|
||||
shutdown: &TaskManager,
|
||||
) -> Result<()>
|
||||
@@ -215,7 +219,8 @@ impl<R: RngCore + CryptoRng + Clone> DkgController<R> {
|
||||
R: Sync + Send + 'static,
|
||||
{
|
||||
let shutdown_listener = shutdown.subscribe();
|
||||
let dkg_controller = DkgController::new(config, nyxd_client, coconut_keypair, rng).await?;
|
||||
let dkg_controller =
|
||||
DkgController::new(config, nyxd_client, coconut_keypair, identity_key, rng).await?;
|
||||
tokio::spawn(async move { dkg_controller.run(shutdown_listener).await });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -139,10 +139,12 @@ pub(crate) mod tests {
|
||||
use nym_coconut::{ttp_keygen, Parameters};
|
||||
use nym_coconut_dkg_common::dealer::DealerDetails;
|
||||
use nym_coconut_dkg_common::types::InitialReplacementData;
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use nym_dkg::bte::keys::KeyPair as DkgKeyPair;
|
||||
use nym_dkg::bte::{Params, PublicKeyWithProof};
|
||||
use nym_validator_client::nyxd::AccountId;
|
||||
use rand::rngs::OsRng;
|
||||
use rand_07::thread_rng;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
@@ -163,6 +165,8 @@ pub(crate) mod tests {
|
||||
let mut keypairs = vec![];
|
||||
for (idx, addr) in TEST_VALIDATORS_ADDRESS.iter().enumerate() {
|
||||
let keypair = DkgKeyPair::new(params, OsRng);
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
|
||||
let bte_public_key_with_proof =
|
||||
bs58::encode(&keypair.public_key().to_bytes()).into_string();
|
||||
keypairs.push(keypair);
|
||||
@@ -172,6 +176,7 @@ pub(crate) mod tests {
|
||||
DealerDetails {
|
||||
address: Addr::unchecked(*addr),
|
||||
bte_public_key_with_proof,
|
||||
ed25519_identity: identity_keypair.public_key().to_base58_string(),
|
||||
announce_address: format!("localhost:80{}", idx),
|
||||
assigned_index: (idx + 1) as u64,
|
||||
},
|
||||
@@ -196,11 +201,13 @@ pub(crate) mod tests {
|
||||
.with_threshold(&threshold_db),
|
||||
);
|
||||
let params = dkg::params();
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let mut state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
DkgKeyPair::new(params, OsRng),
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
state.set_node_index(Some(self_index));
|
||||
@@ -259,11 +266,13 @@ pub(crate) mod tests {
|
||||
.with_threshold(&threshold_db),
|
||||
);
|
||||
let params = dkg::params();
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let mut state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
DkgKeyPair::new(params, OsRng),
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
state.set_node_index(Some(self_index));
|
||||
@@ -332,12 +341,14 @@ pub(crate) mod tests {
|
||||
let mut keys = ttp_keygen(&Parameters::new(4).unwrap(), 3, 4).unwrap();
|
||||
let coconut_keypair = KeyPair::new();
|
||||
coconut_keypair.set(Some(keys.pop().unwrap())).await;
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
|
||||
let mut state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
DkgKeyPair::new(params, OsRng),
|
||||
*identity_keypair.public_key(),
|
||||
coconut_keypair.clone(),
|
||||
);
|
||||
state.set_node_index(Some(self_index));
|
||||
@@ -361,11 +372,13 @@ pub(crate) mod tests {
|
||||
// no dealings submitted for the first (zeroth) epoch
|
||||
assert!(dealings_db.read().unwrap().get(&0).is_none());
|
||||
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let mut state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
DkgKeyPair::new(params, OsRng),
|
||||
*identity_keypair.public_key(),
|
||||
coconut_keypair,
|
||||
);
|
||||
state.set_node_index(Some(self_index));
|
||||
|
||||
@@ -38,7 +38,12 @@ pub(crate) async fn public_key_submission(
|
||||
// If it was a dealer in a previous epoch, re-register it for this epoch
|
||||
debug!("Registering for the current DKG round, with keys from a previous epoch");
|
||||
dkg_client
|
||||
.register_dealer(bte_key, state.announce_address().to_string(), resharing)
|
||||
.register_dealer(
|
||||
bte_key,
|
||||
state.identity_key().to_base58_string(),
|
||||
state.announce_address().to_string(),
|
||||
resharing,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
details.assigned_index
|
||||
@@ -46,7 +51,12 @@ pub(crate) async fn public_key_submission(
|
||||
debug!("Registering for the first time to be a dealer");
|
||||
// First time registration
|
||||
dkg_client
|
||||
.register_dealer(bte_key, state.announce_address().to_string(), resharing)
|
||||
.register_dealer(
|
||||
bte_key,
|
||||
state.identity_key().to_base58_string(),
|
||||
state.announce_address().to_string(),
|
||||
resharing,
|
||||
)
|
||||
.await?
|
||||
};
|
||||
state.set_node_index(Some(index));
|
||||
@@ -61,9 +71,11 @@ pub(crate) mod tests {
|
||||
use crate::coconut::dkg::state::PersistentState;
|
||||
use crate::coconut::tests::DummyClient;
|
||||
use crate::coconut::KeyPair;
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use nym_dkg::bte::keys::KeyPair as DkgKeyPair;
|
||||
use nym_validator_client::nyxd::AccountId;
|
||||
use rand::rngs::OsRng;
|
||||
use rand_07::thread_rng;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use url::Url;
|
||||
@@ -76,11 +88,13 @@ pub(crate) mod tests {
|
||||
let dkg_client = DkgClient::new(DummyClient::new(
|
||||
AccountId::from_str(TEST_VALIDATOR_ADDRESS).unwrap(),
|
||||
));
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let mut state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
DkgKeyPair::new(&nym_dkg::bte::setup(), OsRng),
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use cosmwasm_std::Addr;
|
||||
use log::debug;
|
||||
use nym_coconut_dkg_common::dealer::DealerDetails;
|
||||
use nym_coconut_dkg_common::types::{DealingIndex, EpochId, EpochState};
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use nym_dkg::bte::{keys::KeyPair as DkgKeyPair, PublicKey, PublicKeyWithProof};
|
||||
use nym_dkg::{Dealing, NodeIndex, RecoveredVerificationKeys, Threshold};
|
||||
use serde::de::Error;
|
||||
@@ -249,6 +250,7 @@ impl PersistentState {
|
||||
pub(crate) struct State {
|
||||
persistent_state_path: PathBuf,
|
||||
announce_address: Url,
|
||||
identity_key: identity::PublicKey,
|
||||
dkg_keypair: DkgKeyPair,
|
||||
coconut_keypair: CoconutKeyPair,
|
||||
node_index: Option<NodeIndex>,
|
||||
@@ -269,11 +271,13 @@ impl State {
|
||||
persistent_state: PersistentState,
|
||||
announce_address: Url,
|
||||
dkg_keypair: DkgKeyPair,
|
||||
identity_key: identity::PublicKey,
|
||||
coconut_keypair: CoconutKeyPair,
|
||||
) -> Self {
|
||||
State {
|
||||
persistent_state_path,
|
||||
announce_address,
|
||||
identity_key,
|
||||
dkg_keypair,
|
||||
coconut_keypair,
|
||||
node_index: persistent_state.node_index,
|
||||
@@ -312,6 +316,10 @@ impl State {
|
||||
&self.announce_address
|
||||
}
|
||||
|
||||
pub fn identity_key(&self) -> identity::PublicKey {
|
||||
self.identity_key
|
||||
}
|
||||
|
||||
pub fn dkg_keypair(&self) -> &DkgKeyPair {
|
||||
&self.dkg_keypair
|
||||
}
|
||||
|
||||
@@ -361,10 +361,12 @@ pub(crate) mod tests {
|
||||
use nym_coconut_dkg_common::dealer::DealerDetails;
|
||||
use nym_coconut_dkg_common::types::{EpochId, InitialReplacementData, PartialContractDealing};
|
||||
use nym_coconut_dkg_common::verification_key::ContractVKShare;
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use nym_dkg::bte::keys::KeyPair as DkgKeyPair;
|
||||
use nym_validator_client::nyxd::AccountId;
|
||||
use rand::rngs::OsRng;
|
||||
use rand::Rng;
|
||||
use rand_07::thread_rng;
|
||||
use std::collections::HashMap;
|
||||
use std::env::temp_dir;
|
||||
use std::path::PathBuf;
|
||||
@@ -406,6 +408,7 @@ pub(crate) mod tests {
|
||||
async fn prepare_clients_and_states(db: &MockContractDb) -> Vec<(DkgClient, State)> {
|
||||
let params = dkg::params();
|
||||
let mut clients_and_states = vec![];
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
|
||||
for addr in TEST_VALIDATORS_ADDRESS {
|
||||
let dkg_client = DkgClient::new(
|
||||
@@ -423,6 +426,7 @@ pub(crate) mod tests {
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
keypair,
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
clients_and_states.push((dkg_client, state));
|
||||
@@ -940,11 +944,13 @@ pub(crate) mod tests {
|
||||
.with_initial_dealers_db(&db.initial_dealers_db),
|
||||
);
|
||||
let keypair = DkgKeyPair::new(dkg::params(), OsRng);
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
keypair,
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
|
||||
@@ -1044,11 +1050,13 @@ pub(crate) mod tests {
|
||||
.with_initial_dealers_db(&db.initial_dealers_db),
|
||||
);
|
||||
let keypair = DkgKeyPair::new(dkg::params(), OsRng);
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let state = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
keypair,
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
let new_dkg_client2 = DkgClient::new(
|
||||
@@ -1063,11 +1071,13 @@ pub(crate) mod tests {
|
||||
.with_initial_dealers_db(&db.initial_dealers_db),
|
||||
);
|
||||
let keypair = DkgKeyPair::new(dkg::params(), OsRng);
|
||||
let identity_keypair = identity::KeyPair::new(&mut thread_rng());
|
||||
let state2 = State::new(
|
||||
PathBuf::default(),
|
||||
PersistentState::default(),
|
||||
Url::parse("localhost:8000").unwrap(),
|
||||
keypair,
|
||||
*identity_keypair.public_key(),
|
||||
KeyPair::new(),
|
||||
);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ use nym_coconut_dkg_common::types::{
|
||||
use nym_coconut_dkg_common::verification_key::{ContractVKShare, VerificationKeyShare};
|
||||
use nym_coconut_interface::{hash_to_scalar, Credential, VerificationKey};
|
||||
use nym_config::defaults::VOUCHER_INFO;
|
||||
use nym_contracts_common::IdentityKey;
|
||||
use nym_credentials::coconut::bandwidth::BandwidthVoucher;
|
||||
use nym_crypto::asymmetric::{encryption, identity};
|
||||
use nym_dkg::Threshold;
|
||||
@@ -356,6 +357,7 @@ impl super::client::Client for DummyClient {
|
||||
async fn register_dealer(
|
||||
&self,
|
||||
bte_public_key_with_proof: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: IdentityKey,
|
||||
announce_address: String,
|
||||
_resharing: bool,
|
||||
) -> Result<ExecuteResult> {
|
||||
@@ -379,6 +381,7 @@ impl super::client::Client for DummyClient {
|
||||
DealerDetails {
|
||||
address: Addr::unchecked(self.validator_address.to_string()),
|
||||
bte_public_key_with_proof,
|
||||
ed25519_identity: identity_key,
|
||||
announce_address,
|
||||
assigned_index,
|
||||
},
|
||||
|
||||
@@ -70,6 +70,7 @@ async fn start_nym_api_tasks(config: Config) -> anyhow::Result<ShutdownHandles>
|
||||
|
||||
let coconut_keypair = coconut::keypair::KeyPair::new();
|
||||
let identity_keypair = config.base.storage_paths.load_identity()?;
|
||||
let identity_public_key = *identity_keypair.public_key();
|
||||
|
||||
// let's build our rocket!
|
||||
let rocket = http::setup_rocket(
|
||||
@@ -137,6 +138,7 @@ async fn start_nym_api_tasks(config: Config) -> anyhow::Result<ShutdownHandles>
|
||||
&config.coconut_signer,
|
||||
nyxd_client.clone(),
|
||||
coconut_keypair,
|
||||
identity_public_key,
|
||||
OsRng,
|
||||
&shutdown,
|
||||
)
|
||||
|
||||
@@ -467,12 +467,13 @@ impl crate::coconut::client::Client for Client {
|
||||
async fn register_dealer(
|
||||
&self,
|
||||
bte_key: EncodedBTEPublicKeyWithProof,
|
||||
identity_key: IdentityKey,
|
||||
announce_address: String,
|
||||
resharing: bool,
|
||||
) -> Result<ExecuteResult, CoconutError> {
|
||||
Ok(nyxd_signing!(
|
||||
self,
|
||||
register_dealer(bte_key, announce_address, resharing, None).await?
|
||||
register_dealer(bte_key, announce_address, identity_key, resharing, None).await?
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user