[age-withdraw] reveal works, tested.

Tests for age-withdraw and the reveal now work for both, RSA and CS.
This commit is contained in:
Özgür Kesim 2023-07-26 17:36:13 +02:00
parent 0f17931b10
commit d208041240
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
6 changed files with 43 additions and 37 deletions

View File

@ -876,7 +876,7 @@ sign_and_do_age_withdraw (
/* Prepare the hashes of the coins for insertion */
for (uint32_t i = 0; i<awc->num_coins; i++)
{
TALER_coin_ev_hash (&awc->coin_evs[i],
TALER_coin_ev_hash (&awc->coin_evs[TALER_CNC_KAPPA * i + noreveal_index],
&awc->denom_hs[i],
&h_coin_evs[i]);
}

View File

@ -152,10 +152,10 @@ parse_age_withdraw_reveal_json (
json_array_foreach (array, k, value)
{
struct TALER_PlanchetMasterSecretP *sec =
struct TALER_PlanchetMasterSecretP *secret =
&actx->disclosed_coin_secrets[2 * idx + k];
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto (NULL, sec),
GNUNET_JSON_spec_fixed_auto (NULL, secret),
GNUNET_JSON_spec_end ()
};
@ -312,10 +312,10 @@ calculate_blinded_hash (
/* Next: calculate planchet */
{
struct TALER_CoinPubHashP c_hash;
struct TALER_PlanchetDetail detail;
struct TALER_CoinSpendPrivateKeyP coin_priv;
union TALER_DenominationBlindingKeyP bks;
struct TALER_CoinPubHashP c_hash = {0};
struct TALER_PlanchetDetail detail = {0};
struct TALER_CoinSpendPrivateKeyP coin_priv = {0};
union TALER_DenominationBlindingKeyP bks = {0};
struct TALER_ExchangeWithdrawValues alg_values = {
.cipher = denom_key->denom_pub.cipher,
};
@ -324,24 +324,23 @@ calculate_blinded_hash (
{
struct TALER_CsNonce nonce;
TALER_cs_withdraw_nonce_derive (
secret,
&nonce);
TALER_cs_withdraw_nonce_derive (secret,
&nonce);
{
enum TALER_ErrorCode ec;
struct TEH_CsDeriveData cdd = {
.h_denom_pub = &denom_key->h_denom_pub,
.nonce = &nonce,
};
ec = TEH_keys_denomination_cs_r_pub (&cdd,
false,
&alg_values.details.
cs_values);
/* FIXME Handle error? */
GNUNET_assert (TALER_EC_NONE == ec);
GNUNET_assert (TALER_EC_NONE ==
TEH_keys_denomination_cs_r_pub (
&cdd,
false,
&alg_values.details.cs_values));
}
detail.blinded_planchet.details.cs_blinded_planchet.nonce = nonce;
}
TALER_planchet_blinding_secret_create (secret,
@ -374,6 +373,7 @@ calculate_blinded_hash (
ret = TALER_coin_ev_hash (&detail.blinded_planchet,
&denom_key->h_denom_pub,
bch);
GNUNET_assert (GNUNET_OK == ret);
}
@ -504,7 +504,7 @@ verify_commitment_and_max_age (
}
}
return ret;
return GNUNET_OK;
}
@ -526,7 +526,7 @@ reply_age_withdraw_reveal_success (
for (unsigned int i = 0; i < commitment->num_coins; i++)
{
json_t *obj = GNUNET_JSON_PACK (
TALER_JSON_pack_blinded_denom_sig ("ev_sig",
TALER_JSON_pack_blinded_denom_sig (NULL,
&commitment->denom_sigs[i]));
GNUNET_assert (0 ==
json_array_append_new (list,

View File

@ -346,6 +346,7 @@ reserve_age_withdraw_ok (
return GNUNET_SYSERR;
}
awbh->callback (awbh->callback_cls,
&response);
/* make sure the callback isn't called again */
@ -780,7 +781,7 @@ copy_results (
const struct TALER_EXCHANGE_AgeWithdrawBlindedResponse *awbr)
{
struct TALER_EXCHANGE_AgeWithdrawHandle *awh = cls;
uint8_t idx = awbr->details.ok.noreveal_index;
uint8_t k = awbr->details.ok.noreveal_index;
struct TALER_EXCHANGE_AgeWithdrawCoinPrivateDetails details[awh->num_coins];
struct TALER_BlindedCoinHashP blinded_coin_hs[awh->num_coins];
struct TALER_EXCHANGE_AgeWithdrawResponse resp = {
@ -797,9 +798,9 @@ copy_results (
for (size_t n = 0; n< awh->num_coins; n++)
{
details[n] = awh->coin_data[n].coin_candidates[idx].details;
details[n].planchet = awh->coin_data[n].planchet_details[idx];
blinded_coin_hs[n] = awh->coin_data[n].coin_candidates[idx].blinded_coin_h;
details[n] = awh->coin_data[n].coin_candidates[k].details;
details[n].planchet = awh->coin_data[n].planchet_details[k];
blinded_coin_hs[n] = awh->coin_data[n].coin_candidates[k].blinded_coin_h;
}
awh->callback (awh->callback_cls,
@ -824,9 +825,9 @@ call_age_withdraw_blinded (
for (size_t n = 0; n < awh->num_coins; n++)
{
blinded_input[n].denom_pub = &awh->coin_data[n].denom_pub;
for (uint8_t i = 0; i < TALER_CNC_KAPPA; i++)
blinded_input[n].planchet_details[i] =
awh->coin_data[n].planchet_details[i];
for (uint8_t k = 0; k < TALER_CNC_KAPPA; k++)
blinded_input[n].planchet_details[k] =
awh->coin_data[n].planchet_details[k];
}
awh->procotol_handle =
@ -918,6 +919,8 @@ csr_withdraw_done (
bool success = false;
/* Complete the initialization of the coin with CS denomination */
can->details.alg_values = csrr->details.ok.alg_values;
GNUNET_assert (can->details.alg_values.cipher
== TALER_DENOMINATION_CS);
TALER_planchet_setup_coin_priv (&can->secret,
&can->details.alg_values,
&can->details.coin_priv);
@ -950,7 +953,6 @@ csr_withdraw_done (
TALER_EXCHANGE_age_withdraw_cancel (awh);
break;
}
success = true;
} while(0);
@ -1023,7 +1025,6 @@ prepare_coins (
struct TALER_PlanchetDetail *planchet = &cd->planchet_details[k];
can->secret = input->secrets[k];
/* Derive the age restriction from the given secret and
* the maximum age */
FAIL_IF (GNUNET_OK !=
@ -1063,6 +1064,8 @@ prepare_coins (
}
case TALER_DENOMINATION_CS:
{
can->details.alg_values.cipher = TALER_DENOMINATION_CS;
struct CSRClosure *cls = &cd->csr_cls[k];
/**
* Save the handler and the denomination for the callback

View File

@ -118,17 +118,18 @@ age_withdraw_reveal_ok (
{
struct TALER_BlindedDenominationSignature denom_sigs[awrh->num_coins];
json_t *j_sig;
size_t n;
/* Reconstruct the coins and unblind the signatures */
for (size_t n = 0; n < awrh->num_coins; n++)
json_array_foreach (j_sigs, n, j_sig)
{
json_t *j_sig = json_array_get (j_sigs, n);
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("", &denom_sigs[n]),
TALER_JSON_spec_blinded_denom_sig (NULL,
&denom_sigs[n]),
GNUNET_JSON_spec_end ()
};
GNUNET_assert (NULL != j_sig);
if (GNUNET_OK != GNUNET_JSON_parse (j_sig,
spec,
NULL, NULL))
@ -136,6 +137,7 @@ age_withdraw_reveal_ok (
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
}
response.details.ok.num_sigs = awrh->num_coins;

View File

@ -260,7 +260,7 @@ run (void *cls,
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-kyc-1",
"EUR:30.02"),
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-1",
"check-create-reserve-kyc-1",
"EUR:30.02",
cred.user42_payto,
cred.exchange_payto,
@ -295,10 +295,9 @@ run (void *cls,
8,
MHD_HTTP_OK,
"EUR:10",
"EUR:5",
"EUR:10",
"EUR:5",
NULL),
/* FIXME[oec]: failing */
TALER_TESTING_cmd_age_withdraw_reveal ("age-withdraw-coins-reveal-1",
"age-withdraw-coins-1",
MHD_HTTP_OK),

View File

@ -578,9 +578,9 @@ age_withdraw_reveal_cb (
case MHD_HTTP_OK:
{
const struct AgeWithdrawState *aws = awrs->aws;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Got age-withdraw reveal success!\n");
GNUNET_assert (awrs->num_coins == response->details.ok.num_sigs);
awrs->denom_sigs = GNUNET_new_array (awrs->num_coins,
struct TALER_DenominationSignature);
for (size_t n = 0; n < awrs->num_coins; n++)
TALER_denom_sig_unblind (&awrs->denom_sigs[n],
&response->details.ok.blinded_denom_sigs[n],
@ -588,6 +588,8 @@ age_withdraw_reveal_cb (
&aws->coin_outputs[n].details.h_coin_pub,
&aws->coin_outputs[n].details.alg_values,
&aws->coin_inputs[n].denom_pub->key);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"age-withdraw reveal success!\n");
}
break;
case MHD_HTTP_NOT_FOUND: