summaryrefslogtreecommitdiff
path: root/src/benchmark/taler-aggregator-benchmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/benchmark/taler-aggregator-benchmark.c')
-rw-r--r--src/benchmark/taler-aggregator-benchmark.c324
1 files changed, 182 insertions, 142 deletions
diff --git a/src/benchmark/taler-aggregator-benchmark.c b/src/benchmark/taler-aggregator-benchmark.c
index e432d8f57..228d050e4 100644
--- a/src/benchmark/taler-aggregator-benchmark.c
+++ b/src/benchmark/taler-aggregator-benchmark.c
@@ -59,11 +59,6 @@ static unsigned int refund_rate = 0;
static char *currency;
/**
- * Merchant JSON wire details.
- */
-static json_t *json_wire;
-
-/**
* Configuration.
*/
static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -81,7 +76,7 @@ static struct GNUNET_SCHEDULER_Task *task;
/**
* Hash of the denomination.
*/
-static struct GNUNET_HashCode h_denom_pub;
+static struct TALER_DenominationHashP h_denom_pub;
/**
* "signature" to use for the coin(s).
@@ -91,12 +86,12 @@ static struct TALER_DenominationSignature denom_sig;
/**
* Time range when deposits start.
*/
-static struct GNUNET_TIME_Absolute start;
+static struct GNUNET_TIME_Timestamp start;
/**
* Time range when deposits end.
*/
-static struct GNUNET_TIME_Absolute end;
+static struct GNUNET_TIME_Timestamp end;
/**
@@ -140,36 +135,11 @@ make_amount (unsigned int val,
unsigned int frac,
struct TALER_Amount *out)
{
- memset (out,
- 0,
- sizeof (struct TALER_Amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (currency,
+ out));
out->value = val;
out->fraction = frac;
- strcpy (out->currency,
- currency);
-}
-
-
-/**
- * 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);
}
@@ -178,18 +148,17 @@ make_amountN (unsigned int val,
*
* @return time stamp between start and end
*/
-static struct GNUNET_TIME_Absolute
+static struct GNUNET_TIME_Timestamp
random_time (void)
{
uint64_t delta;
struct GNUNET_TIME_Absolute ret;
- delta = end.abs_value_us - start.abs_value_us;
+ delta = end.abs_time.abs_value_us - start.abs_time.abs_value_us;
delta = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE,
delta);
- ret.abs_value_us = start.abs_value_us + delta;
- (void) GNUNET_TIME_round_abs (&ret);
- return ret;
+ ret.abs_value_us = start.abs_time.abs_value_us + delta;
+ return GNUNET_TIME_absolute_to_timestamp (ret);
}
@@ -212,16 +181,7 @@ do_shutdown (void *cls)
GNUNET_SCHEDULER_cancel (task);
task = NULL;
}
- if (NULL !=denom_sig.rsa_signature)
- {
- GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
- denom_sig.rsa_signature = NULL;
- }
- if (NULL != json_wire)
- {
- json_decref (json_wire);
- json_wire = NULL;
- }
+ TALER_denom_sig_free (&denom_sig);
}
@@ -240,7 +200,17 @@ struct Merchant
* the exchange from the detailed wire data provided by the
* merchant.
*/
- struct GNUNET_HashCode h_wire;
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Salt used when computing @e h_wire.
+ */
+ struct TALER_WireSaltP wire_salt;
+
+ /**
+ * Account information for the merchant.
+ */
+ char *payto_uri;
};
@@ -256,7 +226,7 @@ struct Deposit
* Hash over the proposal data between merchant and customer
* (remains unknown to the Exchange).
*/
- struct GNUNET_HashCode h_contract_terms;
+ struct TALER_PrivateContractHashP h_contract_terms;
};
@@ -281,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))
{
@@ -304,16 +274,30 @@ 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_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,
- &d.coin))
+ &d.coin,
+ &known_coin_id,
+ &dph,
+ &agh))
{
GNUNET_break (0);
global_ret = EXIT_FAILURE;
@@ -322,25 +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.h_wire = m->h_wire;
- deposit.receiver_wire_account
- = json_wire;
- 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))
@@ -359,7 +358,6 @@ static void
work (void *cls)
{
struct Merchant m;
- char *acc;
uint64_t rnd1;
uint64_t rnd2;
@@ -369,33 +367,22 @@ work (void *cls)
UINT64_MAX);
rnd2 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE,
UINT64_MAX);
- GNUNET_asprintf (&acc,
+ GNUNET_asprintf (&m.payto_uri,
"payto://x-taler-bank/localhost:8082/account-%llX-%llX",
(unsigned long long) rnd1,
(unsigned long long) rnd2);
- json_wire = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("payto_uri",
- acc),
- GNUNET_JSON_pack_string ("salt",
- "thesalty"));
- GNUNET_free (acc);
RANDOMIZE (&m.merchant_pub);
- if (GNUNET_OK !=
- TALER_JSON_merchant_wire_signature_hash (json_wire,
- &m.h_wire))
- {
- GNUNET_break (0);
- global_ret = EXIT_FAILURE;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
+ RANDOMIZE (&m.wire_salt);
+ TALER_merchant_wire_signature_hash (m.payto_uri,
+ &m.wire_salt,
+ &m.h_wire);
if (GNUNET_OK !=
plugin->start (plugin->cls,
"aggregator-benchmark-fill"))
{
GNUNET_break (0);
global_ret = EXIT_FAILURE;
+ GNUNET_free (m.payto_uri);
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -405,6 +392,7 @@ work (void *cls)
{
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free (m.payto_uri);
return;
}
}
@@ -414,6 +402,7 @@ work (void *cls)
if (0 == --howmany_merchants)
{
GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free (m.payto_uri);
return;
}
}
@@ -422,8 +411,7 @@ work (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to commit, will try again\n");
}
- json_decref (json_wire);
- json_wire = NULL;
+ GNUNET_free (m.payto_uri);
task = GNUNET_SCHEDULER_add_now (&work,
NULL);
}
@@ -443,17 +431,18 @@ 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;
+ (void) cfgfile;
/* make sure everything 'ends' before the current time,
so that the aggregator will process everything without
need for time-travel */
- end = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&end);
- start = GNUNET_TIME_absolute_subtract (end,
- GNUNET_TIME_UNIT_MONTHS);
- (void) GNUNET_TIME_round_abs (&start);
+ end = GNUNET_TIME_timestamp_get ();
+ start = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_subtract (end.abs_time,
+ GNUNET_TIME_UNIT_MONTHS));
cfg = c;
if (GNUNET_OK !=
TALER_config_get_currency (cfg,
@@ -477,41 +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_absolute_hton (start);
- issue.properties.expire_withdraw
- = GNUNET_TIME_absolute_hton (
- GNUNET_TIME_absolute_add (start,
+ issue.start
+ = start;
+ issue.expire_withdraw
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_add (start.abs_time,
GNUNET_TIME_UNIT_DAYS));
- issue.properties.expire_deposit
- = GNUNET_TIME_absolute_hton (end);
- issue.properties.expire_legal
- = GNUNET_TIME_absolute_hton (
- GNUNET_TIME_absolute_add (end,
+ issue.expire_deposit
+ = end;
+ issue.expire_legal
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_add (end.abs_time,
GNUNET_TIME_UNIT_YEARS));
{
- struct GNUNET_CRYPTO_RsaPrivateKey *pk;
- struct GNUNET_CRYPTO_RsaPublicKey *pub;
- struct GNUNET_HashCode hc;
+ struct TALER_DenominationPrivateKey pk;
struct TALER_DenominationPublicKey denom_pub;
-
- RANDOMIZE (&hc);
- pk = GNUNET_CRYPTO_rsa_private_key_create (1024);
- pub = GNUNET_CRYPTO_rsa_private_key_get_public (pk);
- denom_pub.rsa_public_key = pub;
- GNUNET_CRYPTO_rsa_public_key_hash (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;
+ struct TALER_CoinPubHashP c_hash;
+ struct TALER_PlanchetDetail pd;
+ struct TALER_BlindedDenominationSignature bds;
+ 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,
+ 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_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,
@@ -523,26 +521,69 @@ run (void *cls,
return;
}
- denom_sig.rsa_signature
- = GNUNET_CRYPTO_rsa_sign_fdh (pk,
- &hc);
- GNUNET_CRYPTO_rsa_public_key_free (pub);
- GNUNET_CRYPTO_rsa_private_key_free (pk);
+ 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,
+ &hac,
+ &coin_pub,
+ alg_values,
+ &c_hash,
+ &pd.blinded_planchet));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_denom_sign_blinded (&bds,
+ &pk,
+ 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);
+ TALER_denom_priv_free (&pk);
}
{
- struct TALER_Amount wire_fee;
+ struct TALER_WireFeeSet fees;
struct TALER_MasterSignatureP master_sig;
unsigned int year;
- struct GNUNET_TIME_Absolute ws;
- struct GNUNET_TIME_Absolute we;
+ struct GNUNET_TIME_Timestamp ws;
+ struct GNUNET_TIME_Timestamp we;
year = GNUNET_TIME_get_current_year ();
for (unsigned int y = year - 1; y<year + 2; y++)
{
- ws = GNUNET_TIME_year_to_time (y - 1);
- we = GNUNET_TIME_year_to_time (y);
- make_amount (0, 5, &wire_fee);
+ 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, &fees.wire);
+ make_amount (0, 5, &fees.closing);
memset (&master_sig,
0,
sizeof (master_sig));
@@ -551,8 +592,7 @@ run (void *cls,
"x-taler-bank",
ws,
we,
- &wire_fee,
- &wire_fee,
+ &fees,
&master_sig))
{
GNUNET_break (0);