This commit is contained in:
swrup 2025-10-07 13:02:41 +02:00
parent e5045c2e52
commit 645577aa70

View file

@ -2,6 +2,8 @@
- numeric values are in network byte order (big endian) *) - numeric values are in network byte order (big endian) *)
open Include
(* TODO (* TODO
less boilerplate? less boilerplate?
- type t abstract - type t abstract
@ -272,7 +274,8 @@ module Token_public_key_p = MAKE_EDDSA_PUB ()
(* -- Signatures -- *) (* -- Signatures -- *)
module Ecc_signature_purpose = struct (* EccSignaturePurpose *)
module Purpose = struct
type t = { type t = {
(* This field equals the number of bytes being signed, (* This field equals the number of bytes being signed,
namely 'sizeof (struct Data)'. *) namely 'sizeof (struct Data)'. *)
@ -284,6 +287,8 @@ module Ecc_signature_purpose = struct
purpose: int32; purpose: int32;
} }
let size = 4 + 4
let bin = let bin =
let open Bin in let open Bin in
record (fun size purpose -> { size; purpose }) record (fun size purpose -> { size; purpose })
@ -291,7 +296,7 @@ module Ecc_signature_purpose = struct
|+ field beint32 (fun t -> t.purpose) |+ field beint32 (fun t -> t.purpose)
|> sealr |> sealr
let size = 4 + 4 let make size purpose = { size= Int32.of_int size; purpose }
end end
(* This is the running SHA512-hash over all (* This is the running SHA512-hash over all
@ -418,7 +423,7 @@ module Withdraw_request_ps = struct
type t = { type t = {
(* TODO set it in encode/decode *) (* TODO set it in encode/decode *)
(* Purpose is #TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW *) (* Purpose is #TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW *)
purpose: Ecc_signature_purpose.t; purpose: Purpose.t;
(* Amount to withdraw, excluding fees, i.e. (* Amount to withdraw, excluding fees, i.e.
the total sum of the denominations of the coins. the total sum of the denominations of the coins.
Note that the reserve must have a value of at least amount+fee. *) Note that the reserve must have a value of at least amount+fee. *)
@ -472,7 +477,7 @@ module Withdraw_request_ps = struct
max_age_group; max_age_group;
mask; mask;
}) })
|+ field Ecc_signature_purpose.bin (fun t -> t.purpose) |+ field Purpose.bin (fun t -> t.purpose)
|+ 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)
@ -483,10 +488,9 @@ module Withdraw_request_ps = struct
end end
module Withdraw_confirmation_ps = struct module Withdraw_confirmation_ps = struct
type t = {
(* Purpose is #TALER_SIGNATURE_EXCHANGE_CONFIRM_WITHDRAW. (* Purpose is #TALER_SIGNATURE_EXCHANGE_CONFIRM_WITHDRAW.
Signed by a `struct TALER_ExchangePrivateKeyP` using EdDSA. *) Signed by a `struct TALER_ExchangePrivateKeyP` using EdDSA. *)
(*purpose: Ecc_signature_purpose.t;*) type t = {
(* Commitment made in the /withdraw request. (* Commitment made in the /withdraw request.
Also needed for the /reveal-withdraw endpoint (in case Also needed for the /reveal-withdraw endpoint (in case
of required proof of age restriction) and for /recoup *) of required proof of age restriction) and for /recoup *)
@ -502,20 +506,14 @@ module Withdraw_confirmation_ps = struct
noreveal_index: int32; noreveal_index: int32;
} }
let size = Ecc_signature_purpose.size + Hash_planchets_p.size + 4 let size = Purpose.size + Hash_planchets_p.size + 4
let purpose = Purpose.make size Taler_signatures.exchange_confirm_withdraw
let purpose =
Ecc_signature_purpose.
{
size= Int32.of_int size;
purpose= Include.Taler_signatures.exchange_confirm_withdraw;
}
let bin = let bin =
let open Bin in let open Bin in
record (fun _purpose h_planchets noreveal_index -> record (fun _purpose h_planchets noreveal_index ->
{ h_planchets; noreveal_index }) { h_planchets; noreveal_index })
|+ field Ecc_signature_purpose.bin (Fun.const purpose) |+ field Purpose.bin (Fun.const purpose)
|+ field Hash_planchets_p.bin (fun t -> t.h_planchets) |+ field Hash_planchets_p.bin (fun t -> t.h_planchets)
|+ field beint32 (fun t -> t.noreveal_index) |+ field beint32 (fun t -> t.noreveal_index)
|> sealr |> sealr