WiP: age-withdraw: added exchange confirmation signature
This commit is contained in:
parent
f7a77e4e37
commit
c03ab6d4e4
@ -5779,7 +5779,7 @@ TALER_age_commitment_attest (
|
||||
|
||||
|
||||
/**
|
||||
* @brief Verify the attestation for an given age and age commitment
|
||||
* @brief Verify the attestation for a given age and age commitment
|
||||
*
|
||||
* @param commitment The age commitment that went into the attestation. Only the public keys are needed.
|
||||
* @param age Age (not age group) for which the an attestation should be done
|
||||
@ -5806,7 +5806,7 @@ TALER_age_commitment_verify (
|
||||
enum TALER_ErrorCode
|
||||
TALER_exchange_online_age_withdraw_confirmation_sign (
|
||||
TALER_ExchangeSignCallback scb,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *awch,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||
uint32_t noreveal_index,
|
||||
struct TALER_ExchangePublicKeyP *pub,
|
||||
struct TALER_ExchangeSignatureP *sig);
|
||||
|
@ -359,7 +359,61 @@ TALER_exchange_online_melt_confirmation_verify (
|
||||
}
|
||||
|
||||
|
||||
/* TODO:oec: add signature for age-withdraw and reveal */
|
||||
GNUNET_NETWORK_STRUCT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief Format of the block signed by the Exchange in response to a
|
||||
* successful "/reserves/$RESERVE_PUB/age-withdraw" request. Hereby the
|
||||
* exchange affirms that the commitment along with the maximum age group and
|
||||
* the amount were accepted. This also commits the exchange to a particular
|
||||
* index to not be revealed during the reveal.
|
||||
*/
|
||||
struct TALER_AgeWithdrawConfirmationPS
|
||||
{
|
||||
/**
|
||||
* Purpose is #TALER_SIGNATURE_EXCHANGE_CONFIRM_AGE_WITHDRAW. Signed by a
|
||||
* `struct TALER_ExchangePublicKeyP` using EdDSA.
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||
|
||||
/**
|
||||
* Commitment made in the /reserves/$RESERVE_PUB/age-withdraw.
|
||||
*/
|
||||
struct TALER_AgeWithdrawCommitmentHashP h_commitment GNUNET_PACKED;
|
||||
|
||||
/**
|
||||
* Index that the client will not have to reveal, in NBO.
|
||||
* Must be smaller than #TALER_CNC_KAPPA.
|
||||
*/
|
||||
uint32_t noreveal_index GNUNET_PACKED;
|
||||
|
||||
};
|
||||
|
||||
GNUNET_NETWORK_STRUCT_END
|
||||
|
||||
enum TALER_ErrorCode
|
||||
TALER_exchange_online_age_withdraw_confirmation_sign (
|
||||
TALER_ExchangeSignCallback scb,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||
uint32_t noreveal_index,
|
||||
struct TALER_ExchangePublicKeyP *pub,
|
||||
struct TALER_ExchangeSignatureP *sig)
|
||||
{
|
||||
|
||||
struct TALER_AgeWithdrawConfirmationPS confirm = {
|
||||
.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_AGE_WITHDRAW),
|
||||
.purpose.size = htonl (sizeof (confirm)),
|
||||
.h_commitment = *h_commitment,
|
||||
.noreveal_index = htonl (noreveal_index)
|
||||
};
|
||||
|
||||
return scb (&confirm.purpose,
|
||||
pub,
|
||||
sig);
|
||||
}
|
||||
|
||||
|
||||
/* TODO:oec: add signature for age-withdraw, age-reveal */
|
||||
|
||||
GNUNET_NETWORK_STRUCT_BEGIN
|
||||
|
||||
|
@ -604,6 +604,92 @@ TALER_wallet_withdraw_verify (
|
||||
}
|
||||
|
||||
|
||||
GNUNET_NETWORK_STRUCT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief Format used for to generate the signature on a request to
|
||||
* age-withdraw from a reserve.
|
||||
*/
|
||||
struct TALER_AgeWithdrawRequestPS
|
||||
{
|
||||
|
||||
/**
|
||||
* Purpose must be #TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW.
|
||||
* Used with an EdDSA signature of a `struct TALER_ReservePublicKeyP`.
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||
|
||||
/**
|
||||
* Hash of the commitment of n*kappa coins
|
||||
*/
|
||||
struct TALER_AgeWithdrawCommitmentHashP h_commitment GNUNET_PACKED;
|
||||
|
||||
/**
|
||||
* Value of the coin being exchanged (matching the denomination key)
|
||||
* plus the transaction fee. We include this in what is being
|
||||
* signed so that we can verify a reserve's remaining total balance
|
||||
* without needing to access the respective denomination key
|
||||
* information each time.
|
||||
*/
|
||||
struct TALER_AmountNBO amount_with_fee;
|
||||
|
||||
/**
|
||||
* Maximum age group that the coins are going to be restricted to.
|
||||
*/
|
||||
uint32_t max_age_group;
|
||||
};
|
||||
|
||||
|
||||
GNUNET_NETWORK_STRUCT_END
|
||||
|
||||
void
|
||||
TALER_wallet_age_withdraw_sign (
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||
const struct TALER_Amount *amount_with_fee,
|
||||
uint32_t max_age_group,
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||
struct TALER_ReserveSignatureP *reserve_sig)
|
||||
{
|
||||
struct TALER_AgeWithdrawRequestPS req = {
|
||||
.purpose.size = htonl (sizeof (req)),
|
||||
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_AGE_WITHDRAW),
|
||||
.h_commitment = *h_commitment,
|
||||
.max_age_group = max_age_group
|
||||
};
|
||||
|
||||
TALER_amount_hton (&req.amount_with_fee,
|
||||
amount_with_fee);
|
||||
GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
|
||||
&req,
|
||||
&reserve_sig->eddsa_signature);
|
||||
}
|
||||
|
||||
|
||||
enum GNUNET_GenericReturnValue
|
||||
TALER_wallet_age_withdraw_verify (
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||
const struct TALER_Amount *amount_with_fee,
|
||||
uint32_t max_age_group,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_ReserveSignatureP *reserve_sig)
|
||||
{
|
||||
struct TALER_AgeWithdrawRequestPS awsrd = {
|
||||
.purpose.size = htonl (sizeof (awsrd)),
|
||||
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_AGE_WITHDRAW),
|
||||
.h_commitment = *h_commitment,
|
||||
.max_age_group = max_age_group
|
||||
};
|
||||
|
||||
TALER_amount_hton (&awsrd.amount_with_fee,
|
||||
amount_with_fee);
|
||||
return GNUNET_CRYPTO_eddsa_verify (
|
||||
TALER_SIGNATURE_WALLET_RESERVE_AGE_WITHDRAW,
|
||||
&awsrd,
|
||||
&reserve_sig->eddsa_signature,
|
||||
&reserve_pub->eddsa_pub);
|
||||
}
|
||||
|
||||
|
||||
GNUNET_NETWORK_STRUCT_BEGIN
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user