diff options
Diffstat (limited to 'src/benchmark/taler-aggregator-benchmark.c')
-rw-r--r-- | src/benchmark/taler-aggregator-benchmark.c | 199 |
1 files changed, 113 insertions, 86 deletions
diff --git a/src/benchmark/taler-aggregator-benchmark.c b/src/benchmark/taler-aggregator-benchmark.c index 411921000..228d050e4 100644 --- a/src/benchmark/taler-aggregator-benchmark.c +++ b/src/benchmark/taler-aggregator-benchmark.c @@ -76,7 +76,7 @@ static struct GNUNET_SCHEDULER_Task *task; /** * Hash of the denomination. */ -static struct TALER_DenominationHash h_denom_pub; +static struct TALER_DenominationHashP h_denom_pub; /** * "signature" to use for the coin(s). @@ -144,29 +144,6 @@ make_amount (unsigned int val, /** - * Initialize @a out with an amount given by @a val and - * @a frac using the main "currency". - * - * @param val value to set - * @param frac fraction to set - * @param[out] out where to write the amount - */ -static void -make_amountN (unsigned int val, - unsigned int frac, - struct TALER_AmountNBO *out) -{ - struct TALER_Amount in; - - make_amount (val, - frac, - &in); - TALER_amount_hton (out, - &in); -} - - -/** * Create random-ish timestamp. * * @return time stamp between start and end @@ -223,12 +200,12 @@ struct Merchant * the exchange from the detailed wire data provided by the * merchant. */ - struct TALER_MerchantWireHash h_wire; + struct TALER_MerchantWireHashP h_wire; /** * Salt used when computing @e h_wire. */ - struct TALER_WireSalt wire_salt; + struct TALER_WireSaltP wire_salt; /** * Account information for the merchant. @@ -249,7 +226,7 @@ struct Deposit * Hash over the proposal data between merchant and customer * (remains unknown to the Exchange). */ - struct TALER_PrivateContractHash h_contract_terms; + struct TALER_PrivateContractHashP h_contract_terms; }; @@ -274,7 +251,7 @@ add_refund (const struct Merchant *m, r.details.rtransaction_id = 42; make_amount (0, 5000000, &r.details.refund_amount); make_amount (0, 5, &r.details.refund_fee); - if (0 <= + if (0 >= plugin->insert_refund (plugin->cls, &r)) { @@ -297,15 +274,23 @@ static bool add_deposit (const struct Merchant *m) { struct Deposit d; - struct TALER_EXCHANGEDB_Deposit deposit; + struct TALER_EXCHANGEDB_CoinDepositInformation deposit; + struct TALER_EXCHANGEDB_BatchDeposit bd = { + .cdis = &deposit, + .num_cdis = 1 + }; uint64_t known_coin_id; - struct TALER_DenominationHash dph; - struct TALER_AgeHash agh; + struct TALER_DenominationHashP dph; + struct TALER_AgeCommitmentHash agh; RANDOMIZE (&d.coin.coin_pub); d.coin.denom_pub_hash = h_denom_pub; d.coin.denom_sig = denom_sig; RANDOMIZE (&d.h_contract_terms); + d.coin.no_age_commitment = true; + memset (&d.coin.h_age_commitment, + 0, + sizeof (d.coin.h_age_commitment)); if (0 >= plugin->ensure_coin_known (plugin->cls, @@ -321,24 +306,40 @@ add_deposit (const struct Merchant *m) } deposit.coin = d.coin; RANDOMIZE (&deposit.csig); - deposit.merchant_pub = m->merchant_pub; - deposit.h_contract_terms = d.h_contract_terms; - deposit.wire_salt = m->wire_salt; - deposit.receiver_wire_account = m->payto_uri; - deposit.timestamp = random_time (); - deposit.refund_deadline = random_time (); - deposit.wire_deadline = random_time (); + bd.merchant_pub = m->merchant_pub; + bd.h_contract_terms = d.h_contract_terms; + bd.wire_salt = m->wire_salt; + bd.receiver_wire_account = m->payto_uri; + bd.wallet_timestamp = random_time (); + do { + bd.refund_deadline = random_time (); + bd.wire_deadline = random_time (); + } while (GNUNET_TIME_timestamp_cmp (bd.wire_deadline, + <, + bd.refund_deadline)); + make_amount (1, 0, &deposit.amount_with_fee); - make_amount (0, 5, &deposit.deposit_fee); - if (0 >= - plugin->insert_deposit (plugin->cls, - random_time (), - &deposit)) + { - GNUNET_break (0); - global_ret = EXIT_FAILURE; - GNUNET_SCHEDULER_shutdown (); - return false; + struct GNUNET_TIME_Timestamp now; + bool balance_ok; + uint32_t bad_idx; + bool conflict; + + now = random_time (); + if (0 >= + plugin->do_deposit (plugin->cls, + &bd, + &now, + &balance_ok, + &bad_idx, + &conflict)) + { + GNUNET_break (0); + global_ret = EXIT_FAILURE; + GNUNET_SCHEDULER_shutdown (); + return false; + } } if (GNUNET_YES == eval_probability (((float) refund_rate) / 100.0)) @@ -430,7 +431,7 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; + struct TALER_EXCHANGEDB_DenominationKeyInformation issue; (void) cls; (void) args; @@ -465,48 +466,50 @@ run (void *cls, } GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); + memset (&issue, + 0, + sizeof (issue)); RANDOMIZE (&issue.signature); - issue.properties.purpose.purpose = htonl ( - TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); - issue.properties.purpose.size = htonl (sizeof (issue.properties)); - RANDOMIZE (&issue.properties.master); - issue.properties.start - = GNUNET_TIME_timestamp_hton (start); - issue.properties.expire_withdraw - = GNUNET_TIME_timestamp_hton ( - GNUNET_TIME_absolute_to_timestamp ( - GNUNET_TIME_absolute_add (start.abs_time, - GNUNET_TIME_UNIT_DAYS))); - issue.properties.expire_deposit - = GNUNET_TIME_timestamp_hton (end); - issue.properties.expire_legal - = GNUNET_TIME_timestamp_hton ( - GNUNET_TIME_absolute_to_timestamp ( - GNUNET_TIME_absolute_add (end.abs_time, - GNUNET_TIME_UNIT_YEARS))); + issue.start + = start; + issue.expire_withdraw + = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_add (start.abs_time, + GNUNET_TIME_UNIT_DAYS)); + issue.expire_deposit + = end; + issue.expire_legal + = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_add (end.abs_time, + GNUNET_TIME_UNIT_YEARS)); { struct TALER_DenominationPrivateKey pk; struct TALER_DenominationPublicKey denom_pub; - struct TALER_CoinPubHash c_hash; + struct TALER_CoinPubHashP c_hash; struct TALER_PlanchetDetail pd; struct TALER_BlindedDenominationSignature bds; - union TALER_DenominationBlindingKeyP bks; + struct TALER_PlanchetMasterSecretP ps; struct TALER_CoinSpendPublicKeyP coin_pub; + struct TALER_AgeCommitmentHash hac; + union GNUNET_CRYPTO_BlindingSecretP bks; + const struct TALER_ExchangeWithdrawValues *alg_values; RANDOMIZE (&coin_pub); GNUNET_assert (GNUNET_OK == TALER_denom_priv_create (&pk, &denom_pub, - TALER_DENOMINATION_RSA, + GNUNET_CRYPTO_BSA_RSA, 1024)); + alg_values = TALER_denom_ewv_rsa_singleton (); + denom_pub.age_mask = issue.age_mask; TALER_denom_pub_hash (&denom_pub, &h_denom_pub); - make_amountN (2, 0, &issue.properties.value); - make_amountN (0, 5, &issue.properties.fee_withdraw); - make_amountN (0, 5, &issue.properties.fee_deposit); - make_amountN (0, 5, &issue.properties.fee_refresh); - make_amountN (0, 5, &issue.properties.fee_refund); - issue.properties.denom_hash = h_denom_pub; + make_amount (2, 0, &issue.value); + make_amount (0, 5, &issue.fees.withdraw); + make_amount (0, 5, &issue.fees.deposit); + make_amount (0, 5, &issue.fees.refresh); + make_amount (0, 5, &issue.fees.refund); + issue.denom_hash = h_denom_pub; if (0 >= plugin->insert_denomination_info (plugin->cls, &denom_pub, @@ -518,25 +521,49 @@ run (void *cls, return; } - TALER_blinding_secret_create (&bks); + TALER_planchet_blinding_secret_create (&ps, + TALER_denom_ewv_rsa_singleton (), + &bks); + + { + struct GNUNET_HashCode seed; + struct TALER_AgeMask mask = { + .bits = 1 | (1 << 8) | (1 << 12) | (1 << 16) | (1 << 18) + }; + struct TALER_AgeCommitmentProof acp = {0}; + + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &seed, + sizeof(seed)); + TALER_age_restriction_commit (&mask, + 13, + &seed, + &acp); + TALER_age_commitment_hash (&acp.commitment, + &hac); + } + GNUNET_assert (GNUNET_OK == TALER_denom_blind (&denom_pub, &bks, - NULL, /* FIXME-oec */ + NULL, + &hac, &coin_pub, + alg_values, &c_hash, - &pd.coin_ev, - &pd.coin_ev_size)); + &pd.blinded_planchet)); GNUNET_assert (GNUNET_OK == TALER_denom_sign_blinded (&bds, &pk, - pd.coin_ev, - pd.coin_ev_size)); - GNUNET_free (pd.coin_ev); + false, + &pd.blinded_planchet)); + TALER_blinded_planchet_free (&pd.blinded_planchet); GNUNET_assert (GNUNET_OK == TALER_denom_sig_unblind (&denom_sig, &bds, &bks, + &c_hash, + alg_values, &denom_pub)); TALER_blinded_denom_sig_free (&bds); TALER_denom_pub_free (&denom_pub); @@ -544,7 +571,7 @@ run (void *cls, } { - struct TALER_Amount wire_fee; + struct TALER_WireFeeSet fees; struct TALER_MasterSignatureP master_sig; unsigned int year; struct GNUNET_TIME_Timestamp ws; @@ -555,7 +582,8 @@ run (void *cls, { ws = GNUNET_TIME_absolute_to_timestamp (GNUNET_TIME_year_to_time (y - 1)); we = GNUNET_TIME_absolute_to_timestamp (GNUNET_TIME_year_to_time (y)); - make_amount (0, 5, &wire_fee); + make_amount (0, 5, &fees.wire); + make_amount (0, 5, &fees.closing); memset (&master_sig, 0, sizeof (master_sig)); @@ -564,8 +592,7 @@ run (void *cls, "x-taler-bank", ws, we, - &wire_fee, - &wire_fee, + &fees, &master_sig)) { GNUNET_break (0); |