-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcomms.rs
53 lines (45 loc) · 1.58 KB
/
comms.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pub mod cli;
pub mod http;
use frost_core::{
self as frost,
keys::dkg::{round1, round2},
Ciphersuite,
};
use frostd::PublicKey;
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> {
/// Return this participant's identifier (in case it's derived from other
/// information) and the number of participants in the signing session.
async fn get_identifier_and_max_signers(
&mut self,
input: &mut dyn BufRead,
output: &mut dyn Write,
) -> Result<(Identifier<C>, u16), Box<dyn Error>>;
/// Send the Round 1 package to other participants (using echo broadcast),
/// and receive their Round 1 packages.
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>>;
/// Send the Round 2 packages to other participants, and receive their Round
/// 2 packages.
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>>;
/// Return the map of public keys to identifiers for all participants.
fn get_pubkey_identifier_map(
&self,
) -> Result<HashMap<PublicKey, Identifier<C>>, Box<dyn Error>>;
}