Skip to content

Commit

Permalink
preserves order of identities when returning key packages (#4814)
Browse files Browse the repository at this point in the history
  • Loading branch information
patnir authored Mar 7, 2024
1 parent fb0c7da commit 0d5b7bd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ironfish-rust-nodejs/src/frost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,22 @@ pub fn generate_and_split_key(
let identities = try_deserialize_identities(identities)?;

let packages =
split_spender_key(&spending_key, min_signers, identities).map_err(to_napi_err)?;
split_spender_key(&spending_key, min_signers, identities.clone()).map_err(to_napi_err)?;

let mut key_packages = Vec::with_capacity(packages.key_packages.len());
for (identity, key_package) in packages.key_packages.iter() {

// preserves the order of the identities
for identity in identities {
let key_package = packages
.key_packages
.get(&identity)
.ok_or_else(|| to_napi_err("Key package not found for identity"))?
.serialize()
.map_err(to_napi_err)?;

key_packages.push(ParticipantKeyPackage {
identity: bytes_to_hex(&identity.serialize()),
key_package: bytes_to_hex(&key_package.serialize().map_err(to_napi_err)?),
key_package: bytes_to_hex(&key_package),
});
}

Expand Down

0 comments on commit 0d5b7bd

Please sign in to comment.