This commit is contained in:
swrup 2025-10-07 15:04:09 +02:00
parent 4052f2773b
commit 6e4f34d3e1

View file

@ -53,7 +53,7 @@ end
(* -- Cryptographic primitives -- *) (* -- Cryptographic primitives -- *)
(* MK_BASIC_XX functor for structs like: (* MK_BASIC_XX functor for structs like:
struct Foo { uint8T bar[XX]; } *) struct Foo { uint8t bar[XX]; } *)
module MKMK_BASIC (Size : sig module MKMK_BASIC (Size : sig
val v : int val v : int
end) = end) =
@ -79,7 +79,7 @@ module MK_BASIC_32 () = MKMK_BASIC (SIZE_32)
module MK_BASIC_64 () = MKMK_BASIC (SIZE_64) module MK_BASIC_64 () = MKMK_BASIC (SIZE_64)
(* MK_XX functor for structs like: (* MK_XX functor for structs like:
struct FooWrap { struct Foo { uint8T bar[XX]; } } *) struct FooWrap { struct Foo { uint8t bar[XX]; } } *)
module MKMK (Size : sig module MKMK (Size : sig
val v : int val v : int
end) = end) =
@ -176,12 +176,12 @@ end
(* TODO not sure what to do of union, probably not needed *) (* TODO not sure what to do of union, probably not needed *)
(* (*
union TALER_CoinSpendPublicKeyP { union TALER_CoinSpendPublicKeyP {
uint8T eddsaPub[32]; uint8t eddsaPub[32];
uint8T ecdhePub[32]; uint8t ecdhePub[32];
}; };
union TALER_CoinSpendPrivateKeyP { union TALER_CoinSpendPrivateKeyP {
uint8T eddsaPriv[32]; uint8t eddsaPriv[32];
uint8T ecdhePriv[32]; uint8t ecdhePriv[32];
}; };
*) *)
module CoinSpendPublicKeyP = MK_32 () module CoinSpendPublicKeyP = MK_32 ()
@ -191,12 +191,12 @@ module CoinSpendSignatureP = MK_64 ()
(* TODO padding: sizeof used here (assume no padding for now) *) (* TODO padding: sizeof used here (assume no padding for now) *)
(* (*
struct TALER_TransferSecretP { struct TALER_TransferSecretP {
uint8T key[sizeof (struct GNUNET_HashCode)]; uint8t key[sizeof (struct GNUNET_HashCode)];
}; };
uint8T key[sizeof (struct GNUNET_HashCode)]; uint8t key[sizeof (struct GNUNET_HashCode)];
}; };
struct TALER_EncryptedLinkSecretP { struct TALER_EncryptedLinkSecretP {
uint8T enc[sizeof (struct TALER_LinkSecretP)]; uint8t enc[sizeof (struct TALER_LinkSecretP)];
}; };
*) *)
module TransfertSecretP = MK_64 () module TransfertSecretP = MK_64 ()
@ -205,8 +205,8 @@ module EncryptedLinkSecretP = MK_64 ()
(* (*
union TALER_TokenPublicKeyP { union TALER_TokenPublicKeyP {
uint8T eddsaPub[32]; uint8t eddsaPub[32];
uint8T ecdhePub[32]; uint8t ecdhePub[32];
}; };
*) *)
module TokenPublicKeyP = MK_32 () module TokenPublicKeyP = MK_32 ()
@ -284,19 +284,17 @@ end
* For regional currencies, the first character should be a "*" followed * For regional currencies, the first character should be a "*" followed
* by a region-specific name (i.e. "*BRETAGNEFR"). * by a region-specific name (i.e. "*BRETAGNEFR").
*/ */
#define TALER_CURRENCY_LEN 12
struct TALER_AmountNBO struct TALER_AmountNBO
{ {
/** /**
* Value in the main currency, in NBO. * Value in the main currency, in NBO.
*/ */
uint64T value GNUNET_PACKED; uint64t value GNUNET_PACKED;
/** /**
* Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE), in NBO. * Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE), in NBO.
*/ */
uint32T fraction GNUNET_PACKED; uint32t fraction GNUNET_PACKED;
/** /**
* Type of the currency being represented. * Type of the currency being represented.
@ -309,12 +307,12 @@ struct TALER_Amount
/** /**
* Value (numerator of fraction) * Value (numerator of fraction)
*/ */
uint64T value; uint64t value;
/** /**
* Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE). * Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE).
*/ */
uint32T fraction; uint32t fraction;
/** /**
* Currency string, left adjusted and padded with zeros. All zeros * Currency string, left adjusted and padded with zeros. All zeros
@ -323,7 +321,7 @@ struct TALER_Amount
char currency[TALER_CURRENCY_LEN]; char currency[TALER_CURRENCY_LEN];
}; };
*) *)
let currencyLen = 12 let currency_len = 12
module Amount = struct module Amount = struct
type t = { type t = {
@ -332,7 +330,7 @@ module Amount = struct
currency: string; currency: string;
} }
let size = int64_size + int32_size + currencyLen let size = int64_size + int32_size + currency_len
(* TODO BE here? *) (* TODO BE here? *)
let bin = let bin =
@ -340,7 +338,7 @@ module Amount = struct
record (fun value fraction currency -> { value; fraction; currency }) record (fun value fraction currency -> { value; fraction; currency })
|+ field beint64 (fun t -> t.value) |+ field beint64 (fun t -> t.value)
|+ field beint32 (fun t -> t.fraction) |+ field beint32 (fun t -> t.fraction)
|+ field (bytes currencyLen) (fun t -> t.currency) |+ field (bytes currency_len) (fun t -> t.currency)
|> sealr |> sealr
end end
@ -351,14 +349,14 @@ module AmountNBO = struct
currency: string; currency: string;
} }
let size = int64_size + int32_size + currencyLen let size = int64_size + int32_size + currency_len
let bin = let bin =
let open Bin in let open Bin in
record (fun value fraction currency -> { value; fraction; currency }) record (fun value fraction currency -> { value; fraction; currency })
|+ field beint64 (fun t -> t.value) |+ field beint64 (fun t -> t.value)
|+ field beint32 (fun t -> t.fraction) |+ field beint32 (fun t -> t.fraction)
|+ field (bytes currencyLen) (fun t -> t.currency) |+ field (bytes currency_len) (fun t -> t.currency)
|> sealr |> sealr
end end