age restriction support in exchange_api_purse_create_with_deposit added

This commit is contained in:
Özgür Kesim 2022-06-27 14:11:46 +02:00
parent d2537de68c
commit 87025cfd17
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
4 changed files with 22 additions and 39 deletions

View File

@ -4516,12 +4516,10 @@ struct TALER_EXCHANGE_PurseCreateDepositHandle;
*/ */
struct TALER_EXCHANGE_PurseDeposit struct TALER_EXCHANGE_PurseDeposit
{ {
#if FIXME_OEC
/** /**
* Age commitment data. * Age commitment data, might be NULL.
*/ */
struct TALER_AgeCommitment age_commitment; const struct TALER_AgeCommitmentProof *age_commitment_proof;
#endif
/** /**
* Private key of the coin. * Private key of the coin.

View File

@ -568,18 +568,21 @@ TALER_EXCHANGE_purse_create_with_deposit (
for (unsigned int i = 0; i<num_deposits; i++) for (unsigned int i = 0; i<num_deposits; i++)
{ {
const struct TALER_EXCHANGE_PurseDeposit *deposit = &deposits[i]; const struct TALER_EXCHANGE_PurseDeposit *deposit = &deposits[i];
const struct TALER_AgeCommitmentProof *acp = deposit->age_commitment_proof;
struct Deposit *d = &pch->deposits[i]; struct Deposit *d = &pch->deposits[i];
json_t *jdeposit; json_t *jdeposit;
#if FIXME_OEC
struct TALER_AgeCommitmentHash agh; struct TALER_AgeCommitmentHash agh;
struct TALER_AgeCommitmentHash *aghp = NULL; struct TALER_AgeCommitmentHash *aghp = NULL;
struct TALER_AgeAttestation attest; struct TALER_AgeAttestation attest;
struct TALER_AgeAttestation *attestp = NULL;
TALER_age_commitment_hash (&deposit->age_commitment, if (NULL != acp)
{
TALER_age_commitment_hash (&acp->commitment,
&agh); &agh);
aghp = &agh; aghp = &agh;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_age_commitment_attest (&deposit->age_proof, TALER_age_commitment_attest (acp,
min_age, min_age,
&attest)) &attest))
{ {
@ -589,7 +592,7 @@ TALER_EXCHANGE_purse_create_with_deposit (
GNUNET_free (pch); GNUNET_free (pch);
return NULL; return NULL;
} }
#endif }
d->contribution = deposit->amount; d->contribution = deposit->amount;
d->h_denom_pub = deposit->h_denom_pub; d->h_denom_pub = deposit->h_denom_pub;
GNUNET_CRYPTO_eddsa_key_get_public (&deposit->coin_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&deposit->coin_priv.eddsa_priv,
@ -601,14 +604,12 @@ TALER_EXCHANGE_purse_create_with_deposit (
&deposit->coin_priv, &deposit->coin_priv,
&d->coin_sig); &d->coin_sig);
jdeposit = GNUNET_JSON_PACK ( jdeposit = GNUNET_JSON_PACK (
#if FIXME_OEC
GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_data_auto ("h_age_commitment", GNUNET_JSON_pack_data_auto ("h_age_commitment",
aghp)), aghp)),
GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_data_auto ("age_attestation", GNUNET_JSON_pack_data_auto ("age_attestation",
&attest)), attestp)),
#endif
TALER_JSON_pack_amount ("amount", TALER_JSON_pack_amount ("amount",
&deposit->amount), &deposit->amount),
GNUNET_JSON_pack_data_auto ("denom_pub_hash", GNUNET_JSON_pack_data_auto ("denom_pub_hash",

View File

@ -207,7 +207,6 @@ deposit_run (void *cls,
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_CoinSpendPrivateKeyP *coin_priv;
const struct TALER_AgeCommitmentProof *age_commitment_proof = 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_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *denom_pub_sig; const struct TALER_DenominationSignature *denom_pub_sig;
@ -242,14 +241,7 @@ deposit_run (void *cls,
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
if (NULL != age_commitment_proof) pd->age_commitment_proof = age_commitment_proof;
{
TALER_age_commitment_hash (&age_commitment_proof->commitment,
&h_age_commitment);
}
#if FIXME_OEC
pd->age_commitment = *h_age_commitment;
#endif
pd->denom_sig = *denom_pub_sig; pd->denom_sig = *denom_pub_sig;
pd->coin_priv = *coin_priv; pd->coin_priv = *coin_priv;
pd->amount = cr->deposit_with_fee; pd->amount = cr->deposit_with_fee;

View File

@ -286,7 +286,6 @@ deposit_run (void *cls,
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_CoinSpendPrivateKeyP *coin_priv;
const struct TALER_AgeCommitmentProof *age_commitment_proof = 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_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *denom_pub_sig; const struct TALER_DenominationSignature *denom_pub_sig;
@ -321,14 +320,7 @@ deposit_run (void *cls,
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
if (NULL != age_commitment_proof) pd->age_commitment_proof = age_commitment_proof;
{
TALER_age_commitment_hash (&age_commitment_proof->commitment,
&h_age_commitment);
}
#if FIXME_OEC
pd->age_commitment = *h_age_commitment;
#endif
pd->denom_sig = *denom_pub_sig; pd->denom_sig = *denom_pub_sig;
pd->coin_priv = *coin_priv; pd->coin_priv = *coin_priv;
pd->amount = cr->deposit_with_fee; pd->amount = cr->deposit_with_fee;