+ wip MasterSignatures

This commit is contained in:
swrup 2025-11-28 14:00:11 +01:00
parent f3de6ea80d
commit d760a54b61
7 changed files with 136 additions and 68 deletions

View file

@ -65,13 +65,15 @@ module INT64 = struct
let bin = Bin.neint64
let of_ptime v = Util.ptime_to_int64 v
let of_int64 i = i
end
module INT64_NBO = struct
type t = int64
let bin = Bin.beint64
let of_ptime = Util.ptime_to_int64
let of_ptime v = Util.ptime_to_int64 v
let of_int64 i = i
end
(* -- Time -- *)
@ -80,6 +82,7 @@ module type Time_S = sig
val bin : t Bin.t
val of_ptime : Ptime.t -> t
val of_int64 : int64 -> t
end
module TimeAbsolute : Time_S = INT64
@ -232,67 +235,14 @@ module AgeMask = struct
record (fun mask -> { mask }) |+ field beint32 (fun t -> t.mask) |> sealr
end
(* TODO
- why is the non-NBO version only used in TALER_WithdrawRequestPS?
- correctly do the padding and 0-termination
- handle "invalid" values *)
(* documentation: *)
(* Number of characters (plus 1 for 0-termination) for currency names.
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").
Currency codes are compared case-insensitively.
Currency string, left adjusted and padded with zeros.
All zeros for "invalid" values.
Name of the currency, using either a three-character ISO 4217 currency
code, or a regional currency identifier between 4 and 11 characters,
consisting of ASCII alphabetic characters ("a-zA-Z").
Should be padded to 12 bytes with 0-characters.
Currency codes are compared case-insensitively. *)
let currency_len = 12
(* TODO missing doc
found in src/include/taler/taler_amount_lib.h *)
module AmountP = 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
(* TODO keep this?
some of those are actuall ecdhe, or union of eddsa|ecdhe *)
module Aliases = struct
(* TODO add Amount.bin *)
module Amount = AmountP
module AmountNBO = struct
type t = Amount.t
let bin = Amount.bin_nbo
end
(* - Keys - *)
module PursePublicKey = EddsaPublicKey