-towards reveal response handling in agew-withdraw-reveal
This commit is contained in:
parent
c8250cae25
commit
65c861027a
@ -23,6 +23,7 @@
|
|||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include <microhttpd.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include "taler-exchange-httpd_responses.h"
|
#include "taler-exchange-httpd_responses.h"
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
@ -1091,7 +1092,7 @@ TEH_RESPONSE_reply_reserve_age_restriction_required (
|
|||||||
{
|
{
|
||||||
return TALER_MHD_REPLY_JSON_PACK (
|
return TALER_MHD_REPLY_JSON_PACK (
|
||||||
connection,
|
connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_CONFLICT,
|
||||||
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_RESERVES_AGE_RESTRICTION_REQUIRED),
|
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_RESERVES_AGE_RESTRICTION_REQUIRED),
|
||||||
GNUNET_JSON_pack_uint64 ("maximum_allowed_age",
|
GNUNET_JSON_pack_uint64 ("maximum_allowed_age",
|
||||||
maximum_allowed_age));
|
maximum_allowed_age));
|
||||||
|
@ -2799,6 +2799,18 @@ struct TALER_EXCHANGE_AgeWithdrawResponse
|
|||||||
*/
|
*/
|
||||||
struct TALER_AgeWithdrawCommitmentHashP h_commitment;
|
struct TALER_AgeWithdrawCommitmentHashP h_commitment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The algorithm specific values (for CS) need for the coins that were
|
||||||
|
* retrieved from /csr-withdraw.
|
||||||
|
*/
|
||||||
|
struct TALER_ExchangeWithdrawValues *alg_values;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of elements in @e alg_values, same as number coin candidates.from
|
||||||
|
* the request.
|
||||||
|
*/
|
||||||
|
size_t num_alg_values;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature of the exchange over the origina TALER_AgeWithdrawRequestPS
|
* Signature of the exchange over the origina TALER_AgeWithdrawRequestPS
|
||||||
*/
|
*/
|
||||||
@ -2871,11 +2883,9 @@ TALER_EXCHANGE_age_withdraw_cancel (
|
|||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_AgeWithdrawRevealHandle;
|
struct TALER_EXCHANGE_AgeWithdrawRevealHandle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* The response from a /age-withdraw/$ACH/reveal request
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct TALER_EXCHANGE_AgeWithdrawRevealResponse
|
struct TALER_EXCHANGE_AgeWithdrawRevealResponse
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -2904,7 +2914,7 @@ struct TALER_EXCHANGE_AgeWithdrawRevealResponse
|
|||||||
* have the same length) in which the original age-withdraw request
|
* have the same length) in which the original age-withdraw request
|
||||||
* specified the respective denomination keys.
|
* specified the respective denomination keys.
|
||||||
*/
|
*/
|
||||||
const struct TALER_EXCHANGE_RevealedCoinInfo *coins;
|
const struct TALER_EXCHANGE_RevealedCoinInfo *revealed_coins;
|
||||||
|
|
||||||
} ok;
|
} ok;
|
||||||
/* FIXME[oec]: error cases */
|
/* FIXME[oec]: error cases */
|
||||||
@ -2929,8 +2939,9 @@ typedef void
|
|||||||
* @param curl_ctx The curl context
|
* @param curl_ctx The curl context
|
||||||
* @param exchange_url The base url of the exchange
|
* @param exchange_url The base url of the exchange
|
||||||
* @param reserve_priv The pivate key to the reserve
|
* @param reserve_priv The pivate key to the reserve
|
||||||
* @param num_coins The number of elements in @e coin_inputs
|
* @param num_coins The number of elements in @e coin_inputs and @e alg_values
|
||||||
* @param coins_input The input for the coins to withdraw
|
* @param coins_input The input for the coins to withdraw, same as in the previous call to /age-withdraw
|
||||||
|
* @param alg_values The algorithm specific parameters per coin, from the result to the previous call to /age-withdraw
|
||||||
* @param noreveal_index The index into each of the kappa coin candidates, that should not be revealed to the exchange
|
* @param noreveal_index The index into each of the kappa coin candidates, that should not be revealed to the exchange
|
||||||
* @param h_commitment The commmitment from the previous call to /age-withdraw
|
* @param h_commitment The commmitment from the previous call to /age-withdraw
|
||||||
* @param res_cb A callback for the result, maybe NULL
|
* @param res_cb A callback for the result, maybe NULL
|
||||||
@ -2945,6 +2956,7 @@ TALER_EXCHANGE_age_withdraw_reveal (
|
|||||||
size_t num_coins,
|
size_t num_coins,
|
||||||
const struct TALER_EXCHANGE_AgeWithdrawCoinInput coins_input[static
|
const struct TALER_EXCHANGE_AgeWithdrawCoinInput coins_input[static
|
||||||
num_coins],
|
num_coins],
|
||||||
|
const struct TALER_ExchangeWithdrawValues alg_values[static num_coins],
|
||||||
uint8_t noreveal_index,
|
uint8_t noreveal_index,
|
||||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||||
TALER_EXCHANGE_AgeWithdrawRevealCallback res_cb,
|
TALER_EXCHANGE_AgeWithdrawRevealCallback res_cb,
|
||||||
|
@ -50,9 +50,13 @@ struct TALER_EXCHANGE_AgeWithdrawRevealHandle
|
|||||||
/* Number of coins */
|
/* Number of coins */
|
||||||
size_t num_coins;
|
size_t num_coins;
|
||||||
|
|
||||||
/* The n*kappa coin secrets from the age-withdraw commitment */
|
/* The @e num_coins * kappa coin secrets from the age-withdraw commitment */
|
||||||
const struct TALER_EXCHANGE_AgeWithdrawCoinInput *coins_input;
|
const struct TALER_EXCHANGE_AgeWithdrawCoinInput *coins_input;
|
||||||
|
|
||||||
|
/* The @e num_coins algorithm- and coin-specific parameters from the
|
||||||
|
* previous call to /age-withdraw. */
|
||||||
|
const struct TALER_ExchangeWithdrawValues *alg_values;
|
||||||
|
|
||||||
/* The curl context for the request */
|
/* The curl context for the request */
|
||||||
struct GNUNET_CURL_Context *curl_ctx;
|
struct GNUNET_CURL_Context *curl_ctx;
|
||||||
|
|
||||||
@ -83,17 +87,20 @@ struct TALER_EXCHANGE_AgeWithdrawRevealHandle
|
|||||||
*
|
*
|
||||||
* @param awrh operation handle
|
* @param awrh operation handle
|
||||||
* @param j_response reply from the exchange
|
* @param j_response reply from the exchange
|
||||||
|
* @param num_coins The (expected) number of revealed coins
|
||||||
|
* @param[in,out] revealed_coins The @e num_coins revealed coins to populate
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
|
||||||
*/
|
*/
|
||||||
static enum GNUNET_GenericReturnValue
|
static enum GNUNET_GenericReturnValue
|
||||||
age_withdraw_reveal_ok (
|
age_withdraw_reveal_ok (
|
||||||
struct TALER_EXCHANGE_AgeWithdrawRevealHandle *awrh,
|
struct TALER_EXCHANGE_AgeWithdrawRevealHandle *awrh,
|
||||||
const json_t *j_response)
|
const json_t *j_response,
|
||||||
|
size_t num_coins,
|
||||||
|
struct TALER_EXCHANGE_RevealedCoinInfo revealed_coins[static num_coins])
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_AgeWithdrawRevealResponse response = {
|
struct TALER_EXCHANGE_AgeWithdrawRevealResponse response = {
|
||||||
.hr.reply = j_response,
|
.hr.reply = j_response,
|
||||||
.hr.http_status = MHD_HTTP_OK,
|
.hr.http_status = MHD_HTTP_OK,
|
||||||
.details.ok.num_coins = awrh->num_coins
|
|
||||||
};
|
};
|
||||||
const json_t *j_sigs;
|
const json_t *j_sigs;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
@ -111,18 +118,22 @@ age_withdraw_reveal_ok (
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (awrh->num_coins != json_array_size (j_sigs))
|
GNUNET_assert (num_coins == awrh->num_coins);
|
||||||
|
if (num_coins != json_array_size (j_sigs))
|
||||||
{
|
{
|
||||||
/* Number of coins generated does not match our expectation */
|
/* Number of coins generated does not match our expectation */
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t n = 0; n < awrh->num_coins; n++)
|
|
||||||
|
for (size_t n = 0; n < num_coins; n++)
|
||||||
{
|
{
|
||||||
// TODO[oec] extract the individual coins.
|
// TODO[oec] extract the individual coins.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.details.ok.num_coins = num_coins;
|
||||||
|
response.details.ok.revealed_coins = revealed_coins;
|
||||||
awrh->callback (awrh->callback_cls,
|
awrh->callback (awrh->callback_cls,
|
||||||
&response);
|
&response);
|
||||||
/* make sure the callback isn't called again */
|
/* make sure the callback isn't called again */
|
||||||
@ -160,9 +171,15 @@ handle_age_withdraw_reveal_finished (
|
|||||||
awr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
|
awr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_OK:
|
case MHD_HTTP_OK:
|
||||||
if (GNUNET_OK !=
|
{
|
||||||
age_withdraw_reveal_ok (awrh,
|
enum GNUNET_GenericReturnValue ret;
|
||||||
j_response))
|
struct TALER_EXCHANGE_RevealedCoinInfo revealed_coins[awrh->num_coins];
|
||||||
|
|
||||||
|
ret = age_withdraw_reveal_ok (awrh,
|
||||||
|
j_response,
|
||||||
|
awrh->num_coins,
|
||||||
|
revealed_coins);
|
||||||
|
if (GNUNET_OK != ret)
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
awr.hr.http_status = 0;
|
awr.hr.http_status = 0;
|
||||||
@ -172,6 +189,7 @@ handle_age_withdraw_reveal_finished (
|
|||||||
GNUNET_assert (NULL == awrh->callback);
|
GNUNET_assert (NULL == awrh->callback);
|
||||||
TALER_EXCHANGE_age_withdraw_reveal_cancel (awrh);
|
TALER_EXCHANGE_age_withdraw_reveal_cancel (awrh);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
|
case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
|
||||||
/* only validate reply is well-formed */
|
/* only validate reply is well-formed */
|
||||||
{
|
{
|
||||||
@ -396,6 +414,7 @@ TALER_EXCHANGE_age_withdraw_reveal (
|
|||||||
size_t num_coins,
|
size_t num_coins,
|
||||||
const struct TALER_EXCHANGE_AgeWithdrawCoinInput coins_input[static
|
const struct TALER_EXCHANGE_AgeWithdrawCoinInput coins_input[static
|
||||||
num_coins],
|
num_coins],
|
||||||
|
const struct TALER_ExchangeWithdrawValues alg_values[static num_coins],
|
||||||
uint8_t noreveal_index,
|
uint8_t noreveal_index,
|
||||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||||
TALER_EXCHANGE_AgeWithdrawRevealCallback reveal_cb,
|
TALER_EXCHANGE_AgeWithdrawRevealCallback reveal_cb,
|
||||||
@ -410,6 +429,7 @@ TALER_EXCHANGE_age_withdraw_reveal (
|
|||||||
awrh->h_commitment = *h_commitment;
|
awrh->h_commitment = *h_commitment;
|
||||||
awrh->num_coins = num_coins;
|
awrh->num_coins = num_coins;
|
||||||
awrh->coins_input = coins_input;
|
awrh->coins_input = coins_input;
|
||||||
|
awrh->alg_values = alg_values;
|
||||||
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -429,6 +449,7 @@ TALER_EXCHANGE_age_withdraw_reveal_cancel (
|
|||||||
{
|
{
|
||||||
/* FIXME[oec] */
|
/* FIXME[oec] */
|
||||||
(void) awrh;
|
(void) awrh;
|
||||||
|
#pragma message "need to implement TALER_EXCHANGE_age_withdraw_reveal_cancel"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user