summaryrefslogtreecommitdiff
path: root/src/util/wallet_signatures.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/wallet_signatures.c')
-rw-r--r--src/util/wallet_signatures.c136
1 files changed, 76 insertions, 60 deletions
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
index 221865e73..0b6ab5432 100644
--- a/src/util/wallet_signatures.c
+++ b/src/util/wallet_signatures.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2021, 2022 Taler Systems SA
+ Copyright (C) 2021-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -17,10 +17,12 @@
* @file wallet_signatures.c
* @brief Utility functions for Taler wallet signatures
* @author Christian Grothoff
+ * @author Özgür Kesim
*/
#include "platform.h"
#include "taler_util.h"
#include "taler_signatures.h"
+#include <gnunet/gnunet_common.h>
GNUNET_NETWORK_STRUCT_BEGIN
@@ -109,6 +111,12 @@ struct TALER_DepositRequestPS
*/
struct TALER_MerchantPublicKeyP merchant;
+ /**
+ * Hash over a JSON containing data provided by the
+ * wallet to complete the contract upon payment.
+ */
+ struct GNUNET_HashCode wallet_data_hash;
+
};
GNUNET_NETWORK_STRUCT_END
@@ -119,6 +127,7 @@ TALER_wallet_deposit_sign (
const struct TALER_Amount *deposit_fee,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct GNUNET_HashCode *wallet_data_hash,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_ExtensionPolicyHashP *h_policy,
const struct TALER_DenominationHashP *h_denom_pub,
@@ -139,6 +148,8 @@ TALER_wallet_deposit_sign (
.merchant = *merchant_pub
};
+ if (NULL != wallet_data_hash)
+ dr.wallet_data_hash = *wallet_data_hash;
if (NULL != h_age_commitment)
dr.h_age_commitment = *h_age_commitment;
if (NULL != h_policy)
@@ -159,6 +170,7 @@ TALER_wallet_deposit_verify (
const struct TALER_Amount *deposit_fee,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct GNUNET_HashCode *wallet_data_hash,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_ExtensionPolicyHashP *h_policy,
const struct TALER_DenominationHashP *h_denom_pub,
@@ -177,10 +189,10 @@ TALER_wallet_deposit_verify (
.wallet_timestamp = GNUNET_TIME_timestamp_hton (wallet_timestamp),
.refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline),
.merchant = *merchant_pub,
- .h_age_commitment = {{{0}}},
- .h_policy = {{{0}}}
};
+ if (NULL != wallet_data_hash)
+ dr.wallet_data_hash = *wallet_data_hash;
if (NULL != h_age_commitment)
dr.h_age_commitment = *h_age_commitment;
if (NULL != h_policy)
@@ -308,7 +320,7 @@ struct TALER_RecoupRequestPS
/**
* Blinding factor that was used to withdraw the coin.
*/
- union TALER_DenominationBlindingKeyP coin_blind;
+ union GNUNET_CRYPTO_BlindingSecretP coin_blind;
};
@@ -318,7 +330,7 @@ GNUNET_NETWORK_STRUCT_END
enum GNUNET_GenericReturnValue
TALER_wallet_recoup_verify (
const struct TALER_DenominationHashP *h_denom_pub,
- const union TALER_DenominationBlindingKeyP *coin_bks,
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_bks,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig)
{
@@ -339,7 +351,7 @@ TALER_wallet_recoup_verify (
void
TALER_wallet_recoup_sign (
const struct TALER_DenominationHashP *h_denom_pub,
- const union TALER_DenominationBlindingKeyP *coin_bks,
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_bks,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig)
{
@@ -359,7 +371,7 @@ TALER_wallet_recoup_sign (
enum GNUNET_GenericReturnValue
TALER_wallet_recoup_refresh_verify (
const struct TALER_DenominationHashP *h_denom_pub,
- const union TALER_DenominationBlindingKeyP *coin_bks,
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_bks,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig)
{
@@ -380,7 +392,7 @@ TALER_wallet_recoup_refresh_verify (
void
TALER_wallet_recoup_refresh_sign (
const struct TALER_DenominationHashP *h_denom_pub,
- const union TALER_DenominationBlindingKeyP *coin_bks,
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_bks,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig)
{
@@ -620,9 +632,9 @@ struct TALER_AgeWithdrawRequestPS
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
- * Hash of the commitment of n*kappa coins
+ * The reserve's public key
*/
- struct TALER_AgeWithdrawCommitmentHashP h_commitment GNUNET_PACKED;
+ struct TALER_ReservePublicKeyP reserve_pub;
/**
* Value of the coin being exchanged (matching the denomination key)
@@ -634,9 +646,19 @@ struct TALER_AgeWithdrawRequestPS
struct TALER_AmountNBO amount_with_fee;
/**
+ * Running SHA512 hash of the commitment of n*kappa coins
+ */
+ struct TALER_AgeWithdrawCommitmentHashP h_commitment;
+
+ /**
+ * The mask that defines the age groups. MUST be the same for all denominations.
+ */
+ struct TALER_AgeMask mask;
+
+ /**
* Maximum age group that the coins are going to be restricted to.
*/
- uint32_t max_age_group;
+ uint8_t max_age_group;
};
@@ -646,7 +668,8 @@ 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_AgeMask *mask,
+ uint8_t max_age,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig)
{
@@ -654,9 +677,12 @@ TALER_wallet_age_withdraw_sign (
.purpose.size = htonl (sizeof (req)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_AGE_WITHDRAW),
.h_commitment = *h_commitment,
- .max_age_group = max_age_group
+ .mask = *mask,
+ .max_age_group = TALER_get_age_group (mask, max_age)
};
+ GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
+ &req.reserve_pub.eddsa_pub);
TALER_amount_hton (&req.amount_with_fee,
amount_with_fee);
GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
@@ -669,15 +695,18 @@ 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_AgeMask *mask,
+ uint8_t max_age,
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),
+ .reserve_pub = *reserve_pub,
.h_commitment = *h_commitment,
- .max_age_group = max_age_group
+ .mask = *mask,
+ .max_age_group = TALER_get_age_group (mask, max_age)
};
TALER_amount_hton (&awsrd.amount_with_fee,
@@ -761,9 +790,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Response by which a wallet requests a full
- * reserve history and indicates it is willing
- * to pay for it.
+ * Response by which a wallet requests a reserve history.
*/
struct TALER_ReserveHistoryRequestPS
{
@@ -774,36 +801,27 @@ struct TALER_ReserveHistoryRequestPS
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
- * When did the wallet make the request.
- */
- struct GNUNET_TIME_TimestampNBO request_timestamp;
-
- /**
- * How much does the exchange charge for the history?
+ * Which entries to exclude. Only return above this offset.
*/
- struct TALER_AmountNBO history_fee;
+ uint64_t start_off;
};
-
GNUNET_NETWORK_STRUCT_END
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_history_verify (
- const struct GNUNET_TIME_Timestamp ts,
- const struct TALER_Amount *history_fee,
+ uint64_t start_off,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig)
{
struct TALER_ReserveHistoryRequestPS rhr = {
.purpose.size = htonl (sizeof (rhr)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_HISTORY),
- .request_timestamp = GNUNET_TIME_timestamp_hton (ts)
+ .start_off = GNUNET_htonll (start_off)
};
- TALER_amount_hton (&rhr.history_fee,
- history_fee);
return GNUNET_CRYPTO_eddsa_verify (
TALER_SIGNATURE_WALLET_RESERVE_HISTORY,
&rhr,
@@ -814,19 +832,16 @@ TALER_wallet_reserve_history_verify (
void
TALER_wallet_reserve_history_sign (
- const struct GNUNET_TIME_Timestamp ts,
- const struct TALER_Amount *history_fee,
+ uint64_t start_off,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig)
{
struct TALER_ReserveHistoryRequestPS rhr = {
.purpose.size = htonl (sizeof (rhr)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_HISTORY),
- .request_timestamp = GNUNET_TIME_timestamp_hton (ts)
+ .start_off = GNUNET_htonll (start_off)
};
- TALER_amount_hton (&rhr.history_fee,
- history_fee);
GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
&rhr,
&reserve_sig->eddsa_signature);
@@ -836,60 +851,60 @@ TALER_wallet_reserve_history_sign (
GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Response by which a wallet requests an account status.
+ * Response by which a wallet requests a coin history.
*/
-struct TALER_ReserveStatusRequestPS
+struct TALER_CoinHistoryRequestPS
{
/**
- * Purpose is #TALER_SIGNATURE_WALLET_RESERVE_STATUS
+ * Purpose is #TALER_SIGNATURE_WALLET_COIN_HISTORY
*/
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
- * When did the wallet make the request.
+ * Which entries to exclude. Only return above this offset.
*/
- struct GNUNET_TIME_TimestampNBO request_timestamp;
+ uint64_t start_off;
};
GNUNET_NETWORK_STRUCT_END
enum GNUNET_GenericReturnValue
-TALER_wallet_reserve_status_verify (
- const struct GNUNET_TIME_Timestamp ts,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_ReserveSignatureP *reserve_sig)
+TALER_wallet_coin_history_verify (
+ uint64_t start_off,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_CoinSpendSignatureP *coin_sig)
{
- struct TALER_ReserveStatusRequestPS rsr = {
+ struct TALER_CoinHistoryRequestPS rsr = {
.purpose.size = htonl (sizeof (rsr)),
- .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_STATUS),
- .request_timestamp = GNUNET_TIME_timestamp_hton (ts)
+ .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_HISTORY),
+ .start_off = GNUNET_htonll (start_off)
};
return GNUNET_CRYPTO_eddsa_verify (
- TALER_SIGNATURE_WALLET_RESERVE_STATUS,
+ TALER_SIGNATURE_WALLET_COIN_HISTORY,
&rsr,
- &reserve_sig->eddsa_signature,
- &reserve_pub->eddsa_pub);
+ &coin_sig->eddsa_signature,
+ &coin_pub->eddsa_pub);
}
void
-TALER_wallet_reserve_status_sign (
- const struct GNUNET_TIME_Timestamp ts,
- const struct TALER_ReservePrivateKeyP *reserve_priv,
- struct TALER_ReserveSignatureP *reserve_sig)
+TALER_wallet_coin_history_sign (
+ uint64_t start_off,
+ const struct TALER_CoinSpendPrivateKeyP *coin_priv,
+ struct TALER_CoinSpendSignatureP *coin_sig)
{
- struct TALER_ReserveStatusRequestPS rsr = {
+ struct TALER_CoinHistoryRequestPS rsr = {
.purpose.size = htonl (sizeof (rsr)),
- .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_STATUS),
- .request_timestamp = GNUNET_TIME_timestamp_hton (ts)
+ .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_HISTORY),
+ .start_off = GNUNET_htonll (start_off)
};
- GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
+ GNUNET_CRYPTO_eddsa_sign (&coin_priv->eddsa_priv,
&rsr,
- &reserve_sig->eddsa_signature);
+ &coin_sig->eddsa_signature);
}
@@ -1528,6 +1543,7 @@ struct TALER_ReserveOpenDepositPS
GNUNET_NETWORK_STRUCT_END
+// FIXME-#7267: add h_age_commitment, h_denom_pub to have proof!
void
TALER_wallet_reserve_open_deposit_sign (
const struct TALER_Amount *coin_contribution,