2015-06-09 17:35:33 +02:00
|
|
|
/*
|
2015-06-10 14:59:14 +02:00
|
|
|
This file is part of TALER
|
|
|
|
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
2015-06-09 17:35:33 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
TALER is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
2015-06-09 17:35:33 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
2015-06-09 17:35:33 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
2015-06-09 17:35:33 +02:00
|
|
|
/**
|
|
|
|
* @file mintdb/perf_taler_mintdb_init.c
|
|
|
|
* @brief Interpreter library for mint database performance analysis
|
|
|
|
* @author Nicolas Fournier
|
|
|
|
*/
|
2015-06-10 14:59:14 +02:00
|
|
|
#include "../include/platform.h"
|
2015-06-09 13:03:37 +02:00
|
|
|
#include <gnunet/gnunet_crypto_lib.h>
|
|
|
|
#include <gnunet/gnunet_signatures.h>
|
2015-06-10 14:59:14 +02:00
|
|
|
#include "../include/taler_mintdb_plugin.h"
|
|
|
|
#include "../include/taler_signatures.h"
|
|
|
|
#include "../include/taler_amount_lib.h"
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
|
2015-06-09 17:35:33 +02:00
|
|
|
#define CURRENCY "EUR"
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
|
2015-06-11 15:55:46 +02:00
|
|
|
/**
|
|
|
|
* @return a randomly generated CollectableBlindcoin
|
|
|
|
*/
|
2015-06-09 13:03:37 +02:00
|
|
|
struct TALER_MINTDB_CollectableBlindcoin *
|
2015-06-09 17:35:33 +02:00
|
|
|
collectable_blindcoin_init ()
|
2015-06-09 13:55:05 +02:00
|
|
|
{
|
|
|
|
// indent by 2 spaces
|
2015-06-10 14:59:14 +02:00
|
|
|
struct TALER_MINTDB_CollectableBlindcoin *coin =
|
|
|
|
GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
|
|
|
|
GNUNET_assert (NULL !=
|
2015-06-11 15:55:46 +02:00
|
|
|
(reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ())
|
|
|
|
);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key ;
|
|
|
|
GNUNET_assert (NULL !=
|
2015-06-11 15:55:46 +02:00
|
|
|
(denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512))
|
|
|
|
);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (NULL ==
|
2015-06-11 15:55:46 +02:00
|
|
|
(coin->denom_pub.rsa_public_key =
|
|
|
|
GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key))
|
2015-06-10 14:59:14 +02:00
|
|
|
);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_get_public (reserve_sig_key,
|
2015-06-11 15:55:46 +02:00
|
|
|
&coin->reserve_pub.eddsa_pub);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-06-11 15:55:46 +02:00
|
|
|
TALER_string_to_amount (CURRENCY ":1.1",
|
|
|
|
&coin->amount_with_fee));
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-06-11 15:55:46 +02:00
|
|
|
TALER_string_to_amount (CURRENCY ":1.1",
|
|
|
|
&coin->withdraw_fee));
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
uint32_t random_int =
|
|
|
|
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(coin->sig.rsa_signature =
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_CRYPTO_rsa_sign (denomination_key,
|
|
|
|
&random_int,
|
|
|
|
sizeof (random_int)
|
|
|
|
))
|
2015-06-10 14:59:14 +02:00
|
|
|
);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
2015-06-11 15:55:46 +02:00
|
|
|
&coin->h_coin_envelope);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
struct {
|
|
|
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
|
|
|
uint32_t data;
|
|
|
|
} unsigned_data;
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
unsigned_data.purpose.size = sizeof (unsigned_data);
|
|
|
|
unsigned_data.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
|
|
|
|
unsigned_data.data = random_int;
|
|
|
|
|
|
|
|
GNUNET_assert (GNUNET_OK ==
|
|
|
|
GNUNET_CRYPTO_eddsa_sign (reserve_sig_key,
|
|
|
|
(struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data,
|
|
|
|
&coin->reserve_sig.eddsa_signature)
|
|
|
|
);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_clear (reserve_sig_key);
|
|
|
|
GNUNET_CRYPTO_rsa_private_key_free (denomination_key);
|
|
|
|
return coin;
|
2015-06-09 13:03:37 +02:00
|
|
|
}
|
|
|
|
|
2015-06-09 17:35:33 +02:00
|
|
|
/**
|
2015-06-10 14:59:14 +02:00
|
|
|
* Liberate memory of @a coin
|
2015-06-09 17:35:33 +02:00
|
|
|
*/
|
|
|
|
int
|
2015-06-10 14:59:14 +02:00
|
|
|
collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin)
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-11 15:55:46 +02:00
|
|
|
if (NULL == coin)
|
|
|
|
return GNUNET_OK;
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature);
|
|
|
|
GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key);
|
2015-06-09 17:35:33 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_free (coin);
|
2015-06-09 17:35:33 +02:00
|
|
|
|
|
|
|
return GNUNET_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-09 17:35:33 +02:00
|
|
|
/**
|
|
|
|
* @return a randomly generated reserve
|
|
|
|
*/
|
2015-06-09 13:03:37 +02:00
|
|
|
struct TALER_MINTDB_Reserve *
|
2015-06-10 14:59:14 +02:00
|
|
|
reserve_init ()
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-10 14:59:14 +02:00
|
|
|
struct TALER_MINTDB_Reserve *reserve ;
|
2015-06-11 15:55:46 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(reserve = GNUNET_new (struct TALER_MINTDB_Reserve)
|
|
|
|
));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_priv ;
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(reserve_priv = GNUNET_CRYPTO_eddsa_key_create ()
|
|
|
|
));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_get_public (reserve_priv ,
|
2015-06-11 15:55:46 +02:00
|
|
|
&reserve->pub.eddsa_pub);
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-06-11 15:55:46 +02:00
|
|
|
TALER_string_to_amount (CURRENCY ":1.1", &reserve->balance)
|
|
|
|
);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
reserve->expiry = GNUNET_TIME_absolute_get_forever_ ();
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_clear (reserve_priv);
|
|
|
|
return reserve;
|
|
|
|
}
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-11 15:55:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free memory of a reserve
|
|
|
|
*/
|
2015-06-10 14:59:14 +02:00
|
|
|
int
|
|
|
|
reserve_free (struct TALER_MINTDB_Reserve *reserve)
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_free (reserve);
|
|
|
|
return GNUNET_OK;
|
2015-06-09 13:03:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
/**
|
|
|
|
* @return a randomly generated refresh session
|
|
|
|
*/
|
|
|
|
struct TALER_MINTDB_RefreshSession *
|
|
|
|
refresh_session_init ()
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-10 14:59:14 +02:00
|
|
|
struct TALER_MINTDB_RefreshSession *refresh_session;
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession)
|
|
|
|
));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
refresh_session->noreveal_index = 1;
|
|
|
|
refresh_session->num_oldcoins = 1;
|
|
|
|
refresh_session->num_newcoins = 1;
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
return refresh_session;
|
|
|
|
}
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
/**
|
|
|
|
* Free a refresh session
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session)
|
|
|
|
{
|
|
|
|
GNUNET_free (refresh_session);
|
|
|
|
return GNUNET_OK;
|
|
|
|
}
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
/**
|
|
|
|
* Create a randomly generated deposit
|
|
|
|
*/
|
|
|
|
struct TALER_MINTDB_Deposit *
|
|
|
|
deposit_init ()
|
|
|
|
{
|
|
|
|
static int transaction_id = 0;
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
struct TALER_MINTDB_Deposit *deposit ;
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(deposit = GNUNET_new (struct TALER_MINTDB_Deposit)
|
|
|
|
));
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
deposit-> transaction_id = transaction_id;
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-06-11 15:55:46 +02:00
|
|
|
TALER_string_to_amount (CURRENCY ":1.1", &deposit->amount_with_fee)
|
|
|
|
);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-06-11 15:55:46 +02:00
|
|
|
TALER_string_to_amount (CURRENCY ":0.1", &deposit->deposit_fee)
|
2015-06-10 14:59:14 +02:00
|
|
|
);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
deposit->timestamp = GNUNET_TIME_absolute_get ();
|
|
|
|
deposit->refund_deadline = GNUNET_TIME_absolute_get ();
|
|
|
|
|
|
|
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
2015-06-11 15:55:46 +02:00
|
|
|
&deposit->h_contract);
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
2015-06-11 15:55:46 +02:00
|
|
|
&deposit->h_wire);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
// Coin Spend Signature
|
|
|
|
{
|
|
|
|
struct u32_presign
|
2015-06-09 13:03:37 +02:00
|
|
|
{
|
2015-06-10 14:59:14 +02:00
|
|
|
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 ()
|
|
|
|
));
|
|
|
|
|
|
|
|
uint32_t random_int =
|
|
|
|
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
|
2015-06-11 15:55:46 +02:00
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
unsigned_data.purpose.size = sizeof (unsigned_data);
|
2015-06-11 15:55:46 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
unsigned_data.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
|
|
|
|
unsigned_data.data = random_int;
|
|
|
|
|
|
|
|
GNUNET_assert (GNUNET_OK ==
|
|
|
|
GNUNET_CRYPTO_eddsa_sign (eddsa_prvt,
|
|
|
|
(struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data,
|
|
|
|
&deposit->csig.eddsa_signature)
|
|
|
|
);
|
2015-06-11 15:55:46 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_clear (eddsa_prvt);
|
|
|
|
}
|
|
|
|
|
2015-06-11 15:55:46 +02:00
|
|
|
printf("coin signed");
|
2015-06-10 14:59:14 +02:00
|
|
|
// Merchant Key
|
|
|
|
{
|
|
|
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv;
|
|
|
|
GNUNET_assert(NULL !=
|
|
|
|
(eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ()
|
|
|
|
));
|
|
|
|
|
|
|
|
GNUNET_CRYPTO_eddsa_key_get_public (
|
2015-06-11 15:55:46 +02:00
|
|
|
eddsa_prv,
|
|
|
|
&deposit->merchant_pub.eddsa_pub);
|
2015-06-10 14:59:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
GNUNET_CRYPTO_eddsa_key_clear (eddsa_prv);
|
|
|
|
}
|
2015-06-11 15:55:46 +02:00
|
|
|
|
|
|
|
printf("merchant ok");
|
2015-06-10 14:59:14 +02:00
|
|
|
// Coin
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()
|
|
|
|
));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_get_public (
|
|
|
|
eddsa_prvt,
|
|
|
|
&deposit->coin.coin_pub.eddsa_pub
|
|
|
|
);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_clear (eddsa_prvt);
|
2015-06-09 13:03:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-06-10 14:59:14 +02:00
|
|
|
struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_prv;
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_assert (NULL !=
|
2015-06-10 14:59:14 +02:00
|
|
|
(rsa_prv = GNUNET_CRYPTO_rsa_private_key_create (128)
|
|
|
|
));
|
|
|
|
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(deposit->coin.denom_pub.rsa_public_key =
|
|
|
|
GNUNET_CRYPTO_rsa_private_key_get_public (rsa_prv)
|
|
|
|
));
|
2015-06-10 14:59:14 +02:00
|
|
|
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(deposit->coin.denom_sig.rsa_signature =
|
|
|
|
GNUNET_CRYPTO_rsa_sign (rsa_prv,
|
2015-06-10 14:59:14 +02:00
|
|
|
(void *) &deposit->coin.coin_pub.eddsa_pub,
|
|
|
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)
|
|
|
|
)
|
2015-06-11 15:55:46 +02:00
|
|
|
));
|
2015-06-10 14:59:14 +02:00
|
|
|
|
|
|
|
GNUNET_CRYPTO_rsa_private_key_free (rsa_prv);
|
2015-06-09 13:03:37 +02:00
|
|
|
}
|
2015-06-10 14:59:14 +02:00
|
|
|
}
|
|
|
|
return deposit;
|
2015-06-09 13:03:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
/**
|
|
|
|
* Free memory of a deposit
|
|
|
|
*/
|
2015-06-09 17:35:33 +02:00
|
|
|
int
|
2015-06-10 14:59:14 +02:00
|
|
|
deposit_free (struct TALER_MINTDB_Deposit *deposit)
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-11 15:55:46 +02:00
|
|
|
if ( NULL == deposit)
|
|
|
|
return GNUNET_OK;
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_rsa_public_key_free (deposit->coin.denom_pub.rsa_public_key);
|
|
|
|
GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
|
2015-06-09 17:35:33 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_free (deposit);
|
2015-06-09 17:35:33 +02:00
|
|
|
|
|
|
|
return GNUNET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
/**
|
|
|
|
* Generate a randomly generate DenominationKeyInformation
|
|
|
|
*/
|
2015-06-09 13:03:37 +02:00
|
|
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
2015-06-10 14:59:14 +02:00
|
|
|
denomination_init ()
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-10 14:59:14 +02:00
|
|
|
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
|
|
|
struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
|
|
|
|
struct GNUNET_TIME_Absolute anchor;
|
|
|
|
struct TALER_Amount amount;
|
|
|
|
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)
|
|
|
|
));
|
|
|
|
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(dki->denom_priv.rsa_private_key
|
2015-06-11 15:55:46 +02:00
|
|
|
= GNUNET_CRYPTO_rsa_private_key_create (128)
|
2015-06-10 14:59:14 +02:00
|
|
|
));
|
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(dki->denom_pub.rsa_public_key =
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key)
|
2015-06-10 14:59:14 +02:00
|
|
|
));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
2015-06-10 14:59:14 +02:00
|
|
|
&dki->issue.denom_hash);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (NULL !=
|
|
|
|
(master_prvt = GNUNET_CRYPTO_eddsa_key_create ()
|
|
|
|
));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
|
2015-06-11 15:55:46 +02:00
|
|
|
&dki->issue.master.eddsa_pub);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
anchor = GNUNET_TIME_absolute_get ();
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
dki->issue.start = GNUNET_TIME_absolute_hton (anchor);
|
|
|
|
dki->issue.expire_withdraw =
|
|
|
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_TIME_relative_get_hour_ ()));
|
2015-06-09 13:03:37 +02:00
|
|
|
dki->issue.expire_spend =
|
|
|
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_TIME_relative_get_hour_ ()));
|
2015-06-09 13:03:37 +02:00
|
|
|
dki->issue.expire_legal =
|
|
|
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
2015-06-11 15:55:46 +02:00
|
|
|
GNUNET_TIME_relative_get_hour_ ()));
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
|
|
|
TALER_string_to_amount (CURRENCY ":1.1", &amount)
|
|
|
|
);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
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);
|
2015-06-10 14:59:14 +02:00
|
|
|
dki->issue.purpose.size =
|
|
|
|
htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) -
|
2015-06-11 15:55:46 +02:00
|
|
|
offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation,
|
|
|
|
issue.purpose));
|
2015-06-09 13:03:37 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_eddsa_sign (master_prvt,
|
|
|
|
&dki->issue.purpose,
|
|
|
|
&dki->issue.signature.eddsa_signature));
|
|
|
|
|
|
|
|
GNUNET_CRYPTO_eddsa_key_clear (master_prvt);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
|
|
|
return dki;
|
|
|
|
}
|
|
|
|
|
2015-06-11 15:55:46 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
/**
|
|
|
|
* Free memory for a DenominationKeyIssueInformation
|
|
|
|
*/
|
2015-06-09 13:03:37 +02:00
|
|
|
int
|
2015-06-10 14:59:14 +02:00
|
|
|
denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
|
2015-06-09 17:35:33 +02:00
|
|
|
{
|
2015-06-11 15:55:46 +02:00
|
|
|
if (NULL ==dki)
|
|
|
|
return GNUNET_OK;
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key);
|
|
|
|
GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key);
|
2015-06-09 13:03:37 +02:00
|
|
|
|
2015-06-10 14:59:14 +02:00
|
|
|
GNUNET_free (dki);
|
2015-06-09 13:55:05 +02:00
|
|
|
|
2015-06-09 13:03:37 +02:00
|
|
|
return GNUNET_OK;
|
|
|
|
}
|