This commit is contained in:
swrup 2025-10-07 11:45:15 +02:00
parent 947388b354
commit 7daa2695ac

View file

@ -308,14 +308,96 @@ module Age_mask = struct
record (fun mask -> { mask }) |+ field beint32 (fun t -> t.mask) |> sealr record (fun mask -> { mask }) |+ field beint32 (fun t -> t.mask) |> sealr
end end
(* TODO not in doc (* TODO TALER doc
dummy impl should be in doc
struct TALER_BlindingMasterSecretP blinding_seed; *) found in src/include/taler/taler_amount_lib.h
module Blinding_master_secret_p = MAKE_H (Hash_code)
(* TODO not in doc why is the non-NBO version only used in TALER_WithdrawRequestPS?
struct TALER_Amount amount; *) GNUNET_PACKED?
module Amount = MAKE_H (Hash_code)
can be set to "invalid" if currency = all 0 *)
(*
/**
* @brief Number of characters (plus 1 for 0-termination) we use to
* represent currency names (i.e. EUR, USD, etc.). We use 8+4 for
* alignment in the `struct TALER_Amount`. The amount is typically an
* ISO 4217 currency code when an alphanumeric 3-digit code is used.
* For regional currencies, the first character should be a "*" followed
* by a region-specific name (i.e. "*BRETAGNEFR").
*/
#define TALER_CURRENCY_LEN 12
struct TALER_AmountNBO
{
/**
* Value in the main currency, in NBO.
*/
uint64_t value GNUNET_PACKED;
/**
* Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE), in NBO.
*/
uint32_t fraction GNUNET_PACKED;
/**
* Type of the currency being represented.
*/
char currency[TALER_CURRENCY_LEN];
};
struct TALER_Amount
{
/**
* Value (numerator of fraction)
*/
uint64_t value;
/**
* Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE).
*/
uint32_t fraction;
/**
* Currency string, left adjusted and padded with zeros. All zeros
* for "invalid" values.
*/
char currency[TALER_CURRENCY_LEN];
};
*)
let currency_len = 12
module Amount = struct
type t = {
value: int64;
fraction: int32;
currency: string;
}
(* TODO BE here? *)
let bin =
let open Bin in
record (fun value fraction currency -> { value; fraction; currency })
|+ field beint64 (fun t -> t.value)
|+ field beint32 (fun t -> t.fraction)
|+ field (bytes currency_len) (fun t -> t.currency)
|> sealr
end
module AmountNBO = struct
type t = {
value: int64;
fraction: int32;
currency: string;
}
let bin =
let open Bin in
record (fun value fraction currency -> { value; fraction; currency })
|+ field beint64 (fun t -> t.value)
|+ field beint32 (fun t -> t.fraction)
|+ field (bytes currency_len) (fun t -> t.currency)
|> sealr
end
(* Format used for to generate the signature on a request to withdraw (* Format used for to generate the signature on a request to withdraw
coins from a reserve. *) coins from a reserve. *)
@ -348,7 +430,9 @@ module Withdraw_request_ps = struct
h_planchets: Hash_planchets_p.t; h_planchets: Hash_planchets_p.t;
(* The master seed that was used in the call to /blinding-prepare blinding, (* The master seed that was used in the call to /blinding-prepare blinding,
or all zeros, if no denomination of cipher type Clause-Schnorr is used. *) or all zeros, if no denomination of cipher type Clause-Schnorr is used. *)
blinding_seed: Blinding_master_secret_p.t; (* TODO TALER doc
`TALER_BlindingMasterSecretP` in doc, but probably TALER_BlindingMasterSeed *)
blinding_seed: string;
(* If age restriction proof is required, the maximum age _group_ (* If age restriction proof is required, the maximum age _group_
to commit to, 0 otherwise. Note that in this case, all to commit to, 0 otherwise. Note that in this case, all
denominations for all coins MUST support age restriction. denominations for all coins MUST support age restriction.
@ -379,7 +463,7 @@ module Withdraw_request_ps = struct
|+ field Amount.bin (fun t -> t.amount) |+ field Amount.bin (fun t -> t.amount)
|+ field Amount.bin (fun t -> t.fee) |+ field Amount.bin (fun t -> t.fee)
|+ field Hash_planchets_p.bin (fun t -> t.h_planchets) |+ field Hash_planchets_p.bin (fun t -> t.h_planchets)
|+ field Blinding_master_secret_p.bin (fun t -> t.blinding_seed) |+ field cstring (fun t -> t.blinding_seed)
|+ field beint32 (fun t -> t.max_age_group) |+ field beint32 (fun t -> t.max_age_group)
|+ field Age_mask.bin (fun t -> t.mask) |+ field Age_mask.bin (fun t -> t.mask)
|> sealr |> sealr