-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frost-client, dkg: add support for DKG with server (#423)
* frost-client, dkg: add support for DKG with server * comment out test for now
- Loading branch information
1 parent
54537ba
commit ef37c44
Showing
18 changed files
with
1,379 additions
and
322 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,76 @@ | ||
use std::rc::Rc; | ||
|
||
use clap::Parser; | ||
use frost_core::{Ciphersuite, Identifier}; | ||
|
||
#[derive(Parser, Debug, Default)] | ||
#[command(author, version, about, long_about = None)] | ||
pub struct Args { | ||
#[arg(short = 'C', long, default_value = "ed25519")] | ||
pub ciphersuite: String, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct ProcessedArgs<C: Ciphersuite> { | ||
/// CLI mode. If enabled, it will prompt for inputs from stdin | ||
/// and print values to stdout, ignoring other flags. | ||
pub cli: bool, | ||
|
||
/// HTTP mode. If enabled, it will use HTTP communication with a | ||
/// FROST server. | ||
pub http: bool, | ||
|
||
/// IP to connect to, if using HTTP mode. | ||
pub ip: String, | ||
|
||
/// Port to connect to, if using HTTP mode. | ||
pub port: u16, | ||
|
||
/// The participant's communication private key for HTTP mode. | ||
pub comm_privkey: Option<Vec<u8>>, | ||
|
||
/// The participant's communication public key for HTTP mode. | ||
pub comm_pubkey: Option<Vec<u8>>, | ||
|
||
/// A function that confirms that a public key from the server is trusted by | ||
/// the user; returns the same public key. For HTTP mode. | ||
// It is a `Rc<dyn Fn>` to make it easier to use; | ||
// using `fn()` would preclude using closures and using generics would | ||
// require a lot of code change for something simple. | ||
#[allow(clippy::type_complexity)] | ||
pub comm_participant_pubkey_getter: Option<Rc<dyn Fn(&Vec<u8>) -> Option<Vec<u8>>>>, | ||
|
||
/// The threshold to use for the shares | ||
pub min_signers: u16, | ||
|
||
/// The total number of signers. Only needed for CLI mode. | ||
pub max_signers: Option<u16>, | ||
|
||
/// The list of pubkeys for the other participants. This is only required | ||
/// for the first participant who creates the DKG session. | ||
pub participants: Vec<Vec<u8>>, | ||
|
||
/// Identifier to use for the participant. Only needed for CLI mode. | ||
pub identifier: Option<Identifier<C>>, | ||
} | ||
|
||
impl<C> ProcessedArgs<C> | ||
where | ||
C: Ciphersuite, | ||
{ | ||
pub(crate) fn new(config: &crate::inputs::Config<C>) -> Self { | ||
Self { | ||
cli: true, | ||
http: false, | ||
ip: String::new(), | ||
port: 0, | ||
comm_privkey: None, | ||
comm_pubkey: None, | ||
comm_participant_pubkey_getter: None, | ||
min_signers: config.min_signers, | ||
max_signers: Some(config.max_signers), | ||
participants: Vec::new(), | ||
identifier: Some(config.identifier), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
pub mod cli; | ||
pub mod http; | ||
|
||
use frost_core::{ | ||
self as frost, | ||
keys::dkg::{round1, round2}, | ||
Ciphersuite, | ||
}; | ||
|
||
use std::{ | ||
collections::{BTreeMap, HashMap}, | ||
error::Error, | ||
io::{BufRead, Write}, | ||
}; | ||
|
||
use async_trait::async_trait; | ||
|
||
use frost::Identifier; | ||
|
||
#[async_trait(?Send)] | ||
pub trait Comms<C: Ciphersuite> { | ||
async fn get_identifier( | ||
&mut self, | ||
input: &mut dyn BufRead, | ||
output: &mut dyn Write, | ||
) -> Result<(Identifier<C>, u16), Box<dyn Error>>; | ||
|
||
async fn get_round1_packages( | ||
&mut self, | ||
input: &mut dyn BufRead, | ||
output: &mut dyn Write, | ||
round1_package: round1::Package<C>, | ||
) -> Result<BTreeMap<Identifier<C>, round1::Package<C>>, Box<dyn Error>>; | ||
|
||
async fn get_round2_packages( | ||
&mut self, | ||
input: &mut dyn BufRead, | ||
output: &mut dyn Write, | ||
round2_packages: BTreeMap<Identifier<C>, round2::Package<C>>, | ||
) -> Result<BTreeMap<Identifier<C>, round2::Package<C>>, Box<dyn Error>>; | ||
|
||
fn get_pubkey_identifier_map(&self) -> Result<HashMap<Vec<u8>, Identifier<C>>, Box<dyn Error>>; | ||
} |
Oops, something went wrong.