From 082e4bb9f3fd56a68408dd0c6c445540d2203659 Mon Sep 17 00:00:00 2001 From: David Rusu Date: Wed, 18 Aug 2021 21:10:37 -0700 Subject: [PATCH] fix(bench): fixes #79 - bug in code to generate ownership proofs --- benches/reissue.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/benches/reissue.rs b/benches/reissue.rs index 82ec4d5..6bc7548 100644 --- a/benches/reissue.rs +++ b/benches/reissue.rs @@ -125,6 +125,15 @@ fn bench_reissue_100_to_1(c: &mut Criterion) { .build() .unwrap(); + let dbc_owners = BTreeMap::from_iter(dbc_owners.into_iter().map(|(dbc_hash, owner_pk)| { + let owner = owners + .iter() + .find(|o| o.public_key_set.public_key() == owner_pk) + .unwrap() + .clone(); + (dbc_hash, owner) + })); + let sig_share = genesis_owner .secret_key_share .sign(&reissue_tx.blinded().hash()); @@ -166,11 +175,7 @@ fn bench_reissue_100_to_1(c: &mut Criterion) { let (merge_tx, _) = sn_dbc::TransactionBuilder::default() .add_inputs(dbcs.iter().cloned().map(|dbc| { - let owner_pk = dbc_owners[&dbc.name()]; - let owner = owners - .iter() - .find(|o| o.public_key_set.public_key() == owner_pk) - .unwrap(); + let owner = &dbc_owners[&dbc.name()]; let amount_secrets = sn_dbc::DbcHelper::decrypt_amount_secrets(owner, &dbc.content).unwrap(); (dbc, amount_secrets) @@ -182,13 +187,14 @@ fn bench_reissue_100_to_1(c: &mut Criterion) { .build() .unwrap(); - let input_ownership_proofs = HashMap::from_iter(dbcs.iter().enumerate().map(|(i, dbc)| { - let sig_share = owners[i].secret_key_share.sign(merge_tx.blinded().hash()); - let sig = owners[i] + let input_ownership_proofs = HashMap::from_iter(dbcs.iter().map(|dbc| { + let owner = &dbc_owners[&dbc.name()]; + let sig_share = owner.secret_key_share.sign(merge_tx.blinded().hash()); + let sig = owner .public_key_set .combine_signatures(vec![(0, &sig_share)]) .unwrap(); - (dbc.name(), (owners[i].public_key_set.public_key(), sig)) + (dbc.name(), (owner.public_key_set.public_key(), sig)) })); let merge_reissue = ReissueRequest {