save reserve private key
This commit is contained in:
parent
eeafe9a8dc
commit
3a4052d16d
@ -140,22 +140,25 @@ PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInf
|
||||
* Generate a dummy reserve for testing
|
||||
* @return a reserve with 1000 EUR in it
|
||||
*/
|
||||
struct TALER_MINTDB_Reserve *
|
||||
struct PERF_TALER_MINTDB_Reserve *
|
||||
PERF_TALER_MINTDB_reserve_init ()
|
||||
{
|
||||
struct TALER_MINTDB_Reserve *reserve;
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_priv;
|
||||
struct PERF_TALER_MINTDB_Reserve *reserve;
|
||||
|
||||
GNUNET_assert (NULL !=
|
||||
(reserve = GNUNET_new (struct TALER_MINTDB_Reserve)));
|
||||
GNUNET_assert (NULL !=
|
||||
(reserve_priv = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (reserve_priv ,
|
||||
&reserve->pub.eddsa_pub);
|
||||
(reserve = GNUNET_new (struct PERF_TALER_MINTDB_Reserve)));
|
||||
{/* private */
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey *private;
|
||||
GNUNET_assert (NULL !=
|
||||
(private = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||
reserve->private = *private;
|
||||
}
|
||||
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private,
|
||||
&reserve->reserve.pub.eddsa_pub);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_string_to_amount (CURRENCY ":1000", &reserve->balance));
|
||||
reserve->expiry = GNUNET_TIME_absolute_get_forever_ ();
|
||||
GNUNET_free (reserve_priv);
|
||||
TALER_string_to_amount (CURRENCY ":1000", &reserve->reserve.balance));
|
||||
reserve->reserve.expiry = GNUNET_TIME_absolute_get_forever_ ();
|
||||
return reserve;
|
||||
}
|
||||
|
||||
@ -165,11 +168,12 @@ PERF_TALER_MINTDB_reserve_init ()
|
||||
* @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)
|
||||
struct PERF_TALER_MINTDB_Reserve *
|
||||
PERF_TALER_MINTDB_reserve_copy (const struct PERF_TALER_MINTDB_Reserve *reserve)
|
||||
{
|
||||
struct TALER_MINTDB_Reserve *copy;
|
||||
GNUNET_assert (NULL != (copy = GNUNET_new (struct TALER_MINTDB_Reserve)));
|
||||
struct PERF_TALER_MINTDB_Reserve *copy;
|
||||
GNUNET_assert (NULL !=
|
||||
(copy = GNUNET_new (struct PERF_TALER_MINTDB_Reserve)));
|
||||
*copy = *reserve;
|
||||
return copy;
|
||||
}
|
||||
@ -180,7 +184,7 @@ PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve)
|
||||
* @param reserve pointer to the structure to be freed
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve)
|
||||
PERF_TALER_MINTDB_reserve_free (struct PERF_TALER_MINTDB_Reserve *reserve)
|
||||
{
|
||||
if (NULL == reserve)
|
||||
return GNUNET_OK;
|
||||
@ -346,10 +350,10 @@ PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit)
|
||||
struct TALER_MINTDB_CollectableBlindcoin *
|
||||
PERF_TALER_MINTDB_collectable_blindcoin_init (
|
||||
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
||||
const struct TALER_MINTDB_Reserve *reserve)
|
||||
const struct PERF_TALER_MINTDB_Reserve *reserve)
|
||||
{
|
||||
uint32_t random_int;
|
||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
|
||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
|
||||
struct {
|
||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||
@ -376,7 +380,7 @@ PERF_TALER_MINTDB_collectable_blindcoin_init (
|
||||
GNUNET_assert (NULL !=
|
||||
(coin->denom_pub.rsa_public_key =
|
||||
GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key)));
|
||||
coin->reserve_pub.eddsa_pub = reserve->pub.eddsa_pub;
|
||||
coin->reserve_pub.eddsa_pub = reserve->reserve.pub.eddsa_pub;
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_string_to_amount (CURRENCY ":1.1",
|
||||
&coin->amount_with_fee));
|
||||
|
@ -26,6 +26,43 @@
|
||||
|
||||
#define CURRENCY "EUR"
|
||||
|
||||
/**
|
||||
* All information about a reserve
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_Reserve
|
||||
{
|
||||
/**
|
||||
* Information about a rserve available to the Mint
|
||||
*/
|
||||
struct TALER_MINTDB_Reserve reserve;
|
||||
|
||||
/**
|
||||
* Private key of a reserve
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey private;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* All informations about a coin
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_Coin
|
||||
{
|
||||
/**
|
||||
* Blinded coin, known by the mint
|
||||
*/
|
||||
struct TALER_MINTDB_CollectableBlindcoin blind;
|
||||
|
||||
/**
|
||||
* Public key of the coin and othes informations
|
||||
*/
|
||||
struct TALER_CoinPublicInfo public_info;
|
||||
|
||||
/**
|
||||
* Private key of the coin
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey priv;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@ -59,7 +96,7 @@ PERF_TALER_MINTDB_denomination_free (
|
||||
* Generate a dummy reserve for testing
|
||||
* @return a reserve with 1000 EUR in it
|
||||
*/
|
||||
struct TALER_MINTDB_Reserve *
|
||||
struct PERF_TALER_MINTDB_Reserve *
|
||||
PERF_TALER_MINTDB_reserve_init (void);
|
||||
|
||||
|
||||
@ -68,8 +105,8 @@ PERF_TALER_MINTDB_reserve_init (void);
|
||||
* @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);
|
||||
struct PERF_TALER_MINTDB_Reserve *
|
||||
PERF_TALER_MINTDB_reserve_copy (const struct PERF_TALER_MINTDB_Reserve *reserve);
|
||||
|
||||
|
||||
/**
|
||||
@ -77,7 +114,7 @@ PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve);
|
||||
* @param reserve pointer to the structure to be freed
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve);
|
||||
PERF_TALER_MINTDB_reserve_free (struct PERF_TALER_MINTDB_Reserve *reserve);
|
||||
|
||||
|
||||
/**
|
||||
@ -115,7 +152,7 @@ PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit);
|
||||
struct TALER_MINTDB_CollectableBlindcoin *
|
||||
PERF_TALER_MINTDB_collectable_blindcoin_init (
|
||||
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
||||
const struct TALER_MINTDB_Reserve *reserve);
|
||||
const struct PERF_TALER_MINTDB_Reserve *reserve);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -533,7 +533,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
|
||||
case PERF_TALER_MINTDB_CMD_INSERT_RESERVE:
|
||||
{
|
||||
struct TALER_MINTDB_Reserve *reserve;
|
||||
struct PERF_TALER_MINTDB_Reserve *reserve;
|
||||
json_t *details = NULL;
|
||||
GNUNET_assert (NULL !=
|
||||
(details = json_pack ("{s:i}","justification",
|
||||
@ -544,8 +544,8 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
state->plugin->reserves_in_insert (
|
||||
state->plugin->cls,
|
||||
state->session,
|
||||
&reserve->pub,
|
||||
&reserve->balance,
|
||||
&reserve->reserve.pub,
|
||||
&reserve->reserve.balance,
|
||||
GNUNET_TIME_absolute_get (),
|
||||
details
|
||||
);
|
||||
@ -568,7 +568,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
(state->plugin->reserve_get (state->plugin->cls,
|
||||
state->session,
|
||||
data.data.reserve)));
|
||||
&data.data.reserve->reserve)));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -587,7 +587,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
GNUNET_assert (NULL !=
|
||||
(history = state->plugin->get_reserve_history (state->plugin->cls,
|
||||
state->session,
|
||||
&data.data.reserve->pub)));
|
||||
&data.data.reserve->reserve.pub)));
|
||||
state->plugin->free_reserve_history (state->plugin->cls,
|
||||
history);
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ struct PERF_TALER_MINTDB_Data
|
||||
/** #PERF_TALER_MINTDB_BLINDCOIN */
|
||||
struct TALER_MINTDB_CollectableBlindcoin *blindcoin;
|
||||
/** #PERF_TALER_MINTDB_RESERVE */
|
||||
struct TALER_MINTDB_Reserve *reserve;
|
||||
struct PERF_TALER_MINTDB_Reserve *reserve;
|
||||
/** #PERF_TALER_MINTDB_DENOMINATION_INFO */
|
||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
||||
} data;
|
||||
|
Loading…
Reference in New Issue
Block a user