mostly working migration of the DH-seeded refresh variant
This commit is contained in:
parent
745719dbc1
commit
0fd6cf19af
@ -209,8 +209,10 @@ parse_refresh_link_ok (struct TALER_EXCHANGE_RefreshLinkHandle *rlh,
|
|||||||
json_t *jsona;
|
json_t *jsona;
|
||||||
struct TALER_TransferPublicKeyP trans_pub;
|
struct TALER_TransferPublicKeyP trans_pub;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_json ("new_coins", &jsona),
|
GNUNET_JSON_spec_json ("new_coins",
|
||||||
GNUNET_JSON_spec_fixed_auto ("transfer_pub", &trans_pub),
|
&jsona),
|
||||||
|
GNUNET_JSON_spec_fixed_auto ("transfer_pub",
|
||||||
|
&trans_pub),
|
||||||
GNUNET_JSON_spec_end()
|
GNUNET_JSON_spec_end()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -425,7 +425,9 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
/* parse JSON arrays into binary arrays and hash everything
|
/* parse JSON arrays into binary arrays and hash everything
|
||||||
together for the signature check */
|
together for the signature check */
|
||||||
memset (commit_coin, 0, sizeof (commit_coin));
|
memset (commit_coin,
|
||||||
|
0,
|
||||||
|
sizeof (commit_coin));
|
||||||
for (i = 0; i < TALER_CNC_KAPPA; i++)
|
for (i = 0; i < TALER_CNC_KAPPA; i++)
|
||||||
{
|
{
|
||||||
commit_coin[i] = GNUNET_new_array (num_newcoins,
|
commit_coin[i] = GNUNET_new_array (num_newcoins,
|
||||||
@ -454,7 +456,6 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
GNUNET_CRYPTO_hash_context_read (hash_context,
|
GNUNET_CRYPTO_hash_context_read (hash_context,
|
||||||
rcc->coin_ev,
|
rcc->coin_ev,
|
||||||
rcc->coin_ev_size);
|
rcc->coin_ev_size);
|
||||||
GNUNET_JSON_parse_free (coin_spec);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,9 +575,6 @@ PERF_TALER_EXCHANGEDB_refresh_commit_coin_init ()
|
|||||||
struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin;
|
struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin;
|
||||||
|
|
||||||
commit_coin = GNUNET_new (struct TALER_EXCHANGEDB_RefreshCommitCoin);
|
commit_coin = GNUNET_new (struct TALER_EXCHANGEDB_RefreshCommitCoin);
|
||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
|
||||||
&commit_coin->refresh_link,
|
|
||||||
sizeof(struct TALER_RefreshLinkEncryptedP));
|
|
||||||
commit_coin->coin_ev = "coin_ev";
|
commit_coin->coin_ev = "coin_ev";
|
||||||
commit_coin->coin_ev_size = 8;
|
commit_coin->coin_ev_size = 8;
|
||||||
return commit_coin;
|
return commit_coin;
|
||||||
|
@ -3464,7 +3464,7 @@ postgres_get_link_data_list (void *cls,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nrows; i++)
|
for (i = nrows-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_RsaPublicKey *denom_pub;
|
struct GNUNET_CRYPTO_RsaPublicKey *denom_pub;
|
||||||
struct GNUNET_CRYPTO_RsaSignature *sig;
|
struct GNUNET_CRYPTO_RsaSignature *sig;
|
||||||
@ -3481,7 +3481,9 @@ postgres_get_link_data_list (void *cls,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_PQ_extract_result (result, rs, i))
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
{
|
{
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -297,26 +297,6 @@ static struct TALER_Amount fee_refund;
|
|||||||
static struct TALER_Amount amount_with_fee;
|
static struct TALER_Amount amount_with_fee;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare two coin encrypted refresh links.
|
|
||||||
*
|
|
||||||
* @param rc1 first commitment
|
|
||||||
* @param rc2 second commitment
|
|
||||||
* @return 0 if they are equal
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
refresh_link_encrypted_cmp (struct TALER_RefreshLinkEncryptedP *rl1,
|
|
||||||
struct TALER_RefreshLinkEncryptedP *rl2)
|
|
||||||
{
|
|
||||||
if (0 ==
|
|
||||||
memcmp (rl1,
|
|
||||||
rl2,
|
|
||||||
sizeof (struct TALER_RefreshLinkEncryptedP)))
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two coin commitments.
|
* Compare two coin commitments.
|
||||||
*
|
*
|
||||||
@ -332,11 +312,9 @@ commit_coin_cmp (struct TALER_EXCHANGEDB_RefreshCommitCoin *rc1,
|
|||||||
FAILIF (0 != memcmp (rc1->coin_ev,
|
FAILIF (0 != memcmp (rc1->coin_ev,
|
||||||
rc2->coin_ev,
|
rc2->coin_ev,
|
||||||
rc2->coin_ev_size));
|
rc2->coin_ev_size));
|
||||||
FAILIF (0 !=
|
|
||||||
refresh_link_encrypted_cmp (&rc1->refresh_link,
|
|
||||||
&rc2->refresh_link));
|
|
||||||
return 0;
|
return 0;
|
||||||
drop:
|
drop:
|
||||||
|
GNUNET_break (0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,9 +347,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
|
|||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_RefreshCommitCoin *ret_commit_coins;
|
struct TALER_EXCHANGEDB_RefreshCommitCoin *ret_commit_coins;
|
||||||
struct TALER_EXCHANGEDB_RefreshCommitCoin *a_ccoin;
|
struct TALER_EXCHANGEDB_RefreshCommitCoin *a_ccoin;
|
||||||
struct TALER_RefreshLinkEncryptedP a_rlink;
|
|
||||||
struct TALER_EXCHANGEDB_RefreshCommitCoin *b_ccoin;
|
struct TALER_EXCHANGEDB_RefreshCommitCoin *b_ccoin;
|
||||||
struct TALER_RefreshLinkEncryptedP b_rlink;
|
|
||||||
unsigned int cnt;
|
unsigned int cnt;
|
||||||
uint16_t cnc_index;
|
uint16_t cnc_index;
|
||||||
int ret;
|
int ret;
|
||||||
@ -387,13 +363,8 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
|
|||||||
for (cnt=0; cnt < MELT_NEW_COINS; cnt++)
|
for (cnt=0; cnt < MELT_NEW_COINS; cnt++)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_RefreshCommitCoin *ccoin;
|
struct TALER_EXCHANGEDB_RefreshCommitCoin *ccoin;
|
||||||
struct TALER_RefreshLinkEncryptedP rlink;
|
|
||||||
|
|
||||||
ccoin = &commit_coins[cnc_index][cnt];
|
ccoin = &commit_coins[cnc_index][cnt];
|
||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
|
||||||
&rlink,
|
|
||||||
sizeof (rlink));
|
|
||||||
ccoin->refresh_link = rlink;
|
|
||||||
ccoin->coin_ev_size = GNUNET_CRYPTO_random_u64
|
ccoin->coin_ev_size = GNUNET_CRYPTO_random_u64
|
||||||
(GNUNET_CRYPTO_QUALITY_WEAK, COIN_ENC_MAX_SIZE);
|
(GNUNET_CRYPTO_QUALITY_WEAK, COIN_ENC_MAX_SIZE);
|
||||||
ccoin->coin_ev = GNUNET_malloc (ccoin->coin_ev_size);
|
ccoin->coin_ev = GNUNET_malloc (ccoin->coin_ev_size);
|
||||||
@ -426,14 +397,6 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
|
|||||||
FAILIF (0 != memcmp (a_ccoin->coin_ev,
|
FAILIF (0 != memcmp (a_ccoin->coin_ev,
|
||||||
a_ccoin->coin_ev,
|
a_ccoin->coin_ev,
|
||||||
a_ccoin->coin_ev_size));
|
a_ccoin->coin_ev_size));
|
||||||
a_rlink = a_ccoin->refresh_link;
|
|
||||||
b_rlink = b_ccoin->refresh_link;
|
|
||||||
FAILIF (0 != memcmp (a_rlink.blinding_key_enc,
|
|
||||||
b_rlink.blinding_key_enc,
|
|
||||||
sizeof (a_rlink.blinding_key_enc)));
|
|
||||||
FAILIF (0 != memcmp (a_rlink.coin_priv_enc,
|
|
||||||
b_rlink.coin_priv_enc,
|
|
||||||
sizeof (a_rlink.coin_priv_enc)));
|
|
||||||
GNUNET_free (ret_commit_coins[cnt].coin_ev);
|
GNUNET_free (ret_commit_coins[cnt].coin_ev);
|
||||||
}
|
}
|
||||||
GNUNET_free (ret_commit_coins);
|
GNUNET_free (ret_commit_coins);
|
||||||
@ -453,7 +416,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct TALER_RefreshCommitLinkP rclp[TALER_CNC_KAPPA];
|
static struct TALER_TransferPublicKeyP rctp[TALER_CNC_KAPPA];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -469,37 +432,37 @@ test_refresh_commit_links (struct TALER_EXCHANGEDB_Session *session,
|
|||||||
const struct TALER_EXCHANGEDB_RefreshSession *refresh_session,
|
const struct TALER_EXCHANGEDB_RefreshSession *refresh_session,
|
||||||
const struct GNUNET_HashCode *session_hash)
|
const struct GNUNET_HashCode *session_hash)
|
||||||
{
|
{
|
||||||
struct TALER_RefreshCommitLinkP cl2;
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
struct TALER_TransferPublicKeyP tp;
|
||||||
|
|
||||||
ret = GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
FAILIF (GNUNET_NO !=
|
FAILIF (GNUNET_NO !=
|
||||||
plugin->get_refresh_commit_link (plugin->cls,
|
plugin->get_refresh_transfer_public_key (plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
MELT_NOREVEAL_INDEX,
|
MELT_NOREVEAL_INDEX,
|
||||||
&cl2));
|
&tp));
|
||||||
for (i=0;i<TALER_CNC_KAPPA;i++)
|
for (i=0;i<TALER_CNC_KAPPA;i++)
|
||||||
{
|
{
|
||||||
RND_BLK (&rclp[i]);
|
RND_BLK (&rctp[i]);
|
||||||
FAILIF (GNUNET_OK !=
|
FAILIF (GNUNET_OK !=
|
||||||
plugin->insert_refresh_commit_link (plugin->cls,
|
plugin->insert_refresh_transfer_public_key (plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
i,
|
i,
|
||||||
&rclp[i]));
|
&rctp[i]));
|
||||||
|
|
||||||
FAILIF (GNUNET_OK !=
|
FAILIF (GNUNET_OK !=
|
||||||
plugin->get_refresh_commit_link (plugin->cls,
|
plugin->get_refresh_transfer_public_key (plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
i,
|
i,
|
||||||
&cl2));
|
&tp));
|
||||||
FAILIF (0 !=
|
FAILIF (0 !=
|
||||||
memcmp (&rclp[i],
|
memcmp (&rctp[i],
|
||||||
&cl2,
|
&tp,
|
||||||
sizeof (struct TALER_RefreshCommitLinkP)));
|
sizeof (struct TALER_TransferPublicKeyP)));
|
||||||
}
|
}
|
||||||
ret = GNUNET_OK;
|
ret = GNUNET_OK;
|
||||||
drop:
|
drop:
|
||||||
@ -517,22 +480,17 @@ static struct GNUNET_HashCode session_hash;
|
|||||||
* @param cls closure
|
* @param cls closure
|
||||||
* @param sh a session the coin was melted in
|
* @param sh a session the coin was melted in
|
||||||
* @param transfer_pub public transfer key for the session
|
* @param transfer_pub public transfer key for the session
|
||||||
* @param shared_secret_enc set to shared secret for the session
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
check_transfer_data (void *cls,
|
check_transfer_data (void *cls,
|
||||||
const struct GNUNET_HashCode *sh,
|
const struct GNUNET_HashCode *sh,
|
||||||
const struct TALER_TransferPublicKeyP *transfer_pub,
|
const struct TALER_TransferPublicKeyP *transfer_pub)
|
||||||
const struct TALER_EncryptedLinkSecretP *shared_secret_enc)
|
|
||||||
{
|
{
|
||||||
int *ok = cls;
|
int *ok = cls;
|
||||||
|
|
||||||
FAILIF (0 != memcmp (&rclp[MELT_NOREVEAL_INDEX].transfer_pub,
|
FAILIF (0 != memcmp (&rctp[MELT_NOREVEAL_INDEX],
|
||||||
transfer_pub,
|
transfer_pub,
|
||||||
sizeof (struct TALER_TransferPublicKeyP)));
|
sizeof (struct TALER_TransferPublicKeyP)));
|
||||||
FAILIF (0 != memcmp (&rclp[MELT_NOREVEAL_INDEX].shared_secret_enc,
|
|
||||||
shared_secret_enc,
|
|
||||||
sizeof (struct TALER_EncryptedLinkSecretP)));
|
|
||||||
FAILIF (0 != memcmp (&session_hash,
|
FAILIF (0 != memcmp (&session_hash,
|
||||||
sh,
|
sh,
|
||||||
sizeof (struct GNUNET_HashCode)));
|
sizeof (struct GNUNET_HashCode)));
|
||||||
@ -711,9 +669,9 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
|
|||||||
for (i=0;i<TALER_CNC_KAPPA;i++)
|
for (i=0;i<TALER_CNC_KAPPA;i++)
|
||||||
{
|
{
|
||||||
FAILIF (0 !=
|
FAILIF (0 !=
|
||||||
memcmp (&rclp[i],
|
memcmp (&rctp[i],
|
||||||
&mc->commit_links[i],
|
&mc->transfer_pubs[i],
|
||||||
sizeof (struct TALER_RefreshCommitLinkP)));
|
sizeof (struct TALER_TransferPublicKeyP)));
|
||||||
}
|
}
|
||||||
plugin->free_melt_commitment (plugin->cls,
|
plugin->free_melt_commitment (plugin->cls,
|
||||||
mc);
|
mc);
|
||||||
@ -741,24 +699,18 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
|
|||||||
FAILIF (NULL == ldl);
|
FAILIF (NULL == ldl);
|
||||||
for (ldlp = ldl; NULL != ldlp; ldlp = ldlp->next)
|
for (ldlp = ldl; NULL != ldlp; ldlp = ldlp->next)
|
||||||
{
|
{
|
||||||
struct TALER_RefreshLinkEncryptedP r1;
|
|
||||||
struct TALER_RefreshLinkEncryptedP r2;
|
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
found = GNUNET_NO;
|
found = GNUNET_NO;
|
||||||
for (cnt=0;cnt < MELT_NEW_COINS;cnt++)
|
for (cnt=0;cnt < MELT_NEW_COINS;cnt++)
|
||||||
{
|
{
|
||||||
r1 = commit_coins[MELT_NOREVEAL_INDEX][cnt].refresh_link;
|
|
||||||
r2 = ldlp->link_data_enc;
|
|
||||||
FAILIF (NULL == ldlp->ev_sig.rsa_signature);
|
FAILIF (NULL == ldlp->ev_sig.rsa_signature);
|
||||||
if ( (0 ==
|
if ( (0 ==
|
||||||
GNUNET_CRYPTO_rsa_public_key_cmp (ldlp->denom_pub.rsa_public_key,
|
GNUNET_CRYPTO_rsa_public_key_cmp (ldlp->denom_pub.rsa_public_key,
|
||||||
new_dkp[cnt]->pub.rsa_public_key)) &&
|
new_dkp[cnt]->pub.rsa_public_key)) &&
|
||||||
(0 ==
|
(0 ==
|
||||||
GNUNET_CRYPTO_rsa_signature_cmp (ldlp->ev_sig.rsa_signature,
|
GNUNET_CRYPTO_rsa_signature_cmp (ldlp->ev_sig.rsa_signature,
|
||||||
ev_sigs[cnt].rsa_signature)) &&
|
ev_sigs[cnt].rsa_signature)) )
|
||||||
(0 ==
|
|
||||||
refresh_link_encrypted_cmp (&r1, &r2)) )
|
|
||||||
{
|
{
|
||||||
found = GNUNET_YES;
|
found = GNUNET_YES;
|
||||||
break;
|
break;
|
||||||
|
@ -475,26 +475,6 @@ struct TALER_WireTransferIdentifierP
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Representation of an encrypted refresh link.
|
|
||||||
*/
|
|
||||||
struct TALER_RefreshLinkEncryptedP
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encrypted blinding key with @e blinding_key_enc_size bytes,
|
|
||||||
* must be allocated at the end of this struct.
|
|
||||||
*/
|
|
||||||
char blinding_key_enc[sizeof (struct TALER_DenominationBlindingKeyP)];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encrypted private key of the coin.
|
|
||||||
*/
|
|
||||||
char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKeyP)];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_END
|
GNUNET_NETWORK_STRUCT_END
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user