implementing varsize link data
This commit is contained in:
parent
16817ef0d1
commit
c3731d0df7
@ -115,43 +115,89 @@ struct CollectableBlindcoin
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Global information for a refreshing session.
|
||||
*/
|
||||
struct RefreshSession
|
||||
{
|
||||
/**
|
||||
* Signature over the commitments by the client.
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EddsaSignature commit_sig;
|
||||
|
||||
/**
|
||||
* Public key of the refreshing session, used to sign
|
||||
* the client's commit message.
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EddsaPublicKey session_pub;
|
||||
int has_commit_sig;
|
||||
|
||||
/**
|
||||
* Number of coins we are melting.
|
||||
*/
|
||||
uint16_t num_oldcoins;
|
||||
|
||||
/**
|
||||
* Number of new coins we are creating.
|
||||
*/
|
||||
uint16_t num_newcoins;
|
||||
|
||||
/**
|
||||
* Number of parallel operations we perform for the cut and choose.
|
||||
* (must be greater or equal to three for security).
|
||||
*/
|
||||
uint16_t kappa;
|
||||
|
||||
/**
|
||||
* Index (smaller @e kappa) which the mint has chosen to not
|
||||
* have revealed during cut and choose.
|
||||
*/
|
||||
uint16_t noreveal_index;
|
||||
|
||||
/**
|
||||
* FIXME.
|
||||
*/
|
||||
int has_commit_sig;
|
||||
|
||||
/**
|
||||
* FIXME.
|
||||
*/
|
||||
uint8_t reveal_ok;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* FIXME
|
||||
* For each (old) coin being melted, we have a `struct
|
||||
* RefreshCommitLink` that allows the user to find the shared secret
|
||||
* to decrypt the respective refresh links for the new coins in the
|
||||
* `struct RefreshCommitCoin`.
|
||||
*/
|
||||
struct RefreshCommitLink
|
||||
{
|
||||
struct GNUNET_CRYPTO_EddsaPublicKey session_pub;
|
||||
/**
|
||||
* Transfer public key (FIXME: explain!)
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub;
|
||||
|
||||
/**
|
||||
* FIXME: this can't be exactly the shared secret, must
|
||||
* be a commitment to it or something.
|
||||
*/
|
||||
struct GNUNET_HashCode shared_secret;
|
||||
uint16_t cnc_index;
|
||||
uint16_t oldcoin_index;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* FIXME
|
||||
* We have as many `struct RefreshCommitCoin` as there are new
|
||||
* coins being created by the refresh.
|
||||
*/
|
||||
struct RefreshCommitCoin
|
||||
{
|
||||
/**
|
||||
* Refresh session's public key.
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EddsaPublicKey session_pub;
|
||||
|
||||
struct TALER_RefreshLinkEncrypted refresh_link;
|
||||
/**
|
||||
* Encrypted data allowing those able to decrypt it to derive
|
||||
* the private keys of the new coins created by the refresh.
|
||||
*/
|
||||
struct TALER_RefreshLinkEncrypted *refresh_link;
|
||||
|
||||
/**
|
||||
* Blinded message to be signed (in envelope), with @e coin_env_size bytes.
|
||||
@ -163,16 +209,6 @@ struct RefreshCommitCoin
|
||||
*/
|
||||
size_t coin_ev_size;
|
||||
|
||||
/**
|
||||
* FIXME: needed?
|
||||
*/
|
||||
uint16_t cnc_index;
|
||||
|
||||
/**
|
||||
* FIXME: needed?
|
||||
*/
|
||||
uint16_t newcoin_index;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -1131,7 +1131,8 @@ TALER_MINT_DB_insert_known_coin (PGconn *db_conn,
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_upsert_known_coin (PGconn *db_conn, struct KnownCoin *known_coin)
|
||||
TALER_MINT_DB_upsert_known_coin (PGconn *db_conn,
|
||||
struct KnownCoin *known_coin)
|
||||
{
|
||||
int ret;
|
||||
ret = TALER_MINT_DB_update_known_coin (db_conn, known_coin);
|
||||
@ -1146,58 +1147,38 @@ TALER_MINT_DB_upsert_known_coin (PGconn *db_conn, struct KnownCoin *known_coin)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store the commitment to the given (encrypted) refresh link data
|
||||
* for the given refresh session.
|
||||
*
|
||||
* @param db_conn database connection to use
|
||||
* @param refresh_session_pub public key of the refresh session this
|
||||
* commitment belongs with
|
||||
* @param i
|
||||
* @param j
|
||||
* @param commit_link link information to store
|
||||
* @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success
|
||||
*/
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_commit_link (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
|
||||
int i, int j,
|
||||
const struct RefreshCommitLink *commit_link)
|
||||
{
|
||||
uint16_t cnc_index_nbo = htons (commit_link->cnc_index);
|
||||
uint16_t oldcoin_index_nbo = htons (commit_link->oldcoin_index);
|
||||
uint16_t cnc_index_nbo = htons (i);
|
||||
uint16_t oldcoin_index_nbo = htons (j);
|
||||
struct TALER_DB_QueryParam params[] = {
|
||||
TALER_DB_QUERY_PARAM_PTR(&commit_link->session_pub),
|
||||
TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
|
||||
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),
|
||||
TALER_DB_QUERY_PARAM_PTR_SIZED(&commit_link->shared_secret_enc, sizeof (struct GNUNET_HashCode)),
|
||||
TALER_DB_QUERY_PARAM_PTR(&commit_link->shared_secret),
|
||||
TALER_DB_QUERY_PARAM_END
|
||||
};
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_refresh_commit_link", params);
|
||||
|
||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||
{
|
||||
break_db_err (result);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
if (0 != strcmp ("1", PQcmdTuples (result)))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
PQclear (result);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_commit_coin (PGconn *db_conn,
|
||||
const struct RefreshCommitCoin *commit_coin)
|
||||
{
|
||||
uint16_t cnc_index_nbo = htons (commit_coin->cnc_index);
|
||||
uint16_t newcoin_index_nbo = htons (commit_coin->newcoin_index);
|
||||
struct TALER_DB_QueryParam params[] = {
|
||||
TALER_DB_QUERY_PARAM_PTR(&commit_coin->session_pub),
|
||||
TALER_DB_QUERY_PARAM_PTR(&commit_coin->coin_ev),
|
||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||
TALER_DB_QUERY_PARAM_PTR_SIZED(&commit_coin->link_enc, sizeof (struct LinkData)),
|
||||
TALER_DB_QUERY_PARAM_END
|
||||
};
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_refresh_commit_coin", params);
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn,
|
||||
"insert_refresh_commit_link",
|
||||
params);
|
||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||
{
|
||||
break_db_err (result);
|
||||
@ -1233,12 +1214,9 @@ TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn,
|
||||
TALER_DB_QUERY_PARAM_END
|
||||
};
|
||||
|
||||
cc->cnc_index = cnc_index;
|
||||
cc->oldcoin_index = oldcoin_index;
|
||||
cc->session_pub = *refresh_session_pub;
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn, "get_refresh_commit_link", params);
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn,
|
||||
"get_refresh_commit_link",
|
||||
params);
|
||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||
{
|
||||
break_db_err (result);
|
||||
@ -1254,8 +1232,7 @@ TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn,
|
||||
|
||||
struct TALER_DB_ResultSpec rs[] = {
|
||||
TALER_DB_RESULT_SPEC("transfer_pub", &cc->transfer_pub),
|
||||
TALER_DB_RESULT_SPEC_SIZED("link_secret_enc", &cc->shared_secret_enc,
|
||||
TALER_REFRESH_SHARED_SECRET_LENGTH),
|
||||
TALER_DB_RESULT_SPEC("link_secret_enc", &cc->shared_secret),
|
||||
TALER_DB_RESULT_SPEC_END
|
||||
};
|
||||
|
||||
@ -1267,7 +1244,46 @@ TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn,
|
||||
}
|
||||
|
||||
PQclear (result);
|
||||
return GNUNET_YES;
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_commit_coin (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
|
||||
int i, int j,
|
||||
const struct RefreshCommitCoin *commit_coin)
|
||||
{
|
||||
uint16_t cnc_index_nbo = htons (i);
|
||||
uint16_t newcoin_index_nbo = htons (j);
|
||||
struct TALER_DB_QueryParam params[] = {
|
||||
TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
|
||||
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coin->coin_ev, commit_coin->coin_ev_size),
|
||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coin->refresh_link->coin_priv_enc,
|
||||
commit_coin->refresh_link->blinding_key_enc_size +
|
||||
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)),
|
||||
TALER_DB_QUERY_PARAM_END
|
||||
};
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_refresh_commit_coin", params);
|
||||
|
||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||
{
|
||||
break_db_err (result);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
if (0 != strcmp ("1", PQcmdTuples (result)))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
PQclear (result);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -1280,17 +1296,17 @@ TALER_MINT_DB_get_refresh_commit_coin (PGconn *db_conn,
|
||||
{
|
||||
uint16_t cnc_index_nbo = htons (cnc_index);
|
||||
uint16_t newcoin_index_nbo = htons (newcoin_index);
|
||||
|
||||
cc->cnc_index = cnc_index;
|
||||
cc->newcoin_index = newcoin_index;
|
||||
cc->session_pub = *refresh_session_pub;
|
||||
|
||||
struct TALER_DB_QueryParam params[] = {
|
||||
TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
|
||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||
TALER_DB_QUERY_PARAM_END
|
||||
};
|
||||
char *c_buf;
|
||||
size_t c_buf_size;
|
||||
char *rl_buf;
|
||||
size_t rl_buf_size;
|
||||
struct TALER_RefreshLinkEncrypted *rl;
|
||||
|
||||
PGresult *result = TALER_DB_exec_prepared (db_conn, "get_refresh_commit_coin", params);
|
||||
|
||||
@ -1308,19 +1324,34 @@ TALER_MINT_DB_get_refresh_commit_coin (PGconn *db_conn,
|
||||
}
|
||||
|
||||
struct TALER_DB_ResultSpec rs[] = {
|
||||
TALER_DB_RESULT_SPEC("coin_ev", &cc->coin_ev),
|
||||
TALER_DB_RESULT_SPEC_SIZED("link_vector_enc", &cc->link_enc,
|
||||
TALER_REFRESH_LINK_LENGTH),
|
||||
TALER_DB_RESULT_SPEC_VAR("coin_ev", &c_buf, &c_buf_size),
|
||||
TALER_DB_RESULT_SPEC_VAR("link_vector_enc", &rl_buf, &rl_buf_size),
|
||||
TALER_DB_RESULT_SPEC_END
|
||||
};
|
||||
|
||||
if (GNUNET_YES != TALER_DB_extract_result (result, rs, 0))
|
||||
{
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
PQclear (result);
|
||||
if (rl_buf_size < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))
|
||||
{
|
||||
GNUNET_free (c_buf);
|
||||
GNUNET_free (rl_buf);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
rl = GNUNET_malloc (sizeof (struct TALER_RefreshLinkEncrypted) +
|
||||
rl_buf_size - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));
|
||||
rl->blinding_key_enc = (const char *) &rl[1];
|
||||
rl->blinding_key_enc_size = rl_buf_size - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
|
||||
memcpy (rl->coin_priv_enc,
|
||||
rl_buf,
|
||||
rl_buf_size);
|
||||
GNUNET_free (rl_buf);
|
||||
cc->refresh_link = rl;
|
||||
cc->coin_ev = c_buf;
|
||||
cc->coin_ev_size = c_buf_size;
|
||||
return GNUNET_YES;
|
||||
}
|
||||
|
||||
@ -1582,15 +1613,17 @@ TALER_db_get_link (PGconn *db_conn,
|
||||
|
||||
for (i = 0; i < PQntuples (result); i++)
|
||||
{
|
||||
struct LinkDataEnc link_data_enc;
|
||||
struct TALER_RefreshLinkEncrypted *link_enc;
|
||||
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub;
|
||||
struct GNUNET_CRYPTO_rsa_Signature *sig;
|
||||
char *ld_buf;
|
||||
size_t ld_buf_size;
|
||||
char *pk_buf;
|
||||
size_t pk_buf_size;
|
||||
char *sig_buf;
|
||||
size_t sig_buf_size;
|
||||
struct TALER_DB_ResultSpec rs[] = {
|
||||
TALER_DB_RESULT_SPEC("link_vector_enc", &link_data_enc),
|
||||
TALER_DB_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size),
|
||||
TALER_DB_RESULT_SPEC_VAR("denom_pub", &pk_buf, &pk_buf_size),
|
||||
TALER_DB_RESULT_SPEC_VAR("ev_sig", &sig_buf, &sig_buf_size),
|
||||
TALER_DB_RESULT_SPEC_END
|
||||
@ -1602,39 +1635,59 @@ TALER_db_get_link (PGconn *db_conn,
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (ld_buf_size < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))
|
||||
{
|
||||
PQclear (result);
|
||||
GNUNET_free (pk_buf);
|
||||
GNUNET_free (sig_buf);
|
||||
GNUNET_free (ld_buf);
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
link_enc = GNUNET_malloc (sizeof (struct TALER_RefreshLinkEncrypted) +
|
||||
ld_buf_size - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));
|
||||
link_enc->blinding_key_enc = (const char *) &link_enc[1];
|
||||
link_enc->blinding_key_enc_size = ld_buf_size - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
|
||||
memcpy (link_enc->coin_priv_enc,
|
||||
ld_buf,
|
||||
ld_buf_size);
|
||||
|
||||
sig = GNUNET_CRYPTO_rsa_signature_decode (sig_buf,
|
||||
sig_buf_size);
|
||||
denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (pk_buf,
|
||||
pk_buf_size);
|
||||
GNUNET_free (pk_buf);
|
||||
GNUNET_free (sig_buf);
|
||||
GNUNET_free (ld_buf);
|
||||
if ( (NULL == sig) ||
|
||||
(NULL == denom_pub) )
|
||||
{
|
||||
PQclear (result);
|
||||
if (NULL != denom_pub)
|
||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pub);
|
||||
if (NULL != sig)
|
||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||
GNUNET_free (link_enc);
|
||||
GNUNET_break (0);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (GNUNET_OK != (res = link_iter (cls,
|
||||
&link_data_enc,
|
||||
link_enc,
|
||||
denom_pub,
|
||||
sig)))
|
||||
{
|
||||
GNUNET_assert (GNUNET_SYSERR != res);
|
||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pub);
|
||||
GNUNET_free (link_enc);
|
||||
PQclear (result);
|
||||
return res;
|
||||
}
|
||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pub);
|
||||
GNUNET_free (link_enc);
|
||||
}
|
||||
|
||||
PQclear (result);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
@ -1643,7 +1696,7 @@ int
|
||||
TALER_db_get_transfer (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
|
||||
struct GNUNET_CRYPTO_EcdsaPublicKey *transfer_pub,
|
||||
struct SharedSecretEnc *shared_secret_enc)
|
||||
struct GNUNET_HashCode *shared_secret_enc)
|
||||
{
|
||||
struct TALER_DB_QueryParam params[] = {
|
||||
TALER_DB_QUERY_PARAM_PTR(coin_pub),
|
||||
@ -1667,7 +1720,9 @@ TALER_db_get_transfer (PGconn *db_conn,
|
||||
|
||||
if (1 != PQntuples (result))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "got %d tuples for get_transfer\n", PQntuples (result));
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"got %d tuples for get_transfer\n",
|
||||
PQntuples (result));
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
@ -122,23 +122,49 @@ TALER_MINT_DB_get_known_coin (PGconn *db_conn,
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_upsert_known_coin (PGconn *db_conn, struct KnownCoin *known_coin);
|
||||
TALER_MINT_DB_upsert_known_coin (PGconn *db_conn,
|
||||
struct KnownCoin *known_coin);
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_create_refresh_session (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub);
|
||||
|
||||
|
||||
/**
|
||||
* Store the commitment to the given (encrypted) refresh link data
|
||||
* for the given refresh session.
|
||||
*
|
||||
* @param db_conn database connection to use
|
||||
* @param refresh_session_pub public key of the refresh session this
|
||||
* commitment belongs with
|
||||
* @param i
|
||||
* @param j
|
||||
* @param commit_link link information to store
|
||||
* @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success
|
||||
*/
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_commit_link (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
|
||||
int i, int j,
|
||||
const struct RefreshCommitLink *commit_link);
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_commit_coin (PGconn *db_conn,
|
||||
const struct RefreshCommitCoin *commit_coin);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
|
||||
int i, int j,
|
||||
struct RefreshCommitLink *commit_link);
|
||||
struct RefreshCommitLink *cc);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_commit_coin (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
|
||||
int i,
|
||||
int j,
|
||||
const struct RefreshCommitCoin *commit_coin);
|
||||
|
||||
|
||||
int
|
||||
@ -148,12 +174,6 @@ TALER_MINT_DB_get_refresh_commit_coin (PGconn *db_conn,
|
||||
struct RefreshCommitCoin *commit_coin);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_create_refresh_session (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey
|
||||
*session_pub);
|
||||
|
||||
|
||||
struct GNUNET_CRYPTO_rsa_PublicKey *
|
||||
TALER_MINT_DB_get_refresh_order (PGconn *db_conn,
|
||||
uint16_t newcoin_index,
|
||||
@ -178,6 +198,7 @@ int
|
||||
TALER_MINT_DB_set_reveal_ok (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_refresh_melt (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub,
|
||||
@ -193,11 +214,15 @@ TALER_MINT_DB_get_refresh_melt (PGconn *db_conn,
|
||||
struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub);
|
||||
|
||||
|
||||
typedef
|
||||
int (*LinkIterator) (void *cls,
|
||||
const struct LinkDataEnc *link_data_enc,
|
||||
const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub,
|
||||
const struct GNUNET_CRYPTO_rsa_Signature *ev_sig);
|
||||
/**
|
||||
* FIXME: doc, name is bad, too.
|
||||
*/
|
||||
typedef int
|
||||
(*LinkIterator) (void *cls,
|
||||
const struct TALER_RefreshLinkEncrypted *link_data_enc,
|
||||
const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub,
|
||||
const struct GNUNET_CRYPTO_rsa_Signature *ev_sig);
|
||||
|
||||
|
||||
int
|
||||
TALER_db_get_link (PGconn *db_conn,
|
||||
@ -206,26 +231,37 @@ TALER_db_get_link (PGconn *db_conn,
|
||||
void *cls);
|
||||
|
||||
|
||||
/**
|
||||
* Obtain shared secret from the transfer public key (?).
|
||||
*
|
||||
* @param shared_secret_enc[out] set to shared secret; FIXME: use other type
|
||||
* to indicate this is the encrypted secret
|
||||
*/
|
||||
int
|
||||
TALER_db_get_transfer (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
|
||||
struct GNUNET_CRYPTO_EcdsaPublicKey *transfer_pub,
|
||||
struct SharedSecretEnc *shared_secret_enc);
|
||||
struct GNUNET_HashCode *shared_secret_enc);
|
||||
|
||||
int
|
||||
TALER_MINT_DB_init_deposits (PGconn *db_conn, int temporary);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_prepare_deposits (PGconn *db_conn);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_deposit (PGconn *db_conn,
|
||||
const struct Deposit *deposit);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_get_deposit (PGconn *db_conn,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey *coin_pub,
|
||||
struct Deposit **r_deposit);
|
||||
|
||||
|
||||
int
|
||||
TALER_MINT_DB_insert_known_coin (PGconn *db_conn,
|
||||
const struct KnownCoin *known_coin);
|
||||
|
@ -689,8 +689,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
||||
*
|
||||
* @param connection the MHD connection to handle
|
||||
* @param kappa size of x-dimension of @commit_coin and @commit_link arrays
|
||||
* @param num_oldcoins size of y-dimension of @commit_coin and @commit_link arrays
|
||||
* @param num_newcoins size of y-dimension of @commit_coin and @commit_link arrays
|
||||
* @param num_oldcoins size of y-dimension of @commit_link array
|
||||
* @param num_newcoins size of y-dimension of @commit_coin array
|
||||
* @param commit_coin
|
||||
* @param commit_link
|
||||
* @return MHD result code
|
||||
*/
|
||||
int
|
||||
@ -730,6 +732,9 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection,
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
TALER_MINT_DB_insert_refresh_commit_coin (db_conn,
|
||||
refresh_session_pub,
|
||||
i,
|
||||
j,
|
||||
&commit_coin[i][j]))
|
||||
{
|
||||
// FIXME: return 'internal error'?
|
||||
@ -739,7 +744,11 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection,
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_MINT_DB_insert_refresh_commit_link (db_conn, &commit_link[i][j]))
|
||||
TALER_MINT_DB_insert_refresh_commit_link (db_conn,
|
||||
refresh_session_pub,
|
||||
i,
|
||||
j,
|
||||
&commit_link[i][j]))
|
||||
{
|
||||
// FIXME: return 'internal error'?
|
||||
GNUNET_break (0);
|
||||
|
@ -103,8 +103,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
||||
*
|
||||
* @param connection the MHD connection to handle
|
||||
* @param kappa size of x-dimension of @commit_coin and @commit_link arrays
|
||||
* @param num_oldcoins size of y-dimension of @commit_coin and @commit_link arrays
|
||||
* @param num_newcoins size of y-dimension of @commit_coin and @commit_link arrays
|
||||
* @param num_oldcoins size of y-dimension of @commit_coin array
|
||||
* @param num_newcoins size of y-dimension of @commit_link array
|
||||
* @param commit_coin
|
||||
* @param commit_link
|
||||
* @return MHD result code
|
||||
*/
|
||||
int
|
||||
|
@ -541,6 +541,9 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh,
|
||||
sizeof (struct RefreshCommitCoin));
|
||||
for (j = 0; j < num_newcoins; j++)
|
||||
{
|
||||
char *link_end;
|
||||
size_t link_enc_size;
|
||||
|
||||
res = GNUNET_MINT_parse_navigate_json (connection, root,
|
||||
JNAV_FIELD, "coin_evs",
|
||||
JNAV_INDEX, (int) i,
|
||||
@ -565,9 +568,9 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh,
|
||||
JNAV_FIELD, "link_encs",
|
||||
JNAV_INDEX, (int) i,
|
||||
JNAV_INDEX, (int) j,
|
||||
JNAV_RET_DATA,
|
||||
commit_coin[i][j].link_enc,
|
||||
TALER_REFRESH_LINK_LENGTH);
|
||||
JNAV_RET_DATA_VAR,
|
||||
&link_enc,
|
||||
&link_enc_size);
|
||||
if (GNUNET_OK != res)
|
||||
{
|
||||
// FIXME: return 'internal error'?
|
||||
@ -575,13 +578,13 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh,
|
||||
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||
}
|
||||
// FIXME: convert link_enc / link_enc_size to
|
||||
// commit_coin[i][j].refresh_link!
|
||||
|
||||
|
||||
GNUNET_CRYPTO_hash_context_read (hash_context,
|
||||
commit_coin[i][j].link_enc,
|
||||
TALER_REFRESH_LINK_LENGTH);
|
||||
commit_coin[i][j].cnc_index = i;
|
||||
commit_coin[i][j].newcoin_index = j;
|
||||
commit_coin[i][j].session_pub = refresh_session_pub;
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,8 +620,8 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh,
|
||||
JNAV_INDEX, (int) i,
|
||||
JNAV_INDEX, (int) j,
|
||||
JNAV_RET_DATA,
|
||||
commit_link[i][j].shared_secret_enc,
|
||||
TALER_REFRESH_SHARED_SECRET_LENGTH);
|
||||
&commit_link[i][j].shared_secret,
|
||||
sizeof (struct GNUNET_HashCode));
|
||||
|
||||
if (GNUNET_OK != res)
|
||||
{
|
||||
@ -628,13 +631,8 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh,
|
||||
}
|
||||
|
||||
GNUNET_CRYPTO_hash_context_read (hash_context,
|
||||
commit_link[i][j].shared_secret_enc,
|
||||
TALER_REFRESH_SHARED_SECRET_LENGTH);
|
||||
|
||||
commit_link[i][j].cnc_index = i;
|
||||
commit_link[i][j].oldcoin_index = j;
|
||||
commit_link[i][j].session_pub = refresh_session_pub;
|
||||
|
||||
&commit_link[i][j].shared_secret,
|
||||
sizeof (struct GNUNET_HashCode));
|
||||
}
|
||||
}
|
||||
GNUNET_CRYPTO_hash_context_finish (hash_context, &commit_hash);
|
||||
|
@ -646,9 +646,10 @@ main (int argc, char *const *argv)
|
||||
// check if key from file matches the one from the configuration
|
||||
{
|
||||
struct GNUNET_CRYPTO_EddsaPublicKey master_pub_from_cfg;
|
||||
if (GNUNET_OK != TALER_configuration_get_data (kcfg, "mint", "master_pub",
|
||||
&master_pub_from_cfg,
|
||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_data (kcfg, "mint", "master_pub",
|
||||
&master_pub_from_cfg,
|
||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
|
||||
{
|
||||
fprintf (stderr, "master key missing in configuration (mint.master_pub)\n");
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user