From 747d0832796cfd525321090f59d70c4d975779dc Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Wed, 15 Jul 2015 18:06:50 +0200 Subject: [PATCH] using coin to create deposit --- src/mintdb/perf_taler_mintdb_init.c | 28 +++------------------- src/mintdb/perf_taler_mintdb_init.h | 2 +- src/mintdb/perf_taler_mintdb_interpreter.c | 10 ++++---- src/mintdb/perf_taler_mintdb_interpreter.h | 8 +++---- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c index 97260940b..b2d8c8afa 100644 --- a/src/mintdb/perf_taler_mintdb_init.c +++ b/src/mintdb/perf_taler_mintdb_init.c @@ -197,10 +197,9 @@ PERF_TALER_MINTDB_reserve_free (struct PERF_TALER_MINTDB_Reserve *reserve) * @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 PERF_TALER_MINTDB_Coin *coin) { struct TALER_MINTDB_Deposit *deposit; - struct TALER_CoinPublicInfo coin; struct TALER_CoinSpendSignatureP csig; struct TALER_MerchantPublicKeyP merchant_pub; struct GNUNET_HashCode h_contract; @@ -219,42 +218,21 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn GNUNET_assert (NULL != (deposit = GNUNET_malloc (sizeof (struct TALER_MINTDB_Deposit) + sizeof (wire)))); - { // coin - struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt; - - GNUNET_assert (NULL != - (eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ())); - GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prvt, - &coin.coin_pub.eddsa_pub); - GNUNET_assert (NULL != - (coin.denom_pub.rsa_public_key = - GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key))); - GNUNET_assert (NULL != - (coin.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, - &coin.coin_pub.eddsa_pub, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))); - GNUNET_free (eddsa_prvt); - } { //csig struct u32_presign { struct GNUNET_CRYPTO_EccSignaturePurpose purpose; uint32_t data; } unsigned_data; - struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt; - GNUNET_assert (NULL != - (eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ())); unsigned_data.data = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); unsigned_data.purpose.size = htonl (sizeof (struct u32_presign)); unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (eddsa_prvt, + GNUNET_CRYPTO_eddsa_sign (&coin->priv, &unsigned_data.purpose, &csig.eddsa_signature)); - GNUNET_free (eddsa_prvt); } { //merchant_pub struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv; @@ -278,7 +256,7 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":0.1", &deposit_fee)); - deposit->coin = coin; + deposit->coin = coin->public_info; deposit->csig = csig; deposit->h_contract = h_contract; deposit->h_wire = h_wire; diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h index 06ce2df82..7a96f66d8 100644 --- a/src/mintdb/perf_taler_mintdb_init.h +++ b/src/mintdb/perf_taler_mintdb_init.h @@ -123,7 +123,7 @@ PERF_TALER_MINTDB_reserve_free (struct PERF_TALER_MINTDB_Reserve *reserve); */ struct TALER_MINTDB_Deposit * PERF_TALER_MINTDB_deposit_init ( - const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); + const struct PERF_TALER_MINTDB_Coin *coin); /** diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index 5715a5ed8..d4b821975 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -497,14 +497,14 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT: { - int dki_index; + int coin_index; struct TALER_MINTDB_Deposit *deposit; GNUNET_assert (GNUNET_SYSERR != - (dki_index = cmd_find (state->cmd, - state->cmd[state->i].details.insert_deposit.label_dki))); + (coin_index = cmd_find (state->cmd, + state->cmd[state->i].details.insert_deposit.label_coin))); GNUNET_assert (NULL != - (deposit = PERF_TALER_MINTDB_deposit_init (state->cmd[dki_index].exposed.data.dki))); + (deposit = PERF_TALER_MINTDB_deposit_init (state->cmd[coin_index].exposed.data.coin))); GNUNET_assert ( state->plugin->insert_deposit (state->plugin->cls, @@ -974,7 +974,7 @@ PERF_TALER_MINTDB_check (const struct PERF_TALER_MINTDB_Cmd *cmd) case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT: ret_loc = find_test (cmd, - cmd[i].details.insert_deposit.label_dki, + cmd[i].details.insert_deposit.label_coin, i, "label_dki"); break; diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index b9042262a..a282167ea 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -293,14 +293,14 @@ * @exposes #PERF_TALER_MINTDB_DEPOSIT * * @param _label the label of this command - * @param _label_dki source to use for the denomination key + * @param _label_coin source of the coin used to pay */ -#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \ +#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_coin) \ { \ .command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\ .label = _label, \ .exposed.type = PERF_TALER_MINTDB_DEPOSIT, \ - .details.insert_deposit.label_dki = _label_dki, \ + .details.insert_deposit.label_coin = _label_coin, \ } @@ -732,7 +732,7 @@ union PERF_TALER_MINTDB_CMD_Details /** * Label of the source where the reserve used to create the coin is */ - const char *label_dki; + const char *label_coin; } insert_deposit;