diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2022-03-01 17:02:37 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2022-03-01 17:02:37 +0100 |
commit | e9eb00e285c80f63cfc08fdd9ea6707d55162e60 (patch) | |
tree | 82868974066e473a7905ae3e91c230e2eb96d5d3 /src/testing | |
parent | 3716592addcac5e31d092a83cf02a0fec57d8743 (diff) | |
download | exchange-e9eb00e285c80f63cfc08fdd9ea6707d55162e60.tar.xz |
Refactoring TALER_AgeCommitment
Instead of a single struct TALER_AgeCommitment, we now use
1. TALER_AgeCommitment for the age mask and list public keys for age
restriciton.
2. TALER_AgeProof for list of private keys for age restriction
3. TALER_AgeCommitmentProof for the aggregation of the former two.
Also, we introduce TALER_AgeAttestation as the EDDSA signature to attest
a particular age group, along with the function prototypes
TALER_age_commitment_attest and TALER_age_commitment_verify.
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 25 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_refresh.c | 29 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_withdraw.c | 24 |
3 files changed, 40 insertions, 38 deletions
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 33c1db447..2b9486ca5 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -287,7 +287,7 @@ deposit_run (void *cls, const struct TALER_TESTING_Command *coin_cmd; const struct TALER_CoinSpendPrivateKeyP *coin_priv; struct TALER_CoinSpendPublicKeyP coin_pub; - const struct TALER_AgeCommitment *age_commitment = NULL; + const struct TALER_AgeCommitmentProof *age_commitment_proof = NULL; struct TALER_AgeCommitmentHash h_age_commitment = {0}; const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; const struct TALER_DenominationSignature *denom_pub_sig; @@ -385,9 +385,9 @@ deposit_run (void *cls, ds->coin_index, &coin_priv)) || (GNUNET_OK != - TALER_TESTING_get_trait_age_commitment (coin_cmd, - ds->coin_index, - &age_commitment)) || + TALER_TESTING_get_trait_age_commitment_proof (coin_cmd, + ds->coin_index, + &age_commitment_proof)) || (GNUNET_OK != TALER_TESTING_get_trait_denom_pub (coin_cmd, ds->coin_index, @@ -405,9 +405,10 @@ deposit_run (void *cls, return; } - if (NULL != age_commitment) + if (NULL != age_commitment_proof) { - TALER_age_commitment_hash (age_commitment, &h_age_commitment); + TALER_age_commitment_hash (&age_commitment_proof->commitment, + &h_age_commitment); } ds->deposit_fee = denom_pub->fees.deposit; GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, @@ -533,7 +534,7 @@ deposit_traits (void *cls, const struct TALER_TESTING_Command *coin_cmd; /* Will point to coin cmd internals. */ const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv; - const struct TALER_AgeCommitment *age_commitment; + const struct TALER_AgeCommitmentProof *age_commitment_proof; if (GNUNET_YES != ds->command_initialized) { @@ -556,9 +557,9 @@ deposit_traits (void *cls, ds->coin_index, &coin_spent_priv) || (GNUNET_OK != - TALER_TESTING_get_trait_age_commitment (coin_cmd, - ds->coin_index, - &age_commitment))) + TALER_TESTING_get_trait_age_commitment_proof (coin_cmd, + ds->coin_index, + &age_commitment_proof))) { GNUNET_break (0); TALER_TESTING_interpreter_fail (ds->is); @@ -573,8 +574,8 @@ deposit_traits (void *cls, /* These traits are always available */ TALER_TESTING_make_trait_coin_priv (index, coin_spent_priv), - TALER_TESTING_make_trait_age_commitment (index, - age_commitment), + TALER_TESTING_make_trait_age_commitment_proof (index, + age_commitment_proof), TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv), diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c index 9a81a603d..e2ed8b216 100644 --- a/src/testing/testing_api_cmd_refresh.c +++ b/src/testing/testing_api_cmd_refresh.c @@ -71,9 +71,10 @@ struct TALER_TESTING_FreshCoinData struct TALER_CoinSpendPrivateKeyP coin_priv; /* - * Fresh age commitment for the coin and its hash, NULL if not applicable. + * Fresh age commitment for the coin with proof and its hash, NULL if not + * applicable. */ - struct TALER_AgeCommitment *age_commitment; + struct TALER_AgeCommitmentProof *age_commitment_proof; struct TALER_AgeCommitmentHash *h_age_commitment; /** @@ -441,7 +442,7 @@ reveal_cb (void *cls, return; } fc->coin_priv = coin->coin_priv; - fc->age_commitment = coin->age_commitment; + fc->age_commitment_proof = coin->age_commitment_proof; fc->h_age_commitment = coin->h_age_commitment; TALER_denom_sig_deep_copy (&fc->sig, @@ -834,7 +835,7 @@ refresh_link_run (void *cls, /* finally, use private key from withdraw sign command */ rls->rlh = TALER_EXCHANGE_link (is->exchange, coin_priv, - rms->refresh_data.melt_age_commitment, + rms->refresh_data.melt_age_commitment_proof, &link_cb, rls); @@ -1044,7 +1045,7 @@ melt_run (void *cls, { struct TALER_Amount melt_amount; struct TALER_Amount fresh_amount; - const struct TALER_AgeCommitment *age_commitment; + const struct TALER_AgeCommitmentProof *age_commitment_proof; const struct TALER_AgeCommitmentHash *h_age_commitment; const struct TALER_DenominationSignature *melt_sig; const struct TALER_EXCHANGE_DenomPublicKey *melt_denom_pub; @@ -1072,9 +1073,9 @@ melt_run (void *cls, } if (GNUNET_OK != - TALER_TESTING_get_trait_age_commitment (coin_command, - 0, - &age_commitment)) + TALER_TESTING_get_trait_age_commitment_proof (coin_command, + 0, + &age_commitment_proof)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (rms->is); @@ -1159,13 +1160,13 @@ melt_run (void *cls, rms->refresh_data.melt_amount = melt_amount; rms->refresh_data.melt_sig = *melt_sig; rms->refresh_data.melt_pk = *melt_denom_pub; - rms->refresh_data.melt_age_commitment = age_commitment; + rms->refresh_data.melt_age_commitment_proof = age_commitment_proof; rms->refresh_data.melt_h_age_commitment = h_age_commitment; rms->refresh_data.fresh_pks = rms->fresh_pks; rms->refresh_data.fresh_pks_len = num_fresh_coins; GNUNET_assert (age_restricted == - (NULL != age_commitment)); + (NULL != age_commitment_proof)); rms->rmh = TALER_EXCHANGE_melt (is->exchange, &rms->rms, @@ -1251,9 +1252,9 @@ melt_traits (void *cls, &rms->fresh_pks[index]), TALER_TESTING_make_trait_coin_priv (index, rms->melt_priv), - TALER_TESTING_make_trait_age_commitment ( + TALER_TESTING_make_trait_age_commitment_proof ( index, - rms->refresh_data.melt_age_commitment), + rms->refresh_data.melt_age_commitment_proof), TALER_TESTING_make_trait_h_age_commitment ( index, rms->refresh_data.melt_h_age_commitment), @@ -1421,9 +1422,9 @@ refresh_reveal_traits (void *cls, TALER_TESTING_make_trait_coin_priv ( index, &rrs->fresh_coins[index].coin_priv), - TALER_TESTING_make_trait_age_commitment ( + TALER_TESTING_make_trait_age_commitment_proof ( index, - rrs->fresh_coins[index].age_commitment), + rrs->fresh_coins[index].age_commitment_proof), TALER_TESTING_make_trait_h_age_commitment ( index, rrs->fresh_coins[index].h_age_commitment), diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index 3974a1057..1c24d5a6c 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -138,10 +138,10 @@ struct WithdrawState uint8_t age; /** - * If age > 0, put here the corresponding age commitment and its hash, - * respectivelly, NULL otherwise. + * If age > 0, put here the corresponding age commitment with its proof and + * its hash, respectivelly, NULL otherwise. */ - struct TALER_AgeCommitment *age_commitment; + struct TALER_AgeCommitmentProof *age_commitment_proof; struct TALER_AgeCommitmentHash *h_age_commitment; /** @@ -524,10 +524,10 @@ withdraw_cleanup (void *cls, TALER_EXCHANGE_destroy_denomination_key (ws->pk); ws->pk = NULL; } - if (NULL != ws->age_commitment) + if (NULL != ws->age_commitment_proof) { - TALER_age_commitment_free (ws->age_commitment); - ws->age_commitment = NULL; + TALER_age_commitment_proof_free (ws->age_commitment_proof); + ws->age_commitment_proof = NULL; } if (NULL != ws->h_age_commitment) { @@ -579,7 +579,7 @@ withdraw_traits (void *cls, (const char **) &ws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url ( (const char **) &ws->exchange_url), - TALER_TESTING_make_trait_age_commitment (0, ws->age_commitment), + TALER_TESTING_make_trait_age_commitment_proof (0, ws->age_commitment_proof), TALER_TESTING_make_trait_h_age_commitment (0, ws->h_age_commitment), TALER_TESTING_trait_end () }; @@ -619,12 +619,12 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, ws->age = age; if (0 < age) { - struct TALER_AgeCommitment *ac; + struct TALER_AgeCommitmentProof *acp; struct TALER_AgeCommitmentHash *hac; uint32_t seed; struct TALER_AgeMask mask; - ac = GNUNET_new (struct TALER_AgeCommitment); + acp = GNUNET_new (struct TALER_AgeCommitmentProof); hac = GNUNET_new (struct TALER_AgeCommitmentHash); seed = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); mask = TALER_extensions_age_restriction_ageMask (); @@ -634,7 +634,7 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, &mask, age, seed, - ac)) + acp)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to generate age commitment for age %d at %s\n", @@ -643,8 +643,8 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, GNUNET_assert (0); } - TALER_age_commitment_hash (ac,hac); - ws->age_commitment = ac; + TALER_age_commitment_hash (&acp->commitment,hac); + ws->age_commitment_proof = acp; ws->h_age_commitment = hac; } |