aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/coding-style.txt7
-rw-r--r--src/include/taler_crypto_lib.h48
-rw-r--r--src/include/taler_signatures.h4
-rw-r--r--src/mint/plugin_mintdb_postgres.c139
-rw-r--r--src/mint/taler-mint-httpd_db.c61
-rw-r--r--src/mint/taler-mint-httpd_db.h11
-rw-r--r--src/mint/taler-mint-httpd_deposit.c2
-rw-r--r--src/mint/taler-mint-httpd_refresh.c113
-rw-r--r--src/mint/taler-mint-httpd_responses.c2
-rw-r--r--src/mint/taler_mintdb_plugin.h76
10 files changed, 238 insertions, 225 deletions
diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index 2215ab0ad..e9c3a3138 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -44,6 +44,13 @@ Naming conventions:
MUST match the subdirectory of src/ in which the symbol is defined
+ from libtalerutil start just with TALER_, without subsystemname
+* structs:
+ + structs that are 'packed' and do not contain pointers and are
+ thus suitable for hashing or similar operations are distinguished
+ by adding a "P" at the end of the name. (NEW) Note that this
+ convention does not hold for the GNUnet-structs (yet).
+
+
* private (library-internal) symbols (including structs and macros)
+ must not start with TALER_ or any other prefix
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 0c0ad8865..a7e902777 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -27,6 +27,8 @@
/* ****************** Coin crypto primitives ************* */
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Type of public keys for Taler reserves.
*/
@@ -269,6 +271,10 @@ struct TALER_CoinSpendSignature
};
+GNUNET_NETWORK_STRUCT_END
+
+
+
/**
* Type of blinding keys for Taler.
*/
@@ -358,6 +364,9 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info);
/* ****************** Refresh crypto primitives ************* */
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Secret used to decrypt the key to decrypt link secrets.
*/
@@ -397,45 +406,48 @@ struct TALER_EncryptedLinkSecret
/**
- * Representation of an encrypted refresh link.
+ * Representation of an refresh link in cleartext.
*/
-struct TALER_RefreshLinkEncrypted
+struct TALER_RefreshLinkDecrypted
{
/**
- * Encrypted blinding key with @e blinding_key_enc_size bytes,
- * must be allocated at the end of this struct.
- */
- const char *blinding_key_enc;
-
- /**
- * Number of bytes in @e blinding_key_enc.
+ * Private key of the coin.
*/
- size_t blinding_key_enc_size;
+ struct TALER_CoinSpendPrivateKey coin_priv;
/**
- * Encrypted private key of the coin.
+ * Blinding key.
*/
- char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKey)];
+ struct TALER_DenominationBlindingKey blinding_key;
};
+GNUNET_NETWORK_STRUCT_END
+
+
/**
- * Representation of an refresh link in cleartext.
+ * Representation of an encrypted refresh link.
*/
-struct TALER_RefreshLinkDecrypted
+struct TALER_RefreshLinkEncrypted
{
/**
- * Private key of the coin.
+ * Encrypted blinding key with @e blinding_key_enc_size bytes,
+ * must be allocated at the end of this struct.
*/
- struct TALER_CoinSpendPrivateKey coin_priv;
+ const char *blinding_key_enc;
/**
- * Blinding key.
+ * Number of bytes in @e blinding_key_enc.
*/
- struct TALER_DenominationBlindingKey blinding_key;
+ size_t blinding_key_enc_size;
+
+ /**
+ * Encrypted private key of the coin.
+ */
+ char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKey)];
};
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 51134bf26..fa713dc42 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -253,9 +253,9 @@ struct RefreshMeltCoinSignature
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
- * Which melting operation should the coin become a part of.
+ * Which melting session should the coin become a part of.
*/
- struct GNUNET_HashCode melt_hash;
+ struct GNUNET_HashCode session_hash;
/**
* How much of the value of the coin should be melted? This amount
diff --git a/src/mint/plugin_mintdb_postgres.c b/src/mint/plugin_mintdb_postgres.c
index 1c0388427..1c6851d86 100644
--- a/src/mint/plugin_mintdb_postgres.c
+++ b/src/mint/plugin_mintdb_postgres.c
@@ -220,11 +220,11 @@ postgres_create_tables (void *cls,
",expended_value INT4 NOT NULL"
",expended_fraction INT4 NOT NULL"
",expended_currency VARCHAR(4) NOT NULL"
- ",refresh_session_pub BYTEA"
+ ",refresh_session_hash BYTEA"
")");
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_sessions "
"("
- " session_pub BYTEA PRIMARY KEY CHECK (length(session_pub) = 32)"
+ " session_hash BYTEA PRIMARY KEY CHECK (length(session_hash) = 32)"
",session_melt_sig BYTEA"
",session_commit_sig BYTEA"
",noreveal_index INT2 NOT NULL"
@@ -234,14 +234,14 @@ postgres_create_tables (void *cls,
") ");
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_order "
"( "
- " session_pub BYTEA NOT NULL REFERENCES refresh_sessions (session_pub)"
+ " session_hash BYTEA NOT NULL REFERENCES refresh_sessions (session_hash)"
",newcoin_index INT2 NOT NULL "
",denom_pub BYTEA NOT NULL "
- ",PRIMARY KEY (session_pub, newcoin_index)"
+ ",PRIMARY KEY (session_hash, newcoin_index)"
") ");
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_commit_link"
"("
- " session_pub BYTEA NOT NULL REFERENCES refresh_sessions (session_pub)"
+ " session_hash BYTEA NOT NULL REFERENCES refresh_sessions (session_hash)"
",transfer_pub BYTEA NOT NULL"
",link_secret_enc BYTEA NOT NULL"
// index of the old coin in the customer's request
@@ -252,7 +252,7 @@ postgres_create_tables (void *cls,
")");
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_commit_coin"
"("
- " session_pub BYTEA NOT NULL REFERENCES refresh_sessions (session_pub) "
+ " session_hash BYTEA NOT NULL REFERENCES refresh_sessions (session_hash) "
",link_vector_enc BYTEA NOT NULL"
// index of the new coin in the customer's request
",newcoin_index INT2 NOT NULL"
@@ -262,14 +262,14 @@ postgres_create_tables (void *cls,
")");
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_melt"
"("
- " session_pub BYTEA NOT NULL REFERENCES refresh_sessions (session_pub) "
+ " session_hash BYTEA NOT NULL REFERENCES refresh_sessions (session_hash) "
",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) "
",denom_pub BYTEA NOT NULL "
",oldcoin_index INT2 NOT NULL"
")");
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_collectable"
"("
- " session_pub BYTEA NOT NULL REFERENCES refresh_sessions (session_pub) "
+ " session_hash BYTEA NOT NULL REFERENCES refresh_sessions (session_hash) "
",ev_sig BYTEA NOT NULL"
",newcoin_index INT2 NOT NULL"
")");
@@ -393,16 +393,16 @@ postgres_prepare (PGconn *db_conn)
#if 0
PREPARE ("get_refresh_session",
"SELECT "
- " (SELECT count(*) FROM refresh_melt WHERE session_pub = $1)::INT2 as num_oldcoins "
+ " (SELECT count(*) FROM refresh_melt WHERE session_hash = $1)::INT2 as num_oldcoins "
",(SELECT count(*) FROM refresh_blind_session_keys "
- " WHERE session_pub = $1 and cnc_index = 0)::INT2 as num_newcoins "
+ " WHERE session_hash = $1 and cnc_index = 0)::INT2 as num_newcoins "
",(SELECT count(*) FROM refresh_blind_session_keys "
- " WHERE session_pub = $1 and newcoin_index = 0)::INT2 as kappa "
+ " WHERE session_hash = $1 and newcoin_index = 0)::INT2 as kappa "
",noreveal_index"
",session_commit_sig "
",reveal_ok "
"FROM refresh_sessions "
- "WHERE session_pub = $1",
+ "WHERE session_hash = $1",
1, NULL);
#endif
@@ -410,7 +410,7 @@ postgres_prepare (PGconn *db_conn)
"SELECT "
" coin_pub, denom_pub, denom_sig "
",expended_value, expended_fraction, expended_currency "
- ",refresh_session_pub "
+ ",refresh_session_hash "
"FROM known_coins "
"WHERE coin_pub = $1",
1, NULL);
@@ -422,7 +422,7 @@ postgres_prepare (PGconn *db_conn)
",expended_value = $4 "
",expended_fraction = $5 "
",expended_currency = $6 "
- ",refresh_session_pub = $7 "
+ ",refresh_session_hash = $7 "
"WHERE "
" coin_pub = $1 ",
7, NULL);
@@ -434,7 +434,7 @@ postgres_prepare (PGconn *db_conn)
",expended_value"
",expended_fraction"
",expended_currency"
- ",refresh_session_pub"
+ ",refresh_session_hash"
")"
"VALUES ($1,$2,$3,$4,$5,$6,$7)",
7, NULL);
@@ -443,26 +443,26 @@ postgres_prepare (PGconn *db_conn)
" transfer_pub "
",link_secret_enc "
"FROM refresh_commit_link "
- "WHERE session_pub = $1 AND cnc_index = $2 AND oldcoin_index = $3",
+ "WHERE session_hash = $1 AND cnc_index = $2 AND oldcoin_index = $3",
3, NULL);
PREPARE ("get_refresh_commit_coin",
"SELECT "
" link_vector_enc "
",coin_ev "
"FROM refresh_commit_coin "
- "WHERE session_pub = $1 AND cnc_index = $2 AND newcoin_index = $3",
+ "WHERE session_hash = $1 AND cnc_index = $2 AND newcoin_index = $3",
3, NULL);
PREPARE ("insert_refresh_order",
"INSERT INTO refresh_order ( "
" newcoin_index "
- ",session_pub "
+ ",session_hash "
",denom_pub "
") "
"VALUES ($1, $2, $3) ",
3, NULL);
PREPARE ("insert_refresh_melt",
"INSERT INTO refresh_melt ( "
- " session_pub "
+ " session_hash "
",oldcoin_index "
",coin_pub "
",denom_pub "
@@ -472,28 +472,28 @@ postgres_prepare (PGconn *db_conn)
PREPARE ("get_refresh_order",
"SELECT denom_pub "
"FROM refresh_order "
- "WHERE session_pub = $1 AND newcoin_index = $2",
+ "WHERE session_hash = $1 AND newcoin_index = $2",
2, NULL);
PREPARE ("get_refresh_collectable",
"SELECT ev_sig "
"FROM refresh_collectable "
- "WHERE session_pub = $1 AND newcoin_index = $2",
+ "WHERE session_hash = $1 AND newcoin_index = $2",
2, NULL);
PREPARE ("get_refresh_melt",
"SELECT coin_pub "
"FROM refresh_melt "
- "WHERE session_pub = $1 AND oldcoin_index = $2",
+ "WHERE session_hash = $1 AND oldcoin_index = $2",
2, NULL);
PREPARE ("insert_refresh_session",
"INSERT INTO refresh_sessions ( "
- " session_pub "
+ " session_hash "
",noreveal_index "
") "
"VALUES ($1, $2) ",
2, NULL);
PREPARE ("insert_refresh_commit_link",
"INSERT INTO refresh_commit_link ( "
- " session_pub "
+ " session_hash "
",transfer_pub "
",cnc_index "
",oldcoin_index "
@@ -503,7 +503,7 @@ postgres_prepare (PGconn *db_conn)
5, NULL);
PREPARE ("insert_refresh_commit_coin",
"INSERT INTO refresh_commit_coin ( "
- " session_pub "
+ " session_hash "
",coin_ev "
",cnc_index "
",newcoin_index "
@@ -513,7 +513,7 @@ postgres_prepare (PGconn *db_conn)
5, NULL);
PREPARE ("insert_refresh_collectable",
"INSERT INTO refresh_collectable ( "
- " session_pub "
+ " session_hash "
",newcoin_index "
",ev_sig "
") "
@@ -522,33 +522,33 @@ postgres_prepare (PGconn *db_conn)
PREPARE ("set_reveal_ok",
"UPDATE refresh_sessions "
"SET reveal_ok = TRUE "
- "WHERE session_pub = $1 ",
+ "WHERE session_hash = $1 ",
1, NULL);
PREPARE ("get_link",
"SELECT link_vector_enc, ro.denom_pub, ev_sig "
"FROM refresh_melt rm "
- " JOIN refresh_order ro USING (session_pub) "
- " JOIN refresh_commit_coin rcc USING (session_pub) "
- " JOIN refresh_sessions rs USING (session_pub) "
- " JOIN refresh_collectable rc USING (session_pub) "
+ " JOIN refresh_order ro USING (session_hash) "
+ " JOIN refresh_commit_coin rcc USING (session_hash) "
+ " JOIN refresh_sessions rs USING (session_hash) "
+ " JOIN refresh_collectable rc USING (session_hash) "
"WHERE rm.coin_pub = $1 "
"AND ro.newcoin_index = rcc.newcoin_index "
"AND ro.newcoin_index = rc.newcoin_index "
"AND rcc.cnc_index = rs.noreveal_index % ( "
" SELECT count(*) FROM refresh_commit_coin rcc2 "
- " WHERE rcc2.newcoin_index = 0 AND rcc2.session_pub = rs.session_pub "
+ " WHERE rcc2.newcoin_index = 0 AND rcc2.session_hash = rs.session_hash "
" ) ",
1, NULL);
PREPARE ("get_transfer",
"SELECT transfer_pub, link_secret_enc "
"FROM refresh_melt rm "
- " JOIN refresh_commit_link rcl USING (session_pub) "
- " JOIN refresh_sessions rs USING (session_pub) "
+ " JOIN refresh_commit_link rcl USING (session_hash) "
+ " JOIN refresh_sessions rs USING (session_hash) "
"WHERE rm.coin_pub = $1 "
"AND rm.oldcoin_index = rcl.oldcoin_index "
"AND rcl.cnc_index = rs.noreveal_index % ( "
" SELECT count(*) FROM refresh_commit_coin rcc2 "
- " WHERE newcoin_index = 0 AND rcc2.session_pub = rm.session_pub "
+ " WHERE newcoin_index = 0 AND rcc2.session_hash = rm.session_hash "
" ) ",
1, NULL);
PREPARE ("insert_deposit",
@@ -1434,11 +1434,11 @@ postgres_insert_deposit (void *cls,
/**
- * Lookup refresh session data under the given public key.
+ * Lookup refresh session data under the given @a session_hash.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database handle to use
- * @param refresh_session_pub public key to use for the lookup
+ * @param session_hash hash over the melt to use to locate the session
* @param refresh_session[OUT] where to store the result
* @return #GNUNET_YES on success,
* #GNUNET_NO if not found,
@@ -1447,13 +1447,13 @@ postgres_insert_deposit (void *cls,
static int
postgres_get_refresh_session (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
struct RefreshSession *refresh_session)
{
// FIXME: check logic!
int res;
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_END
};
@@ -1511,11 +1511,11 @@ postgres_get_refresh_session (void *cls,
/**
- * Store new refresh session data under the given public key.
+ * Store new refresh session data under the given @a session_hash.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database handle to use
- * @param refresh_session_pub public key to use to locate the session
+ * @param session_hash hash over the melt to use to locate the session
* @param refresh_session session data to store
* @return #GNUNET_YES on success,
* #GNUNET_SYSERR on DB failure
@@ -1523,13 +1523,13 @@ postgres_get_refresh_session (void *cls,
static int
postgres_create_refresh_session (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
const struct RefreshSession *refresh_session)
{
// FIXME: actually store session data!
uint16_t noreveal_index;
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR(&noreveal_index),
TALER_DB_QUERY_PARAM_END
};
@@ -1558,16 +1558,15 @@ postgres_create_refresh_session (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
- * @param refresh_session session key of the melt operation
* @param oldcoin_index index of the coin to store
- * @param melt melt operation
+ * @param melt melt operation details to store; includes
+ * the session hash of the melt
* @return #GNUNET_OK on success
* #GNUNET_SYSERR on internal error
*/
static int
postgres_insert_refresh_melt (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session,
uint16_t oldcoin_index,
const struct RefreshMelt *melt)
{
@@ -1581,7 +1580,7 @@ postgres_insert_refresh_melt (void *cls,
&buf);
{
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(refresh_session),
+ TALER_DB_QUERY_PARAM_PTR(&melt->session_hash),
TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo),
TALER_DB_QUERY_PARAM_PTR(&melt->coin.coin_pub),
TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size),
@@ -1617,7 +1616,7 @@ postgres_insert_refresh_melt (void *cls,
static int
postgres_get_refresh_melt (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session,
+ const struct GNUNET_HashCode *session_hash,
uint16_t oldcoin_index,
struct RefreshMelt *melt)
{
@@ -1633,7 +1632,7 @@ postgres_get_refresh_melt (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
- * @param session_pub refresh session key
+ * @param session_hash hash to identify refresh session
* @param num_newcoins number of coins to generate, size of the @a denom_pubs array
* @param denom_pubs array denominations of the coins to create
* @return #GNUNET_OK on success
@@ -1642,7 +1641,7 @@ postgres_get_refresh_melt (void *cls,
static int
postgres_insert_refresh_order (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
uint16_t num_newcoins,
const struct TALER_DenominationPublicKey *denom_pubs)
{
@@ -1658,7 +1657,7 @@ postgres_insert_refresh_order (void *cls,
{
struct TALER_DB_QueryParam params[] = {
TALER_DB_QUERY_PARAM_PTR (&newcoin_index_nbo),
- TALER_DB_QUERY_PARAM_PTR (session_pub),
+ TALER_DB_QUERY_PARAM_PTR (session_hash),
TALER_DB_QUERY_PARAM_PTR_SIZED (buf, buf_size),
TALER_DB_QUERY_PARAM_END
};
@@ -1689,7 +1688,7 @@ postgres_insert_refresh_order (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
- * @param session_pub refresh session key
+ * @param session_hash hash to identify refresh session
* @param newcoin_index array of the @a denom_pubs array
* @param denom_pubs where to store the deomination keys
* @return #GNUNET_OK on success
@@ -1698,7 +1697,7 @@ postgres_insert_refresh_order (void *cls,
static int
postgres_get_refresh_order (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
uint16_t num_newcoins,
struct TALER_DenominationPublicKey *denom_pubs)
{
@@ -1708,7 +1707,7 @@ postgres_get_refresh_order (void *cls,
uint16_t newcoin_index_nbo = htons (num_newcoins);
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
TALER_DB_QUERY_PARAM_END
};
@@ -1756,7 +1755,7 @@ postgres_get_refresh_order (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection to use
- * @param refresh_session_pub refresh session this commitment belongs to
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension)
* @param num_newcoins coin index size of the @a commit_coins array
* @param commit_coins array of coin commitments to store
@@ -1766,7 +1765,7 @@ postgres_get_refresh_order (void *cls,
static int
postgres_insert_refresh_commit_coins (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int num_newcoins,
const struct RefreshCommitCoin *commit_coins)
@@ -1775,7 +1774,7 @@ postgres_insert_refresh_commit_coins (void *cls,
uint16_t cnc_index_nbo = htons (i);
uint16_t newcoin_index_nbo = htons (num_newcoins);
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size),
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
@@ -1813,7 +1812,7 @@ postgres_insert_refresh_commit_coins (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection to use
- * @param refresh_session_pub refresh session the commitment belongs to
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension)
* @param j coin index (2nd dimension), corresponds to refreshed (new) coins
* @param commit_coin[OUT] coin commitment to return
@@ -1824,7 +1823,7 @@ postgres_insert_refresh_commit_coins (void *cls,
static int
postgres_get_refresh_commit_coins (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int cnc_index,
unsigned int newcoin_index,
struct RefreshCommitCoin *cc)
@@ -1833,7 +1832,7 @@ postgres_get_refresh_commit_coins (void *cls,
uint16_t cnc_index_nbo = htons (cnc_index);
uint16_t newcoin_index_nbo = htons (newcoin_index);
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
TALER_DB_QUERY_PARAM_END
@@ -1894,8 +1893,7 @@ postgres_get_refresh_commit_coins (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection to use
- * @param refresh_session_pub public key of the refresh session this
- * commitment belongs with -- FIXME: should not be needed!
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension)
* @param j coin index (2nd dimension), corresponds to melted (old) coins
* @param commit_link link information to store
@@ -1904,7 +1902,7 @@ postgres_get_refresh_commit_coins (void *cls,
static int
postgres_insert_refresh_commit_links (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int j,
const struct RefreshCommitLink *commit_link)
@@ -1913,7 +1911,7 @@ postgres_insert_refresh_commit_links (void *cls,
uint16_t cnc_index_nbo = htons (i);
uint16_t oldcoin_index_nbo = htons (j);
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR(&commit_link->transfer_pub),
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo),
@@ -1948,8 +1946,7 @@ postgres_insert_refresh_commit_links (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection to use
- * @param refresh_session_pub public key of the refresh session this
- * commitment belongs with -- FIXME: should not be needed!
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension)
* @param num_links size of the @a commit_link array
* @param links[OUT] array of link information to return
@@ -1960,7 +1957,7 @@ postgres_insert_refresh_commit_links (void *cls,
static int
postgres_get_refresh_commit_links (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int num_links,
struct RefreshCommitLink *links)
@@ -1970,7 +1967,7 @@ postgres_get_refresh_commit_links (void *cls,
uint16_t oldcoin_index_nbo = htons (num_links);
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo),
TALER_DB_QUERY_PARAM_END
@@ -2017,7 +2014,7 @@ postgres_get_refresh_commit_links (void *cls,
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
- * @param session_pub refresh session
+ * @param session_hash hash to identify refresh session
* @param newcoin_index coin index
* @param ev_sig coin signature
* @return #GNUNET_OK on success
@@ -2025,7 +2022,7 @@ postgres_get_refresh_commit_links (void *cls,
static int
postgres_insert_refresh_collectable (void *cls,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
uint16_t newcoin_index,
const struct TALER_DenominationSignature *ev_sig)
{
@@ -2039,7 +2036,7 @@ postgres_insert_refresh_collectable (void *cls,
&buf);
{
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(session_pub),
+ TALER_DB_QUERY_PARAM_PTR(session_hash),
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size),
TALER_DB_QUERY_PARAM_END
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c
index 30585730b..7592403da 100644
--- a/src/mint/taler-mint-httpd_db.c
+++ b/src/mint/taler-mint-httpd_db.c
@@ -481,7 +481,7 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
* @param connection the connection to send errors to
* @param session the database connection
* @param key_state the mint's key state
- * @param session_pub the refresh session's public key
+ * @param session_hash hash identifying the refresh session
* @param coin_public_info the coin to melt
* @param coin_details details about the coin being melted
* @param oldcoin_index what is the number assigned to this coin
@@ -493,7 +493,7 @@ static int
refresh_accept_melts (struct MHD_Connection *connection,
struct TALER_MINTDB_Session *session,
const struct MintKeyState *key_state,
- const struct GNUNET_HashCode *melt_hash,
+ const struct GNUNET_HashCode *session_hash,
const struct TALER_SessionPublicKey *session_pub,
const struct TALER_CoinPublicInfo *coin_public_info,
const struct MeltDetails *coin_details,
@@ -563,12 +563,11 @@ refresh_accept_melts (struct MHD_Connection *connection,
melt.coin = *coin_public_info;
melt.coin_sig = coin_details->melt_sig;
- melt.melt_hash = *melt_hash;
+ melt.session_hash = *session_hash;
melt.amount_with_fee = coin_details->melt_amount_with_fee;
if (GNUNET_OK !=
plugin->insert_refresh_melt (plugin->cls,
session,
- session_pub,
oldcoin_index,
&melt))
{
@@ -587,7 +586,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
* melted and confirm the melting operation to the client.
*
* @param connection the MHD connection to handle
- * @param melt_hash hash code of the session the coins are melted into
+ * @param session_hash hash code of the session the coins are melted into
* @param refresh_session_pub public key of the refresh session
* @param client_signature signature of the client (matching @a refresh_session_pub)
* over the melting request
@@ -606,7 +605,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
*/
int
TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
- const struct GNUNET_HashCode *melt_hash,
+ const struct GNUNET_HashCode *session_hash,
const struct TALER_SessionPublicKey *refresh_session_pub,
const struct TALER_SessionSignature *client_signature,
unsigned int num_new_denoms,
@@ -639,14 +638,14 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
}
res = plugin->get_refresh_session (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
&refresh_session);
if (GNUNET_YES == res)
{
plugin->rollback (plugin->cls,
session);
res = TALER_MINT_reply_refresh_melt_success (connection,
- &refresh_session.session_hash,
+ session_hash,
refresh_session.noreveal_index);
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
@@ -665,7 +664,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
(res = refresh_accept_melts (connection,
session,
key_state,
- melt_hash,
+ session_hash,
refresh_session_pub,
&coin_public_infos[i],
&coin_melt_details[i],
@@ -683,7 +682,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->insert_refresh_order (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
num_new_denoms,
denom_pubs))
{
@@ -697,7 +696,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->insert_refresh_commit_coins (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
i,
num_new_denoms,
commit_coin[i]))
@@ -712,7 +711,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->insert_refresh_commit_links (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
i,
coin_count,
commit_link[i]))
@@ -726,7 +725,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
/* store 'global' session data */
refresh_session.melt_sig = *client_signature;
- refresh_session.session_hash = *melt_hash;
+ refresh_session.refresh_session_pub = *refresh_session_pub;
refresh_session.num_oldcoins = coin_count;
refresh_session.num_newcoins = num_new_denoms;
refresh_session.kappa = KAPPA; // FIXME... (#3711)
@@ -736,7 +735,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
if (GNUNET_OK !=
(res = plugin->create_refresh_session (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
&refresh_session)))
{
plugin->rollback (plugin->cls,
@@ -754,7 +753,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
return TALER_MINT_reply_commit_error (connection);
}
return TALER_MINT_reply_refresh_melt_success (connection,
- &refresh_session.session_hash,
+ session_hash,
refresh_session.noreveal_index);
}
@@ -767,7 +766,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
*
* @param connection the MHD connection to handle
* @param session database connection to use
- * @param refresh_session session to query
+ * @param session_hash hash of session to query
* @param off commitment offset to check
* @param num_oldcoins size of the @a transfer_privs and @a melts arrays
* @param transfer_privs private transfer keys
@@ -781,7 +780,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
static int
check_commitment (struct MHD_Connection *connection,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session,
+ const struct GNUNET_HashCode *session_hash,
unsigned int off,
unsigned int num_oldcoins,
const struct TALER_TransferPrivateKey *transfer_privs,
@@ -802,7 +801,7 @@ check_commitment (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->get_refresh_commit_links (plugin->cls,
session,
- refresh_session,
+ session_hash,
off,
num_oldcoins,
commit_links))
@@ -901,7 +900,7 @@ check_commitment (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->get_refresh_commit_coins (plugin->cls,
session,
- refresh_session,
+ session_hash,
off,
num_newcoins,
commit_coins))
@@ -982,7 +981,7 @@ check_commitment (struct MHD_Connection *connection,
*
* @param connection the MHD connection to handle
* @param session database connection to use
- * @param refresh_session session to query
+ * @param session_hash hash of session to query
* @param key_state key state to lookup denomination pubs
* @param denom_pub denomination key for the coin to create
* @param commit_coin the coin that was committed
@@ -992,7 +991,7 @@ check_commitment (struct MHD_Connection *connection,
static struct TALER_DenominationSignature
refresh_mint_coin (struct MHD_Connection *connection,
struct TALER_MINTDB_Session *session,
- const struct TALER_SessionPublicKey *refresh_session,
+ const struct GNUNET_HashCode *session_hash,
struct MintKeyState *key_state,
const struct TALER_DenominationPublicKey *denom_pub,
const struct RefreshCommitCoin *commit_coin,
@@ -1021,7 +1020,7 @@ refresh_mint_coin (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->insert_refresh_collectable (plugin->cls,
session,
- refresh_session,
+ session_hash,
coin_off,
&ev_sig))
{
@@ -1041,7 +1040,7 @@ refresh_mint_coin (struct MHD_Connection *connection,
* coins that was not chosen.
*
* @param connection the MHD connection to handle
- * @param refresh_session_pub public key of the refresh session
+ * @param session_hash hash identifying the refresh session
* @param kappa size of x-dimension of @transfer_privs array plus one (!)
* @param num_oldcoins size of y-dimension of @transfer_privs array
* @param transfer_pubs array with the revealed transfer keys
@@ -1049,7 +1048,7 @@ refresh_mint_coin (struct MHD_Connection *connection,
*/
int
TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int kappa,
unsigned int num_oldcoins,
struct TALER_TransferPrivateKey **transfer_privs)
@@ -1075,11 +1074,11 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
res = plugin->get_refresh_session (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
&refresh_session);
if (GNUNET_NO == res)
return TALER_MINT_reply_arg_invalid (connection,
- "session_pub");
+ "session_hash");
if (GNUNET_SYSERR == res)
return TALER_MINT_reply_internal_db_error (connection);
if (0 == refresh_session.num_oldcoins)
@@ -1095,7 +1094,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->get_refresh_melt (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
j,
&melts[j]))
{
@@ -1109,7 +1108,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->get_refresh_order (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
refresh_session.num_newcoins,
denom_pubs))
{
@@ -1129,7 +1128,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
if (GNUNET_OK !=
(res = check_commitment (connection,
session,
- refresh_session_pub,
+ session_hash,
i + off,
refresh_session.num_oldcoins,
transfer_privs[i + off],
@@ -1163,7 +1162,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
if (GNUNET_OK !=
plugin->get_refresh_commit_coins (plugin->cls,
session,
- refresh_session_pub,
+ session_hash,
refresh_session.noreveal_index,
refresh_session.num_newcoins,
commit_coins))
@@ -1182,7 +1181,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
{
ev_sigs[j] = refresh_mint_coin (connection,
session,
- refresh_session_pub,
+ session_hash,
key_state,
&denom_pubs[j],
&commit_coins[j],
diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h
index fd420bd9b..edf8248c7 100644
--- a/src/mint/taler-mint-httpd_db.h
+++ b/src/mint/taler-mint-httpd_db.h
@@ -106,11 +106,8 @@ struct MeltDetails
* required value left and if so, store that they have been
* melted and confirm the melting operation to the client.
*
- * FIXME: some arguments are redundant here...
- *
* @param connection the MHD connection to handle
- * @param melt_hash hash code of the session the coins are melted into
- * @param refresh_session_pub public key of the refresh session
+ * @param session_hash hash code of the session the coins are melted into
* @param client_signature signature of the client (matching @a refresh_session_pub)
* over the melting request
* @param num_new_denoms number of entries in @a denom_pubs, size of y-dimension of @commit_coin array
@@ -128,7 +125,7 @@ struct MeltDetails
*/
int
TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
- const struct GNUNET_HashCode *melt_hash,
+ const struct GNUNET_HashCode *session_hash,
const struct TALER_SessionPublicKey *refresh_session_pub,
const struct TALER_SessionSignature *client_signature,
unsigned int num_new_denoms,
@@ -149,7 +146,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
* coins that was not chosen.
*
* @param connection the MHD connection to handle
- * @param refresh_session_pub public key of the refresh session
+ * @param session_hash hash over the refresh session
* @param kappa size of x-dimension of @transfer_privs array plus one (!)
* @param num_oldcoins size of y-dimension of @transfer_privs array
* @param transfer_pubs array with the revealed transfer keys
@@ -157,7 +154,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
*/
int
TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int kappa,
unsigned int num_oldcoins,
struct TALER_TransferPrivateKey **transfer_privs);
diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c
index bf8121037..7ecf8bfe6 100644
--- a/src/mint/taler-mint-httpd_deposit.c
+++ b/src/mint/taler-mint-httpd_deposit.c
@@ -131,7 +131,7 @@ static int
parse_and_handle_deposit_request (struct MHD_Connection *connection,
const json_t *root,
const struct TALER_Amount *amount,
- const json_t *wire)
+ json_t *wire)
{
int res;
struct Deposit deposit;
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c
index e72a77950..775ffd4ce 100644
--- a/src/mint/taler-mint-httpd_refresh.c
+++ b/src/mint/taler-mint-httpd_refresh.c
@@ -72,11 +72,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
{
unsigned int i;
- struct GNUNET_HashContext *hash_context;
- struct GNUNET_HashCode melt_hash;
struct RefreshMeltSessionSignature body;
- char *buf;
- size_t buf_size;
struct MintKeyState *key_state;
struct TALER_MINT_DenomKeyIssue *dki;
struct TALER_Amount cost;
@@ -88,28 +84,9 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
struct TALER_Amount total_melt;
/* check that signature from the session public key is ok */
- hash_context = GNUNET_CRYPTO_hash_context_start ();
- /* FIXME: also hash session public key here!? #3708 */
- for (i = 0; i < num_new_denoms; i++)
- {
- buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs[i].rsa_public_key,
- &buf);
- GNUNET_CRYPTO_hash_context_read (hash_context,
- buf,
- buf_size);
- GNUNET_free (buf);
- }
- for (i = 0; i < coin_count; i++)
- GNUNET_CRYPTO_hash_context_read (hash_context,
- &coin_public_infos[i].coin_pub,
- sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
- GNUNET_CRYPTO_hash_context_finish (hash_context,
- &melt_hash);
- /* FIXME: what about the `commit_hash`? #3708 */
-
body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_SESSION);
body.purpose.size = htonl (sizeof (struct RefreshMeltSessionSignature));
- body.melt_hash = melt_hash;
+ body.melt_hash = *commit_hash;
TALER_amount_hton (&body.amount_with_fee,
&coin_melt_details->melt_amount_with_fee);
@@ -197,7 +174,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
"error", "value mismatch");
}
return TALER_MINT_db_execute_refresh_melt (connection,
- &melt_hash,
+ commit_hash,
refresh_session_pub,
commit_client_sig,
num_new_denoms,
@@ -278,7 +255,7 @@ get_coin_public_info (struct MHD_Connection *connection,
* be done before the transaction starts.
*
* @param connection the connection to send error responses to
- * @param melt_hash hash over refresh session the coin is melted into
+ * @param session_hash hash over refresh session the coin is melted into
* @param r_public_info the coin's public information
* @param r_melt_detail details about the coin's melting permission (if valid)
* @return #GNUNET_YES if coin public info in JSON was valid
@@ -287,7 +264,7 @@ get_coin_public_info (struct MHD_Connection *connection,
*/
static int
verify_coin_public_info (struct MHD_Connection *connection,
- const struct GNUNET_HashCode *melt_hash,
+ const struct GNUNET_HashCode *session_hash,
const struct TALER_CoinPublicInfo *r_public_info,
const struct MeltDetails *r_melt_detail)
{
@@ -298,7 +275,7 @@ verify_coin_public_info (struct MHD_Connection *connection,
body.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature));
body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN);
- body.melt_hash = *melt_hash;
+ body.session_hash = *session_hash;
TALER_amount_hton (&body.amount_with_fee,
&r_melt_detail->melt_amount_with_fee);
body.coin_pub = r_public_info->coin_pub;
@@ -449,11 +426,21 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
struct RefreshCommitLink *commit_link[kappa];
const struct TALER_SessionSignature commit_client_sig;
+ /* For the signature check, we hash most of the inputs together
+ (except for the signatures on the coins). */
+ hash_context = GNUNET_CRYPTO_hash_context_start ();
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ refresh_session_pub,
+ sizeof (struct TALER_SessionPublicKey));
+
num_new_denoms = json_array_size (new_denoms);
denom_pubs = GNUNET_malloc (num_new_denoms *
sizeof (struct TALER_DenominationPublicKey));
for (i=0;i<num_new_denoms;i++)
{
+ char *buf;
+ size_t buf_size;
+
res = GNUNET_MINT_parse_navigate_json (connection,
new_denoms,
JNAV_INDEX, (int) i,
@@ -466,7 +453,13 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
GNUNET_free (denom_pubs);
return res;
}
- }
+ buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs[i].rsa_public_key,
+ &buf);
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ buf,
+ buf_size);
+ GNUNET_free (buf);
+ }
coin_count = json_array_size (melt_coins);
/* FIXME: make 'struct TALER_CoinPublicInfo' part of `struct MeltDetails`
@@ -478,6 +471,8 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
for (i=0;i<coin_count;i++)
{
/* decode JSON data on coin to melt */
+ struct TALER_AmountNBO melt_amount;
+
res = get_coin_public_info (connection,
json_array_get (melt_coins, i),
&coin_public_infos[i],
@@ -518,14 +513,21 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
"melting same coin twice in same session is not allowed");
}
}
- }
+ TALER_amount_hton (&melt_amount,
+ &coin_melt_details[i].melt_amount_with_fee);
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ &coin_public_infos[i].coin_pub,
+ sizeof (struct TALER_CoinSpendPublicKey));
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ &melt_amount,
+ sizeof (struct TALER_AmountNBO));
+ }
/* parse JSON arrays into 2d binary arrays and hash everything
together for the signature check */
memset (commit_coin, 0, sizeof (commit_coin));
memset (commit_link, 0, sizeof (commit_link));
- hash_context = GNUNET_CRYPTO_hash_context_start ();
for (i = 0; i < kappa; i++)
{
commit_coin[i] = GNUNET_malloc (num_newcoins *
@@ -534,14 +536,15 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
{
char *link_enc;
size_t link_enc_size;
+ struct RefreshCommitCoin *rcc = &commit_coin[i][j];
res = GNUNET_MINT_parse_navigate_json (connection,
coin_evs,
JNAV_INDEX, (int) i,
JNAV_INDEX, (int) j,
JNAV_RET_DATA_VAR,
- &commit_coin[i][j].coin_ev,
- &commit_coin[i][j].coin_ev_size);
+ &rcc->coin_ev,
+ &rcc->coin_ev_size);
if (GNUNET_OK != res)
{
@@ -550,8 +553,8 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
GNUNET_CRYPTO_hash_context_read (hash_context,
- commit_coin[i][j].coin_ev,
- commit_coin[i][j].coin_ev_size);
+ rcc->coin_ev,
+ rcc->coin_ev_size);
res = GNUNET_MINT_parse_navigate_json (connection,
link_encs,
JNAV_INDEX, (int) i,
@@ -565,9 +568,9 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
free_commit_coins (commit_coin, kappa, num_newcoins);
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
- commit_coin[i][j].refresh_link = TALER_refresh_link_encrypted_decode (link_enc,
- link_enc_size);
-
+ rcc->refresh_link
+ = TALER_refresh_link_encrypted_decode (link_enc,
+ link_enc_size);
GNUNET_CRYPTO_hash_context_read (hash_context,
link_enc,
link_enc_size);
@@ -580,12 +583,14 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
sizeof (struct RefreshCommitLink));
for (j = 0; j < num_oldcoins; j++)
{
+ struct RefreshCommitLink *rcl = &commit_link[i][j];
+
res = GNUNET_MINT_parse_navigate_json (connection,
transfer_pubs,
JNAV_INDEX, (int) i,
JNAV_INDEX, (int) j,
JNAV_RET_DATA,
- &commit_link[i][j].transfer_pub,
+ &rcl->transfer_pub,
sizeof (struct TALER_TransferPublicKey));
if (GNUNET_OK != res)
@@ -596,17 +601,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
free_commit_links (commit_link, kappa, num_oldcoins);
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
-
- GNUNET_CRYPTO_hash_context_read (hash_context,
- &commit_link[i][j].transfer_pub,
- sizeof (struct TALER_TransferPublicKey));
-
res = GNUNET_MINT_parse_navigate_json (connection,
secret_encs,
JNAV_INDEX, (int) i,
JNAV_INDEX, (int) j,
JNAV_RET_DATA,
- &commit_link[i][j].shared_secret_enc,
+ &rcl->shared_secret_enc,
sizeof (struct GNUNET_HashCode));
if (GNUNET_OK != res)
@@ -619,12 +619,13 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
}
GNUNET_CRYPTO_hash_context_read (hash_context,
- &commit_link[i][j].shared_secret_enc,
- sizeof (struct GNUNET_HashCode));
+ rcl,
+ sizeof (struct RefreshCommitLink));
}
- }
- GNUNET_CRYPTO_hash_context_finish (hash_context, &commit_hash);
+ }
+ GNUNET_CRYPTO_hash_context_finish (hash_context,
+ &commit_hash);
res = GNUNET_MINT_parse_navigate_json (connection,
commit_signature,
@@ -640,7 +641,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
for (i=0;i<coin_count;i++)
{
- /* verify signatures ons coin to melt */
+ /* verify signatures on coins to melt */
res = verify_coin_public_info (connection,
&commit_hash,
&coin_public_infos[i],
@@ -812,7 +813,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
* coins.
*
* @param connection the MHD connection to handle
- * @param refresh_session_pub public key of the session
+ * @param session_hash hash identifying the melting session
* @param kappa length of the 1st dimension of @a transfer_privs array PLUS ONE
* @param num_oldcoins length of the 2nd dimension of @a transfer_privs array
* @param tp_json private transfer keys in JSON format
@@ -820,7 +821,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
*/
static int
handle_refresh_reveal_json (struct MHD_Connection *connection,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int kappa,
unsigned int num_oldcoins,
const json_t *tp_json)
@@ -855,7 +856,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
else
res = TALER_MINT_db_execute_refresh_reveal (connection,
- refresh_session_pub,
+ session_hash,
kappa,
num_oldcoins,
transfer_privs);
@@ -888,7 +889,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
const char *upload_data,
size_t *upload_data_size)
{
- struct TALER_SessionPublicKey refresh_session_pub;
+ struct GNUNET_HashCode session_hash;
int res;
unsigned int kappa;
unsigned int num_oldcoins;
@@ -896,7 +897,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
json_t *root;
json_t *transfer_privs;
struct GNUNET_MINT_ParseFieldSpec spec[] = {
- TALER_MINT_PARSE_FIXED ("session_pub", &refresh_session_pub),
+ TALER_MINT_PARSE_FIXED ("session_hash", &session_hash),
TALER_MINT_PARSE_ARRAY ("transfer_privs", &transfer_privs),
TALER_MINT_PARSE_END
};
@@ -941,7 +942,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
}
num_oldcoins = json_array_size (reveal_detail);
res = handle_refresh_reveal_json (connection,
- &refresh_session_pub,
+ &session_hash,
kappa,
num_oldcoins,
transfer_privs);
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c
index 4f124a15c..00b002842 100644
--- a/src/mint/taler-mint-httpd_responses.c
+++ b/src/mint/taler-mint-httpd_responses.c
@@ -364,7 +364,7 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl)
value = melt->amount_with_fee;
ms.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN);
ms.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature));
- ms.melt_hash = melt->melt_hash;
+ ms.session_hash = melt->session_hash;
TALER_amount_hton (&ms.amount_with_fee,
&melt->amount_with_fee);
ms.coin_pub = melt->coin.coin_pub;
diff --git a/src/mint/taler_mintdb_plugin.h b/src/mint/taler_mintdb_plugin.h
index 078238515..326737e61 100644
--- a/src/mint/taler_mintdb_plugin.h
+++ b/src/mint/taler_mintdb_plugin.h
@@ -236,18 +236,15 @@ struct Deposit
struct RefreshSession
{
/**
- * Signature over the commitments by the client,
- * only valid if @e has_commit_sig is set.
- *
- * FIXME: The above comment is clearly confused.
+ * Signature over the commitments by the client.
*/
struct TALER_SessionSignature commit_sig;
/**
- * Hash over coins to melt and coins to create of the
- * refresh session.
+ * Public key the client uses to sign messages in
+ * this exchange.
*/
- struct GNUNET_HashCode session_hash;
+ struct TALER_SessionPublicKey refresh_session_pub;
/**
* Signature over the melt by the client.
@@ -296,9 +293,9 @@ struct RefreshMelt
struct TALER_CoinSpendSignature coin_sig;
/**
- * Which melting operation should the coin become a part of.
+ * Hash of the refresh session this coin is melted into.
*/
- struct GNUNET_HashCode melt_hash;
+ struct GNUNET_HashCode session_hash;
/**
* How much value is being melted? This amount includes the fees,
@@ -341,6 +338,8 @@ struct RefreshCommitCoin
};
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* For each (old) coin being melted, we have a `struct
* RefreshCommitLink` that allows the user to find the shared secret
@@ -350,7 +349,9 @@ struct RefreshCommitCoin
struct RefreshCommitLink
{
/**
- * Transfer public key (FIXME: explain!)
+ * Transfer public key, used to decrypt the @e shared_secret_enc
+ * in combintation with the corresponding private key of the
+ * coin.
*/
struct TALER_TransferPublicKey transfer_pub;
@@ -360,6 +361,9 @@ struct RefreshCommitLink
struct TALER_EncryptedLinkSecret shared_secret_enc;
};
+GNUNET_NETWORK_STRUCT_END
+
+
/**
* Linked list of refresh information linked to a coin.
@@ -709,11 +713,11 @@ struct TALER_MINTDB_Plugin
/**
- * Lookup refresh session data under the given public key.
+ * Lookup refresh session data under the given @a session_hash.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database handle to use
- * @param refresh_session_pub public key to use for the lookup
+ * @param session_hash hash over the melt to use for the lookup
* @param refresh_session[OUT] where to store the result
* @return #GNUNET_YES on success,
* #GNUNET_NO if not found,
@@ -722,16 +726,16 @@ struct TALER_MINTDB_Plugin
int
(*get_refresh_session) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
struct RefreshSession *refresh_session);
/**
- * Store new refresh session data under the given public key.
+ * Store new refresh session data under the given @a session_hash.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database handle to use
- * @param refresh_session_pub public key to use to locate the session
+ * @param session_hash hash over the melt to use to locate the session
* @param refresh_session session data to store
* @return #GNUNET_YES on success,
* #GNUNET_SYSERR on DB failure
@@ -739,26 +743,24 @@ struct TALER_MINTDB_Plugin
int
(*create_refresh_session) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
const struct RefreshSession *refresh_session);
-
/**
* Store the given /refresh/melt request in the database.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection
- * @param refresh_session session key of the melt operation
* @param oldcoin_index index of the coin to store
- * @param melt coin melt operation details to store
+ * @param melt coin melt operation details to store; includes
+ * the session hash of the melt
* @return #GNUNET_OK on success
* #GNUNET_SYSERR on internal error
*/
int
(*insert_refresh_melt) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session,
uint16_t oldcoin_index,
const struct RefreshMelt *melt);
@@ -768,7 +770,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection
- * @param refresh_session session key of the melt operation
+ * @param session_hash hash to identify refresh session
* @param oldcoin_index index of the coin to retrieve
* @param melt melt data to fill in
* @return #GNUNET_OK on success
@@ -777,7 +779,7 @@ struct TALER_MINTDB_Plugin
int
(*get_refresh_melt) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session,
+ const struct GNUNET_HashCode *session_hash,
uint16_t oldcoin_index,
struct RefreshMelt *melt);
@@ -788,7 +790,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection
- * @param session_pub refresh session key
+ * @param session_hash hash to identify refresh session
* @param num_newcoins number of coins to generate, size of the @a denom_pubs array
* @param denom_pubs array denominations of the coins to create
* @return #GNUNET_OK on success
@@ -797,7 +799,7 @@ struct TALER_MINTDB_Plugin
int
(*insert_refresh_order) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
uint16_t num_newcoins,
const struct TALER_DenominationPublicKey *denom_pubs);
@@ -808,7 +810,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection
- * @param session_pub refresh session key
+ * @param session_hash hash to identify refresh session
* @param num_newcoins size of the @a denom_pubs array
* @param denom_pubs[OUT] where to write @a num_newcoins denomination keys
* @return #GNUNET_OK on success
@@ -817,7 +819,7 @@ struct TALER_MINTDB_Plugin
int
(*get_refresh_order) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
uint16_t num_newcoins,
struct TALER_DenominationPublicKey *denom_pubs);
@@ -828,7 +830,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection to use
- * @param refresh_session_pub refresh session this commitment belongs to
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension), relating to kappa
* @param num_newcoins coin index size of the @a commit_coins array
* @param commit_coin array of coin commitments to store
@@ -838,7 +840,7 @@ struct TALER_MINTDB_Plugin
int
(*insert_refresh_commit_coins) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int num_newcoins,
const struct RefreshCommitCoin *commit_coins);
@@ -850,7 +852,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection to use
- * @param refresh_session_pub refresh session the commitment belongs to
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension)
* @param num_coins size of the @a commit_coins array
* @param commit_coin[OUT] array of coin commitments to return
@@ -861,7 +863,7 @@ struct TALER_MINTDB_Plugin
int
(*get_refresh_commit_coins) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int num_coins,
struct RefreshCommitCoin *commit_coins);
@@ -873,8 +875,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection to use
- * @param refresh_session_pub public key of the refresh session this
- * commitment belongs with
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension), relating to kappa
* @param num_links size of the @a commit_link array
* @param commit_links array of link information to store
@@ -883,7 +884,7 @@ struct TALER_MINTDB_Plugin
int
(*insert_refresh_commit_links) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int num_links,
const struct RefreshCommitLink *commit_links);
@@ -894,8 +895,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection to use
- * @param refresh_session_pub public key of the refresh session this
- * commitment belongs with
+ * @param session_hash hash to identify refresh session
* @param i set index (1st dimension)
* @param num_links size of the @links array to return
* @param links[OUT] array link information to return
@@ -906,7 +906,7 @@ struct TALER_MINTDB_Plugin
int
(*get_refresh_commit_links) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *refresh_session_pub,
+ const struct GNUNET_HashCode *session_hash,
unsigned int i,
unsigned int num_links,
struct RefreshCommitLink *links);
@@ -920,7 +920,7 @@ struct TALER_MINTDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion database connection
- * @param session_pub refresh session
+ * @param session_hash hash to identify refresh session
* @param newcoin_index coin index
* @param ev_sig coin signature
* @return #GNUNET_OK on success
@@ -928,7 +928,7 @@ struct TALER_MINTDB_Plugin
int
(*insert_refresh_collectable) (void *cls,
struct TALER_MINTDB_Session *sesssion,
- const struct TALER_SessionPublicKey *session_pub,
+ const struct GNUNET_HashCode *session_hash,
uint16_t newcoin_index,
const struct TALER_DenominationSignature *ev_sig);