aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-06-30 09:23:04 +0200
committerFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-06-30 09:23:04 +0200
commit582e623b13457f372f22edd8d8c1c99d26e07626 (patch)
tree093fbd5e45329c40c204a844c0317e3f3ced7306 /src
parentc023cdc96a18026fd2eb84f8c7b2f9ad621192eb (diff)
initialization of the database
Diffstat (limited to 'src')
-rw-r--r--src/mintdb/perf_taler_mintdb.c99
-rw-r--r--src/mintdb/perf_taler_mintdb_init.c366
-rw-r--r--src/mintdb/perf_taler_mintdb_init.h103
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.c20
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.h74
-rw-r--r--src/mintdb/perf_taler_mintdb_values.h11
6 files changed, 398 insertions, 275 deletions
diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c
index 50d351e2a..58cf6d88c 100644
--- a/src/mintdb/perf_taler_mintdb.c
+++ b/src/mintdb/perf_taler_mintdb.c
@@ -34,43 +34,74 @@ main (int argc, char ** argv)
struct PERF_TALER_MINTDB_Cmd test[] =
{
// Denomination used to create coins
- PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("denomination"),
-
- PERF_TALER_MINTDB_INIT_CMD_DEBUG ("denomination inserted"),
- PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit",
+ PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop",
+ PERF_TALER_MINTDB_NB_DENOMINATION_INIT),
+ PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"),
+ PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("01 - denomination"),
+ PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("01 - commit transaction"),
+ PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
+ "01 - denomination loop",
+ "01 - denomination",
+ PERF_TALER_MINTDB_NB_DENOMINATION_SAVE,
+ PERF_TALER_MINTDB_BLINDCOIN),
+ PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("01 - denomination loop end",
+ "01 - denomination loop"),
+ PERF_TALER_MINTDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
+ // End of initialization
+ // Reserve initialization
+ PERF_TALER_MINTDB_INIT_CMD_LOOP ("02 - init reserve loop",
+ PERF_TALER_MINTDB_NB_RESERVE_INIT),
+ PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE ("02 - reserve"),
+ PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
+ "02 - init reserve loop",
+ "02 - reserve",
+ PERF_TALER_MINTDB_NB_RESERVE_SAVE,
+ PERF_TALER_MINTDB_RESERVE),
+ PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop",
+ "02 - init reserve loop"),
+ PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
+ // End reserve init
+ // Withdrawal initialization
+ PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop",
+ PERF_TALER_MINTDB_NB_WITHDRAW_INIT),
+ // PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"),
+ PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
+ "03 - init withdraw loop",
+ "01 - save denomination"),
+ PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
+ "03 - init withdraw loop",
+ "02 - save reserve"),
+ PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW ("03 - withdraw",
+ "03 - denomination load",
+ "03 - reserve load"),
+ // PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("03 - commit transaction"),
+ PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("03 - blindcoin array",
+ "03 - init withdraw loop",
+ "03 - withdraw",
+ PERF_TALER_MINTDB_NB_WITHDRAW_SAVE,
+ PERF_TALER_MINTDB_BLINDCOIN),
+ PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
+ "03 - init withdraw loop"),
+ PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
+ //End of withdrawal initialization
+ //Deposit initialization
+ PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop",
PERF_TALER_MINTDB_NB_DEPOSIT_INIT),
- PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_init"),
- PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("init_deposit_insert",
- "denomination"),
- PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"),
- PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo",
- "loop_db_init_deposit",
- "init_deposit_insert",
- PERF_TALER_MINTDB_NB_DEPOSIT_GET,
+ PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"),
+ PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit",
+ "01 - denomination"),
+ PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"),
+ PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
+ "04 - deposit init loop",
+ "04 - deposit",
+ PERF_TALER_MINTDB_NB_DEPOSIT_SAVE,
PERF_TALER_MINTDB_DEPOSIT),
- PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit",
- "loop_db_init_deposit"),
- // End of database initialization
- PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_start"),
- PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get",
- PERF_TALER_MINTDB_NB_DEPOSIT_GET),
- PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"),
- PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load_deposit",
- "loop_deposit_get",
- "array_depo"),
- PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit",
- "load_deposit"),
- PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"),
- PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("stop2", "loop_deposit_get"),
- PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_end"),
- PERF_TALER_MINTDB_INIT_CMD_GAUGER ("deposit_get_commit",
- "deposit_get_start",
- "deposit_get_end",
- "time per deposit check",
- PERF_TALER_MINTDB_NB_DEPOSIT_GET),
- PERF_TALER_MINTDB_INIT_CMD_END("end"),
+ PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("04 - deposit init loop end",
+ "04 - deposit init loop"),
+ PERF_TALER_MINTDB_INIT_CMD_DEBUG ("04 - deposit init complete"),
+ // End of deposit initialization
+ PERF_TALER_MINTDB_INIT_CMD_END ("end"),
};
- // Plugin init
GNUNET_log_setup ("perf-taler-mintdb",
"WARNING",
diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c
index f93bd8284..a0019f84c 100644
--- a/src/mintdb/perf_taler_mintdb_init.c
+++ b/src/mintdb/perf_taler_mintdb_init.c
@@ -30,108 +30,115 @@
/**
- * @return a randomly generated CollectableBlindcoin
+ * Generate a dummy DenominationKeyInformation for testing purposes
+ * @return a dummy denomination key
*/
-struct TALER_MINTDB_CollectableBlindcoin *
-PERF_TALER_MINTDB_collectable_blindcoin_init (
- const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
- const struct TALER_MINTDB_Reserve *reserve)
+struct TALER_MINTDB_DenominationKeyIssueInformation *
+PERF_TALER_MINTDB_denomination_init ()
{
- uint32_t random_int;
- struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
- struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
- struct {
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
- uint32_t data;
- } unsigned_data;
- struct TALER_MINTDB_CollectableBlindcoin *coin;
-
+ struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
+ struct GNUNET_TIME_Absolute anchor;
+ struct TALER_Amount amount;
- GNUNET_assert (NULL !=
- (coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
GNUNET_assert (NULL !=
- (reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ()));
+ (dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
GNUNET_assert (NULL !=
- (denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512)));
+ (dki->denom_priv.rsa_private_key
+ = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
GNUNET_assert (NULL !=
- (coin->denom_pub.rsa_public_key =
- GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key)));
- GNUNET_CRYPTO_eddsa_key_get_public (reserve_sig_key,
- &coin->reserve_pub.eddsa_pub);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &coin->amount_with_fee));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &coin->withdraw_fee));
- random_int =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
+ (dki->denom_pub.rsa_public_key =
+ GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key)));
+ GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
+ &dki->issue.denom_hash);
GNUNET_assert (NULL !=
- (coin->sig.rsa_signature =
- GNUNET_CRYPTO_rsa_sign (denomination_key,
- &random_int,
- sizeof (random_int))));
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
- &coin->h_coin_envelope);
- unsigned_data.purpose.size = htonl (sizeof (unsigned_data));
- unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
- unsigned_data.data = htonl (random_int);
+ (master_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
+ GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
+ &dki->issue.master.eddsa_pub);
+ anchor = GNUNET_TIME_absolute_get ();
+ dki->issue.start = GNUNET_TIME_absolute_hton (anchor);
+ dki->issue.expire_withdraw =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
+ GNUNET_TIME_relative_get_hour_ ()));
+ dki->issue.expire_spend =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
+ GNUNET_TIME_relative_get_hour_ ()));
+ dki->issue.expire_legal =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
+ GNUNET_TIME_relative_get_hour_ ()));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (reserve_sig_key,
- (struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data,
- &coin->reserve_sig.eddsa_signature));
- GNUNET_free (reserve_sig_key);
- GNUNET_CRYPTO_rsa_private_key_free (denomination_key);
- return coin;
+ TALER_string_to_amount (CURRENCY ":1.1", &amount));
+ TALER_amount_hton (&dki->issue.value, &amount);
+ TALER_amount_hton (&dki->issue.fee_withdraw, &amount);
+ TALER_amount_hton (&dki->issue.fee_deposit, &amount);
+ TALER_amount_hton (&dki->issue.fee_refresh, &amount);
+ dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
+ dki->issue.purpose.size =
+ htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) -
+ offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation,
+ issue.purpose));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_sign (master_prvt,
+ &dki->issue.purpose,
+ &dki->issue.signature.eddsa_signature));
+ GNUNET_free (master_prvt);
+
+ return dki;
}
-struct TALER_MINTDB_CollectableBlindcoin *
-PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin)
+/**
+ * Copies the given denomination
+ * @param reserve the deposit copy
+ * @return a copy of @a deposit; NULL if error
+ */
+struct TALER_MINTDB_DenominationKeyIssueInformation *
+PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
{
- struct TALER_MINTDB_CollectableBlindcoin *copy;
+ struct TALER_MINTDB_DenominationKeyIssueInformation *copy;
- GNUNET_assert (NULL !=
- (copy = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
- *copy = *coin;
- // No signature copy function found, Hacking it in
+ GNUNET_assert (NULL !=
+ (copy = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
+ *copy = *dki;
{
char *buffer = NULL;
int size;
GNUNET_assert (0 <
- (size = GNUNET_CRYPTO_rsa_signature_encode (
- coin->sig.rsa_signature,
+ (size = GNUNET_CRYPTO_rsa_private_key_encode (
+ dki->denom_priv.rsa_private_key,
&buffer)));
GNUNET_assert (NULL !=
- (copy->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_decode(
- buffer,
- size)));
+ (copy->denom_priv.rsa_private_key =
+ GNUNET_CRYPTO_rsa_private_key_decode(buffer, size)));
GNUNET_free (buffer);
}
GNUNET_assert (NULL !=
(copy->denom_pub.rsa_public_key =
- GNUNET_CRYPTO_rsa_public_key_dup (coin->denom_pub.rsa_public_key)));
+ GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key)));
return copy;
}
+
/**
- * Liberate memory of @a coin
+ * Free memory of a DenominationKeyIssueInformation
+ * @param dki pointer to the struct to free
*/
int
-PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin)
+PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
{
- if (NULL == coin)
+ if (NULL ==dki)
return GNUNET_OK;
+ GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key);
+ GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key);
+ GNUNET_free (dki);
- GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature);
- GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key);
- GNUNET_free (coin);
return GNUNET_OK;
}
/**
- * @return a randomly generated reserve
+ * Generate a dummy reserve for testing
+ * @return a reserve with 1000 EUR in it
*/
struct TALER_MINTDB_Reserve *
PERF_TALER_MINTDB_reserve_init ()
@@ -146,14 +153,18 @@ PERF_TALER_MINTDB_reserve_init ()
GNUNET_CRYPTO_eddsa_key_get_public (reserve_priv ,
&reserve->pub.eddsa_pub);
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1", &reserve->balance));
+ TALER_string_to_amount (CURRENCY ":1000", &reserve->balance));
reserve->expiry = GNUNET_TIME_absolute_get_forever_ ();
GNUNET_free (reserve_priv);
return reserve;
}
-
+/**
+ * Copies the given reserve
+ * @param reserve the reserve to copy
+ * @return a copy of @a reserve; NULL if error
+ */
struct TALER_MINTDB_Reserve *
PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve)
{
@@ -165,6 +176,7 @@ PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve)
/**
* Free memory of a reserve
+ * @param reserve pointer to the structure to be freed
*/
int
PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve)
@@ -177,36 +189,8 @@ PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve)
/**
- * @return a randomly generated refresh session
- */
-struct TALER_MINTDB_RefreshSession *
-PERF_TALER_MINTDB_refresh_session_init ()
-{
- struct TALER_MINTDB_RefreshSession *refresh_session;
-
- GNUNET_assert (NULL !=
- (refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession)));
- refresh_session->noreveal_index = 1;
- refresh_session->num_oldcoins = 1;
- refresh_session->num_newcoins = 1;
-
- return refresh_session;
-}
-
-
-/**
- * Free a refresh session
- */
-int
-PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session)
-{
- GNUNET_free (refresh_session);
- return GNUNET_OK;
-}
-
-
-/**
- * Create a randomly generated deposit
+ * Generate a dummy deposit for testing purposes
+ * @param dki the denomination key used to sign the key
*/
struct TALER_MINTDB_Deposit *
PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
@@ -275,8 +259,8 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn
GNUNET_assert(NULL !=
(eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ()));
GNUNET_CRYPTO_eddsa_key_get_public (
- eddsa_prv,
- &merchant_pub.eddsa_pub);
+ eddsa_prv,
+ &merchant_pub.eddsa_pub);
GNUNET_free (eddsa_prv);
}
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
@@ -305,6 +289,11 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn
}
+/**
+ * Copies the given deposit
+ * @param reserve the deposit copy
+ * @return a copy of @a deposit; NULL if error
+ */
struct TALER_MINTDB_Deposit *
PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit)
{
@@ -334,6 +323,7 @@ PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit)
/**
* Free memory of a deposit
+ * @param deposit pointer to the structure to free
*/
int
PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit)
@@ -350,102 +340,150 @@ PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit)
/**
- * Generate a randomly generate DenominationKeyInformation
+ * Generate a CollectableBlindcoin for testing purpuses
+ * @param dki denomination key used to sign the coin
+ * @param reserve reserve providing the money for the coin
+ * @return a randomly generated CollectableBlindcoin
*/
-struct TALER_MINTDB_DenominationKeyIssueInformation *
-PERF_TALER_MINTDB_denomination_init ()
+struct TALER_MINTDB_CollectableBlindcoin *
+PERF_TALER_MINTDB_collectable_blindcoin_init (
+ const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
+ const struct TALER_MINTDB_Reserve *reserve)
{
- struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
- struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
- struct GNUNET_TIME_Absolute anchor;
- struct TALER_Amount amount;
+ uint32_t random_int;
+ struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
+ struct {
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+ uint32_t data;
+ } unsigned_data;
+ struct TALER_MINTDB_CollectableBlindcoin *coin;
+
+ GNUNET_assert (NULL !=
+ (coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
GNUNET_assert (NULL !=
- (dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
- GNUNET_assert (NULL !=
- (dki->denom_priv.rsa_private_key
- = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
- GNUNET_assert (NULL !=
- (dki->denom_pub.rsa_public_key =
- GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key)));
- GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
- &dki->issue.denom_hash);
+ (reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ()));
+ {
+ char *buffer = NULL;
+ int size;
+ GNUNET_assert (0 <
+ (size = GNUNET_CRYPTO_rsa_private_key_encode (
+ dki->denom_priv.rsa_private_key,
+ &buffer)));
+ GNUNET_assert (NULL !=
+ (denomination_key =
+ GNUNET_CRYPTO_rsa_private_key_decode (buffer, size)));
+ GNUNET_free (buffer);
+ }
+
GNUNET_assert (NULL !=
- (master_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
- GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
- &dki->issue.master.eddsa_pub);
- anchor = GNUNET_TIME_absolute_get ();
- dki->issue.start = GNUNET_TIME_absolute_hton (anchor);
- dki->issue.expire_withdraw =
- GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
- GNUNET_TIME_relative_get_hour_ ()));
- dki->issue.expire_spend =
- GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
- GNUNET_TIME_relative_get_hour_ ()));
- dki->issue.expire_legal =
- GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
- GNUNET_TIME_relative_get_hour_ ()));
+ (coin->denom_pub.rsa_public_key =
+ GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key)));
+ coin->reserve_pub.eddsa_pub = reserve->pub.eddsa_pub;
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1", &amount));
- TALER_amount_hton (&dki->issue.value, &amount);
- TALER_amount_hton (&dki->issue.fee_withdraw, &amount);
- TALER_amount_hton (&dki->issue.fee_deposit, &amount);
- TALER_amount_hton (&dki->issue.fee_refresh, &amount);
- dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
- dki->issue.purpose.size =
- htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) -
- offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation,
- issue.purpose));
+ TALER_string_to_amount (CURRENCY ":1.1",
+ &coin->amount_with_fee));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (master_prvt,
- &dki->issue.purpose,
- &dki->issue.signature.eddsa_signature));
- GNUNET_free (master_prvt);
-
- return dki;
+ TALER_string_to_amount (CURRENCY ":1.1",
+ &coin->withdraw_fee));
+ random_int =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
+ GNUNET_assert (NULL !=
+ (coin->sig.rsa_signature =
+ GNUNET_CRYPTO_rsa_sign (denomination_key,
+ &random_int,
+ sizeof (random_int))));
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
+ &coin->h_coin_envelope);
+ unsigned_data.purpose.size = htonl (sizeof (unsigned_data));
+ unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
+ unsigned_data.data = htonl (random_int);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_sign (reserve_sig_key,
+ (struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data,
+ &coin->reserve_sig.eddsa_signature));
+ GNUNET_free (reserve_sig_key);
+ GNUNET_CRYPTO_rsa_private_key_free (denomination_key);
+ return coin;
}
-
-struct TALER_MINTDB_DenominationKeyIssueInformation *
-PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
+/**
+ * Copies the given coin
+ * @param coin the coin to copy
+ * @return a copy of coin; NULL if error
+ */
+struct TALER_MINTDB_CollectableBlindcoin *
+PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin)
{
- struct TALER_MINTDB_DenominationKeyIssueInformation *copy;
+ struct TALER_MINTDB_CollectableBlindcoin *copy;
- GNUNET_assert (NULL !=
- (copy = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
- *copy = *dki;
+ GNUNET_assert (NULL !=
+ (copy = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
+ *copy = *coin;
+ // No signature copy function found, Hacking it in
{
char *buffer = NULL;
int size;
GNUNET_assert (0 <
- (size = GNUNET_CRYPTO_rsa_private_key_encode (
- dki->denom_priv.rsa_private_key,
+ (size = GNUNET_CRYPTO_rsa_signature_encode (
+ coin->sig.rsa_signature,
&buffer)));
GNUNET_assert (NULL !=
- (copy->denom_priv.rsa_private_key =
- GNUNET_CRYPTO_rsa_private_key_decode(buffer, size)));
+ (copy->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_decode(
+ buffer,
+ size)));
GNUNET_free (buffer);
}
GNUNET_assert (NULL !=
(copy->denom_pub.rsa_public_key =
- GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key)));
+ GNUNET_CRYPTO_rsa_public_key_dup (coin->denom_pub.rsa_public_key)));
return copy;
}
-
/**
- * Free memory for a DenominationKeyIssueInformation
+ * Liberate memory of @a coin
+ * @param coin pointer to the structure to free
*/
int
-PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
+PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin)
{
- if (NULL ==dki)
+ if (NULL == coin)
return GNUNET_OK;
- GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key);
- GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key);
- GNUNET_free (dki);
+ GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature);
+ GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key);
+ GNUNET_free (coin);
+ return GNUNET_OK;
+}
+
+
+/**
+ * @return a randomly generated refresh session
+ */
+struct TALER_MINTDB_RefreshSession *
+PERF_TALER_MINTDB_refresh_session_init ()
+{
+ struct TALER_MINTDB_RefreshSession *refresh_session;
+
+ GNUNET_assert (NULL !=
+ (refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession)));
+ refresh_session->noreveal_index = 1;
+ refresh_session->num_oldcoins = 1;
+ refresh_session->num_newcoins = 1;
+
+ return refresh_session;
+}
+
+
+/**
+ * Free a refresh session
+ */
+int
+PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session)
+{
+ GNUNET_free (refresh_session);
return GNUNET_OK;
}
diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h
index 3e2eb3cc2..4682f800f 100644
--- a/src/mintdb/perf_taler_mintdb_init.h
+++ b/src/mintdb/perf_taler_mintdb_init.h
@@ -27,70 +27,72 @@
#define CURRENCY "EUR"
+
/**
- * @return a randomly generated CollectableBlindcoin
+ * Generate a dummy DenominationKeyInformation for testing purposes
+ * @return a dummy denomination key
*/
-struct TALER_MINTDB_CollectableBlindcoin *
-PERF_TALER_MINTDB_collectable_blindcoin_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
- const struct TALER_MINTDB_Reserve *reserve);
+struct TALER_MINTDB_DenominationKeyIssueInformation *
+PERF_TALER_MINTDB_denomination_init (void);
+
/**
- * @returns a copy of @a coin
+ * Copies the given denomination
+ * @param reserve the deposit copy
+ * @return a copy of @a deposit; NULL if error
*/
-struct TALER_MINTDB_CollectableBlindcoin *
-PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin);
+struct TALER_MINTDB_DenominationKeyIssueInformation *
+PERF_TALER_MINTDB_denomination_copy (
+ const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
/**
- * Liberate memory of @a coin
+ * Free memory of a DenominationKeyIssueInformation
+ * @param dki pointer to the struct to free
*/
int
-PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin);
+PERF_TALER_MINTDB_denomination_free (
+ struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
/**
- * @return a randomly generated reserve
+ * Generate a dummy reserve for testing
+ * @return a reserve with 1000 EUR in it
*/
struct TALER_MINTDB_Reserve *
PERF_TALER_MINTDB_reserve_init (void);
/**
- * Returns a copy of @reserve
+ * Copies the given reserve
+ * @param reserve the reserve to copy
+ * @return a copy of @a reserve; NULL if error
*/
struct TALER_MINTDB_Reserve *
PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve);
-/**
- * Frees memory allocated to @a reserve
- */
-int
-PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve);
-
/**
- * @return a randomly generated refresh session
- */
-struct TALER_MINTDB_RefreshSession *
-PERF_TALER_MINTDB_refresh_session_init (void);
-
-
-/**
- * Frees memory of a refresh_session
+ * Free memory of a reserve
+ * @param reserve pointer to the structure to be freed
*/
int
-PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session);
+PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve);
/**
- * Create a randomly generated deposit
+ * Generate a dummy deposit for testing purposes
+ * @param dki the denomination key used to sign the key
*/
struct TALER_MINTDB_Deposit *
-PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
+PERF_TALER_MINTDB_deposit_init (
+ const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
/**
- * @returns a copy of @a deposit
+ * Copies the given deposit
+ * @param reserve the deposit copy
+ * @return a copy of @a deposit; NULL if error
*/
struct TALER_MINTDB_Deposit *
PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit);
@@ -98,29 +100,41 @@ PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit);
/**
* Free memory of a deposit
+ * @param deposit pointer to the structure to free
*/
int
PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit);
/**
- * Generate a randomly generate DenominationKeyInformation
+ * Generate a CollectableBlindcoin for testing purpuses
+ * @param dki denomination key used to sign the coin
+ * @param reserve reserve providing the money for the coin
+ * @return a randomly generated CollectableBlindcoin
*/
-struct TALER_MINTDB_DenominationKeyIssueInformation *
-PERF_TALER_MINTDB_denomination_init (void);
+struct TALER_MINTDB_CollectableBlindcoin *
+PERF_TALER_MINTDB_collectable_blindcoin_init (
+ const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
+ const struct TALER_MINTDB_Reserve *reserve);
/**
- * @returns a copy of @a dki
+ * Copies the given coin
+ * @param coin the coin to copy
+ * @return a copy of coin; NULL if error
*/
-struct TALER_MINTDB_DenominationKeyIssueInformation *
-PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
+struct TALER_MINTDB_CollectableBlindcoin *
+PERF_TALER_MINTDB_collectable_blindcoin_copy (
+ const struct TALER_MINTDB_CollectableBlindcoin *coin);
+
/**
- * Free memory for a DenominationKeyIssueInformation
+ * Liberate memory of @a coin
+ * @param coin pointer to the structure to free
*/
int
-PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
+PERF_TALER_MINTDB_collectable_blindcoin_free (
+ struct TALER_MINTDB_CollectableBlindcoin *coin);
/**
@@ -135,4 +149,19 @@ PERF_TALER_MINTDB_coin_public_info_init (void);
*/
int PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi);
+
+/**
+ * @return a randomly generated refresh session
+ */
+struct TALER_MINTDB_RefreshSession *
+PERF_TALER_MINTDB_refresh_session_init (void);
+
+
+/**
+ * Frees memory of a refresh_session
+ */
+int
+PERF_TALER_MINTDB_refresh_session_free (
+ struct TALER_MINTDB_RefreshSession *refresh_session);
+
#endif
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c
index 25999792a..c377c8149 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.c
+++ b/src/mintdb/perf_taler_mintdb_interpreter.c
@@ -202,7 +202,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
{
unsigned int i;
union PERF_TALER_MINTDB_Data zero = {0};
- unsigned int jump;
+ int jump;
GNUNET_assert (GNUNET_SYSERR !=
(jump = cmd_find (state->cmd,
state->cmd[state->i]
@@ -235,7 +235,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
static void
interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
{
- unsigned int loop_index, save_index;
+ int loop_index, save_index;
unsigned int selection_chance;
// Array initialization on first loop iteration
@@ -314,7 +314,8 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
static void
interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
{
- unsigned int loop_index, save_index, loop_iter, permut_index;
+ unsigned int loop_iter;
+ int loop_index, save_index;
union PERF_TALER_MINTDB_Data zero = {0};
union PERF_TALER_MINTDB_Data *loaded_data;
@@ -327,11 +328,18 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
state->cmd[state->i]
.details.load_array.label_save)));
loop_iter = state->cmd[loop_index].details.loop.curr_iteration;
- permut_index = state->cmd[state->i].details.load_array.permutation[loop_iter];
+ {
+ int i, quotient;
+ quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved;
+ loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved;
+ for (i=0; i<=quotient; i++){
+ loop_iter = state->cmd[state->i].details.load_array.permutation[loop_iter];
+ }
+ }
/* Extracting the data from the loop_indexth indice in save_index
* array.
*/
- loaded_data = &state->cmd[save_index].details.save_array.data_saved[permut_index];
+ loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_index];
switch (state->cmd[state->i].exposed_type)
{
case PERF_TALER_MINTDB_TIME:
@@ -393,7 +401,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
case PERF_TALER_MINTDB_CMD_GAUGER:
{
- unsigned int start_index, stop_index;
+ int start_index, stop_index;
struct timespec start, stop;
unsigned long elapsed_ms;
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h
index 9f7ee4207..b69e39ebe 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.h
+++ b/src/mintdb/perf_taler_mintdb_interpreter.h
@@ -38,7 +38,7 @@
/**
- *
+ * Prints @ _label to stdout
*/
#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
{ \
@@ -86,6 +86,10 @@
/**
* Commits the duration between @a _label_start and @a _label_stop
* to Gauger with @a _description explaining
+ * @param _label_start label of the start of the measurment
+ * @param _label_stop label of the end of the measurment
+ * @param _description description of the measure displayed in gauger
+ * @param _divide number of measurments in the interval
*/
#define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \
{ \
@@ -151,27 +155,26 @@
.label_save = _label_save \
} \
}
+
/**
- * Insert a deposit into the database
+ * Inserts informations about a denomination key in the database
*/
-#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \
+#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
{ \
- .command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\
+ .command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \
.label = _label, \
- .exposed_type = PERF_TALER_MINTDB_DEPOSIT, \
- .details.insert_deposit.label_dki = _label_dki, \
+ .exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \
}
/**
- * Check if a deposit is in the database
- * @param _label_deposit Label of the deposit to use
+ * Polls the database about informations regarding a specific denomination key
*/
-#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
+#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \
{ \
- .command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
+ .command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \
.label = _label, \
.exposed_type = PERF_TALER_MINTDB_NONE, \
- .details.get_deposit.label_source = _label_deposit \
+ .details.get_denomination.label_source = _label_source, \
}
/**
@@ -199,50 +202,57 @@
/**
- * Inserts informations about a withdrawal in the database
+ * Insert a deposit into the database
+ * @param _label_dki source to use for the denomination key
*/
-#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve) \
+#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \
{ \
- .command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \
+ .command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\
.label = _label, \
- .exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \
- .details.insert_withdraw = {\
- .label_dki = _label_dki, \
- .label.reserve = _label_reserve, \
- } \
-}\
+ .exposed_type = PERF_TALER_MINTDB_DEPOSIT, \
+ .details.insert_deposit.label_dki = _label_dki, \
+}
/**
- * Polls the database about informations regarding a secific withdrawal
+ * Check if a deposit is in the database
+ * @param _label_deposit Label of the deposit to use
*/
-#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
+#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
{ \
- .command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \
+ .command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
.label = _label, \
.exposed_type = PERF_TALER_MINTDB_NONE, \
- .details.get_withdraw.label_source = _label_source, \
+ .details.get_deposit.label_source = _label_deposit \
}
+
/**
- * Inserts informations about a denomination key in the database
+ * Inserts informations about a withdrawal in the database
+ * @param _label_dki denomination key used to sign the coin
+ * @param _label_reserve reserve used to emmit the coin
*/
-#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
+#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve) \
{ \
- .command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \
+ .command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \
.label = _label, \
- .exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \
+ .exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \
+ .details.insert_withdraw = {\
+ .label_dki = _label_dki, \
+ .label_reserve = _label_reserve, \
+ } \
}
+
/**
- * Polls the database about informations regarding a specific denomination key
+ * Polls the database about informations regarding a secific withdrawal
*/
-#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \
+#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
{ \
- .command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \
+ .command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \
.label = _label, \
.exposed_type = PERF_TALER_MINTDB_NONE, \
- .details.get_denomination.label_source = _label_source, \
+ .details.get_withdraw.label_source = _label_source, \
}
diff --git a/src/mintdb/perf_taler_mintdb_values.h b/src/mintdb/perf_taler_mintdb_values.h
index f0cdd4f10..f8a8fde0b 100644
--- a/src/mintdb/perf_taler_mintdb_values.h
+++ b/src/mintdb/perf_taler_mintdb_values.h
@@ -22,10 +22,17 @@
#define __PERF_TALER_MINTDB__VALUES_H__
+#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 100
+#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 100
-#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100
-#define PERF_TALER_MINTDB_NB_DEPOSIT_GET 1
+#define PERF_TALER_MINTDB_NB_RESERVE_INIT 10000
+#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 1000
+#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100000
+#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 1000
+
+#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100000
+#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 1000
#endif