diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/taler_crypto_lib.h | 65 | ||||
| -rw-r--r-- | src/include/taler_exchangedb_plugin.h | 92 | ||||
| -rw-r--r-- | src/include/taler_kyclogic_lib.h | 6 | 
3 files changed, 162 insertions, 1 deletions
| diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 1a3b40e4..b6ec2ed8 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -46,6 +46,7 @@   * fixed and part of the protocol.   */  #define TALER_CNC_KAPPA 3 +#define TALER_CNC_KAPPA_MINUS_ONE_STR "2"  /* ****************** Coin crypto primitives ************* */ @@ -436,6 +437,15 @@ struct TALER_AgeCommitmentPublicKeyP  }; +/* + * @brief Hash to represent the commitment to n*kappa blinded keys during a age-withdrawal. + */ +struct TALER_AgeWithdrawCommitmentHashP +{ +  struct GNUNET_HashCode hash; +}; + +  /**   * @brief Type of online public keys used by the wallet to establish a purse and the associated contract meta data.   */ @@ -3701,6 +3711,42 @@ TALER_wallet_withdraw_verify (  /** + * Sign age-withdraw request. + * + * @param h_commitment hash all n*kappa blinded coins in the commitment for the age-withdraw + * @param amount_with_fee amount to debit the reserve for + * @param max_age_group maximum age group that the withdrawn coins must be restricted to + * @param reserve_priv private key to sign with + * @param[out] reserve_sig resulting signature + */ +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); + +/** + * Verify an age-withdraw request. + * + * @param h_commitment hash all n*kappa blinded coins in the commitment for the age-withdraw + * @param amount_with_fee amount to debit the reserve for + * @param max_age_group maximum age group that the withdrawn coins must be restricted to + * @param reserve_pub public key of the reserve + * @param reserve_sig resulting signature + * @return #GNUNET_OK if the signature is valid + */ +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); + + +/**   * Verify exchange melt confirmation.   *   * @param rc refresh session this is about @@ -4789,6 +4835,25 @@ TALER_exchange_online_purse_status_verify (    const struct TALER_ExchangeSignatureP *exchange_sig); +/** + * Create age-withdraw confirmation signature. + * + * @param scb function to call to create the signature + * @param awch age-withdraw commitment that identifies the n*kappa blinded coins + * @param noreveal_index gamma cut-and-choose value chosen by the exchange + * @param[out] pub where to write the exchange public key + * @param[out] sig where to write the exchange signature + * @return #TALER_EC_NONE on success + */ +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); + +  /* ********************* offline signing ************************** */ diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index db3289ff..2c606225 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1052,6 +1052,58 @@ struct TALER_EXCHANGEDB_CollectableBlindcoin  /** + * @brief Information we keep for an age-withdraw commitment + * to reproduce the /age-withdraw operation if neede, and to have proof + * that a reserve was drained by this amount. + */ +struct TALER_EXCHANGEDB_AgeWithdrawCommitment +{ +  /** +   * Total amount (with fee) committed to withdraw +   */ +  struct TALER_Amount amount_with_fee; + +  /** +   * Maximum age group that the coins are restricted to. +   */ +  uint32_t max_age_group; + +  /** +   * The hash of the commitment of all n*kappa coins +   */ +  struct TALER_AgeWithdrawCommitmentHashP h_commitment; + +  /** +   * Index (smaller #TALER_CNC_KAPPA) which the exchange has chosen to not have +   * revealed during cut and choose.  This value applies to all n coins in the +   * commitment. +   */ +  uint32_t noreveal_index; + +  /** +   * Public key of the reserve that was drained. +   */ +  struct TALER_ReservePublicKeyP reserve_pub; + +  /** +   * Signature confirming the age withdrawal, matching @e reserve_pub, @e +   * maximum_age_group and @e h_commitment and @e total_amount_with_fee. +   */ +  struct TALER_ReserveSignatureP reserve_sig; + +  /** +   * The exchange's signature of the response. +   */ +  struct TALER_ExchangeSignatureP sig; + +  /** +   * Timestamp of the request beeing made +   */ +  struct GNUNET_TIME_Timestamp timestamp; +}; + + +/**   * Information the exchange records about a recoup request   * in a reserve history.   */ @@ -3608,6 +3660,46 @@ struct TALER_EXCHANGEDB_Plugin      bool *nonce_reuse);    /** +   * Locate the response for a age-withdraw request under a hash that uniquely +   * identifies the age-withdraw operation.  Used to ensure idempotency of the +   * request. +   * +   * @param cls the @e cls of this struct with the plugin-specific state +   * @param reserve_pub public key of the reserve for which the age-withdraw request is made +   * @param ach hash that uniquely identifies the age-withdraw operation +   * @param[out] awc corresponding details of the previous age-withdraw request if an entry was found +   * @return statement execution status +   */ +  enum GNUNET_DB_QueryStatus +  (*get_age_withdraw_info)( +    void *cls, +    const struct TALER_ReservePublicKeyP *reserve_pub, +    const struct TALER_AgeWithdrawCommitmentHashP *ach, +    struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc); + +  /** +   * Perform an age-withdraw operation, checking for sufficient balance +   * and possibly persisting the withdrawal details. +   * +   * @param cls the `struct PostgresClosure` with the plugin-specific state +   * @param commitment corresponding commitment for the age-withdraw +   * @param now current time (rounded) +   * @param[out] found set to true if the reserve was found +   * @param[out] balance_ok set to true if the balance was sufficient +   * @param[out] ruuid set to the reserve's UUID (reserves table row) +   * @return query execution status +   */ +  enum GNUNET_DB_QueryStatus +  (*do_age_withdraw)( +    void *cls, +    const struct TALER_EXCHANGEDB_AgeWithdrawCommitment *commitment, +    struct GNUNET_TIME_Timestamp now, +    bool *found, +    bool *balance_ok, +    uint64_t *ruuid); + + +  /**     * Retrieve the details to a policy given by its hash_code     *     * @param cls the `struct PostgresClosure` with the plugin-specific state diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h index 4b15b447..44cc16e5 100644 --- a/src/include/taler_kyclogic_lib.h +++ b/src/include/taler_kyclogic_lib.h @@ -73,8 +73,12 @@ enum TALER_KYCLOGIC_KycTriggerEvent    /**     * Reserve is being closed by force.     */ -  TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE = 4 +  TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE = 4, +  /** +   * Customer withdraws coins via age-withdraw. +   */ +  TALER_KYCLOGIC_KYC_TRIGGER_AGE_WITHDRAW = 5,  }; | 
