Skip to content

Commit

Permalink
Cargo Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
pacu committed Jun 21, 2024
1 parent de4a4a8 commit 067d284
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions frost-uniffi-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ pub fn trusted_dealer_keygen_with_identifiers(

let mut rng = thread_rng();

let (shares, pubkey) =
let trust_dealt_keys =
trusted_dealer_keygen(&configuration, list, &mut rng).map_err(FrostError::map_err)?;

let pubkey =
FrostPublicKeyPackage::from_public_key_package::<E>(pubkey).map_err(FrostError::map_err)?;
FrostPublicKeyPackage::from_public_key_package::<E>(trust_dealt_keys.public_keys).map_err(FrostError::map_err)?;

let mut hash_map: HashMap<ParticipantIdentifier, FrostSecretKeyShare> = HashMap::new();

for (k, v) in shares {
for (k, v) in trust_dealt_keys.secret_shares {
hash_map.insert(
ParticipantIdentifier::from_identifier(k).map_err(FrostError::map_err)?,
FrostSecretKeyShare::from_secret_share::<E>(v).map_err(FrostError::map_err)?,
Expand Down
31 changes: 24 additions & 7 deletions frost-uniffi-sdk/src/trusted_dealer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ pub fn trusted_dealer_keygen_from_configuration<C: Ciphersuite>(
split_secret(config, IdentifierList::Default, &mut rng)
};

let (shares, pubkeys) = keygen?;
let trusted_dealt_keys = keygen?;

let pubkey = FrostPublicKeyPackage::from_public_key_package::<C>(pubkeys)?;


let pubkey = FrostPublicKeyPackage::from_public_key_package::<C>(trusted_dealt_keys.public_keys)?;

let mut hash_map: HashMap<ParticipantIdentifier, FrostSecretKeyShare> = HashMap::new();

for (k, v) in shares {
for (k, v) in trusted_dealt_keys.secret_shares {
hash_map.insert(
ParticipantIdentifier::from_identifier(k)?,
FrostSecretKeyShare::from_secret_share(v)?,
Expand All @@ -42,11 +44,16 @@ pub fn trusted_dealer_keygen_from_configuration<C: Ciphersuite>(
Ok((pubkey, hash_map))
}

pub struct TrustDealtKeys<C: Ciphersuite> {
pub secret_shares: BTreeMap<Identifier<C>,SecretShare<C>>,
pub public_keys: PublicKeyPackage<C>
}

pub fn trusted_dealer_keygen<C: Ciphersuite>(
config: &Configuration,
identifiers: IdentifierList<C>,
rng: &mut ThreadRng,
) -> Result<(BTreeMap<Identifier<C>, SecretShare<C>>, PublicKeyPackage<C>), Error<C>> {
) -> Result<TrustDealtKeys<C>, Error<C>> {
let (shares, pubkeys) = frost::keys::generate_with_dealer(
config.max_signers,
config.min_signers,
Expand All @@ -58,14 +65,19 @@ pub fn trusted_dealer_keygen<C: Ciphersuite>(
frost::keys::KeyPackage::try_from(v)?;
}

Ok((shares, pubkeys))
Ok(
TrustDealtKeys {
secret_shares: shares,
public_keys: pubkeys
}
)
}

fn split_secret<C: Ciphersuite>(
config: &Configuration,
identifiers: IdentifierList<C>,
rng: &mut ThreadRng,
) -> Result<(BTreeMap<Identifier<C>, SecretShare<C>>, PublicKeyPackage<C>), Error<C>> {
) -> Result<TrustDealtKeys<C>, Error<C>> {
let secret_key = SigningKey::deserialize(
config
.secret
Expand All @@ -85,7 +97,12 @@ fn split_secret<C: Ciphersuite>(
frost::keys::KeyPackage::try_from(v)?;
}

Ok((shares, pubkeys))
Ok(
TrustDealtKeys {
secret_shares: shares,
public_keys: pubkeys
}
)
}
#[cfg(test)]
mod tests {
Expand Down

0 comments on commit 067d284

Please sign in to comment.