api support: submit ed25519 public key alongside the bte public key
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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