Skip to content

Commit

Permalink
frost-client: add support for group description (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg authored Dec 26, 2024
1 parent 57144ee commit 30cdd00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions frost-client/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pub(crate) enum Command {
/// dealer process via the FROST server (TODO: this is not supported yet)
#[arg(short, long)]
config: Vec<String>,
/// A description of the group being created. Will be written to the
/// participant's config files and will help them identify groups.
#[arg(short, long)]
description: String,
/// The comma-separated name of each participant.
#[arg(short = 'N', long, value_delimiter = ',')]
names: Vec<String>,
Expand Down
12 changes: 8 additions & 4 deletions frost-client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,26 @@ pub struct CommunicationKey {
}

/// A FROST group the user belongs to.
// TODO: add a textual name for the group?
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Group {
/// A human-readable description of the group to make it easier to select
/// groups
pub description: String,
/// The ciphersuite being used for the group
pub ciphersuite: String,
/// The encoded public key package for the group.
#[serde(
serialize_with = "serdect::slice::serialize_hex_lower_or_bin",
deserialize_with = "serdect::slice::deserialize_hex_or_bin_vec"
)]
pub public_key_package: Vec<u8>,
/// The user's encodede key package for the group.
/// The user's encoded key package for the group.
#[serde(
serialize_with = "serdect::slice::serialize_hex_lower_or_bin",
deserialize_with = "serdect::slice::deserialize_hex_or_bin_vec"
)]
pub key_package: Vec<u8>,
/// The server the participants are registered in, if any.
/// The default server the participants are using, if any.
pub server_url: Option<String>,
/// The group participants, keyed by hex-encoded identifier
pub participant: BTreeMap<String, Participant>,
Expand All @@ -86,7 +89,8 @@ impl Group {
let helper = ciphersuite_helper(&self.ciphersuite)?;
let info = helper.group_info(&self.key_package, &self.public_key_package)?;
let mut s = format!(
"Group with public key {}\nServer URL: {}\nThreshold: {}\nParticipants: {}\n",
"Group \"{}\"\nPublic key {}\nServer URL: {}\nThreshold: {}\nParticipants: {}\n",
self.description,
info.hex_verifying_key,
self.server_url.clone().unwrap_or_default(),
info.threshold,
Expand Down
2 changes: 2 additions & 0 deletions frost-client/src/trusted_dealer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub(crate) fn trusted_dealer_for_ciphersuite<C: Ciphersuite + MaybeIntoEvenY + '
) -> Result<(), Box<dyn Error>> {
let Command::TrustedDealer {
config,
description,
ciphersuite: _,
threshold,
num_signers,
Expand Down Expand Up @@ -91,6 +92,7 @@ pub(crate) fn trusted_dealer_for_ciphersuite<C: Ciphersuite + MaybeIntoEvenY + '
let key_package: KeyPackage<C> = share.clone().try_into()?;
let group = Group {
ciphersuite: C::ID.to_string(),
description: description.clone(),
key_package: postcard::to_allocvec(&key_package)?,
public_key_package: postcard::to_allocvec(&public_key_package)?,
participant: participants.clone(),
Expand Down

0 comments on commit 30cdd00

Please sign in to comment.