slowly implementing age restriction in refresh/reveal
- hash of age commitment passed around API boundaries - code compiles and tests run - ready to derive new age commitment
This commit is contained in:
parent
e6d85c824f
commit
9a0c86d644
@ -79,6 +79,8 @@ serialize_melted_coin (const struct MeltedCoin *mc)
|
||||
return GNUNET_JSON_PACK (
|
||||
GNUNET_JSON_pack_data_auto ("coin_priv",
|
||||
&mc->coin_priv),
|
||||
GNUNET_JSON_pack_data_auto ("h_age_commitment",
|
||||
&mc->h_age_commitment),
|
||||
TALER_JSON_pack_denom_sig ("denom_sig",
|
||||
&mc->sig),
|
||||
TALER_JSON_pack_denom_pub ("denom_pub",
|
||||
@ -113,6 +115,9 @@ deserialize_melted_coin (struct MeltedCoin *mc,
|
||||
struct GNUNET_JSON_Specification spec[] = {
|
||||
GNUNET_JSON_spec_fixed_auto ("coin_priv",
|
||||
&mc->coin_priv),
|
||||
GNUNET_JSON_spec_mark_optional (
|
||||
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
|
||||
&mc->h_age_commitment)),
|
||||
TALER_JSON_spec_denom_sig ("denom_sig",
|
||||
&mc->sig),
|
||||
TALER_JSON_spec_denom_pub ("denom_pub",
|
||||
@ -367,6 +372,9 @@ TALER_EXCHANGE_refresh_prepare (
|
||||
md.melted_coin.original_value = melt_pk->value;
|
||||
md.melted_coin.expire_deposit
|
||||
= melt_pk->expire_deposit;
|
||||
TALER_age_commitment_hash (age_commitment,
|
||||
&md.melted_coin.h_age_commitment);
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_amount_set_zero (melt_amount->currency,
|
||||
&total));
|
||||
@ -427,22 +435,36 @@ TALER_EXCHANGE_refresh_prepare (
|
||||
struct TALER_RefreshCoinData);
|
||||
|
||||
md.fresh_ach[i] = GNUNET_new_array (fresh_pks_len,
|
||||
struct TALER_AgeCommitment);
|
||||
struct TALER_AgeCommitmentHash);
|
||||
|
||||
for (unsigned int j = 0; j<fresh_pks_len; j++)
|
||||
{
|
||||
struct TALER_PlanchetSecretsP *fc = &md.fresh_coins[i][j];
|
||||
struct TALER_RefreshCoinData *rcd = &rce[i].new_coins[j];
|
||||
struct TALER_AgeCommitmentHash *ach = &md.fresh_ach[i][j];
|
||||
struct TALER_PlanchetDetail pd;
|
||||
struct TALER_CoinPubHash c_hash;
|
||||
|
||||
if (NULL == age_commitment)
|
||||
{
|
||||
memset (ach, 0, sizeof(struct TALER_AgeCommitmentHash));
|
||||
ach = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Age Commitment provided, but not supported");
|
||||
// FIXME-oec: Fill &md.fresh_ach[i][j];
|
||||
}
|
||||
|
||||
TALER_planchet_setup_refresh (&trans_sec[i],
|
||||
j,
|
||||
fc);
|
||||
if (GNUNET_OK !=
|
||||
TALER_planchet_prepare (&md.fresh_pks[j],
|
||||
fc,
|
||||
&md.fresh_ach[j],
|
||||
ach,
|
||||
&c_hash,
|
||||
&pd))
|
||||
{
|
||||
|
@ -52,6 +52,12 @@ struct MeltedCoin
|
||||
*/
|
||||
struct TALER_Amount original_value;
|
||||
|
||||
/**
|
||||
* The original age commitment hash. MUST be all zeroes, if no age
|
||||
* commitment was set.
|
||||
*/
|
||||
struct TALER_AgeCommitmentHash h_age_commitment;
|
||||
|
||||
/**
|
||||
* Transfer private keys for each cut-and-choose dimension.
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,
|
||||
{
|
||||
const struct TALER_PlanchetSecretsP *fc;
|
||||
struct TALER_DenominationPublicKey *pk;
|
||||
struct TALER_AgeCommitmentHash *ach;
|
||||
struct TALER_AgeCommitmentHash *ach = NULL;
|
||||
json_t *jsonai;
|
||||
struct TALER_BlindedDenominationSignature blind_sig;
|
||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||
@ -149,11 +149,16 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,
|
||||
struct TALER_FreshCoin coin;
|
||||
|
||||
fc = &rrh->md->fresh_coins[rrh->noreveal_index][i];
|
||||
ach = &rrh->md->fresh_ach[rrh->noreveal_index][i];
|
||||
pk = &rrh->md->fresh_pks[i];
|
||||
jsonai = json_array_get (jsona, i);
|
||||
GNUNET_assert (NULL != jsonai);
|
||||
|
||||
if (! TALER_AgeCommitmentHash_isNullOrZero (
|
||||
&rrh->md->melted_coin.h_age_commitment))
|
||||
{
|
||||
ach = &rrh->md->fresh_ach[rrh->noreveal_index][i];
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_JSON_parse (jsonai,
|
||||
spec,
|
||||
|
@ -373,7 +373,14 @@ TALER_age_commitment_hash (
|
||||
{
|
||||
struct GNUNET_HashContext *hash_context;
|
||||
struct GNUNET_HashCode hash;
|
||||
GNUNET_assert (NULL != commitment);
|
||||
|
||||
GNUNET_assert (NULL != ahash);
|
||||
if (NULL == commitment)
|
||||
{
|
||||
memset (ahash, 0, sizeof(struct TALER_AgeCommitmentHash));
|
||||
return;
|
||||
}
|
||||
|
||||
GNUNET_assert (__builtin_popcount (commitment->mask.mask) ==
|
||||
commitment->num_pub_keys);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user