This commit is contained in:
swrup 2025-10-18 14:55:16 +02:00
parent eee7f43ab2
commit 56694e9b3e

View file

@ -41,10 +41,8 @@
let int32_size = 4
let int64_size = 8
(* TODO clean up
? rm all of UTIL
? Bin.map int64 to Ptime.t here *)
module UTIL = struct
(* -- Time -- *)
(* microseconds since the UNIX Epoch
UINT64_MAX represents "never" *)
module MK_TIME () = struct
@ -64,6 +62,17 @@ module UTIL = struct
record (fun v -> { v }) |+ field beint64 (fun t -> t.v) |> sealr
end
module TimeAbsolute = MK_TIME ()
module TimeAbsoluteNBO = MK_TIME_NBO ()
module TimeRelative = MK_TIME ()
module TimeRelativeNBO = MK_TIME_NBO ()
module Timestamp = MK_TIME ()
module TimestampNBO = MK_TIME_NBO ()
(* TODO clean up
? rm all of UTIL
? Bin.map int64 to Ptime.t here *)
module UTIL = struct
module type Bytes_sig = sig
type t = { v: string }
@ -196,20 +205,41 @@ module UTIL = struct
module MK_HASH_32 () : H_sig = struct
include HHH_32
end
module MK_SRC_HASH_64 (M : sig
type src
val to_octets : src -> string
end) : sig
type t
val bin : t Bin.t
val hash : M.src -> t
end = struct
include Hash_64
let hash src = hash (M.to_octets src)
end
module MK_SRC_HASH_32 (M : sig
type src
val to_octets : src -> string
end) : sig
type t
val bin : t Bin.t
val hash : M.src -> t
end = struct
include Hash_32
let hash src = hash (M.to_octets src)
end
end
include UTIL
module Taler_signatures = Include.Taler_signatures
(* -- Time -- *)
module TimeAbsolute = MK_TIME ()
module TimeAbsoluteNBO = MK_TIME_NBO ()
module TimeRelative = MK_TIME ()
module TimeRelativeNBO = MK_TIME_NBO ()
module Timestamp = MK_TIME ()
module TimestampNBO = MK_TIME_NBO ()
(* -- Cryptographic primitives -- *)
(* GNUNET_CRYPTO format *)
@ -274,15 +304,12 @@ module GNUNET_RsaPublicKey = struct
t
end
module DenominationHash = struct
include Hash_64
module DenominationHash = MK_SRC_HASH_32 (struct
type src = Mirage_crypto_pk.Rsa.pub
let hash (pub : Mirage_crypto_pk.Rsa.pub) =
pub
|> GNUNET_RsaPublicKey.of_pub
|> Bin.to_string GNUNET_RsaPublicKey.bin
|> hash
end
let to_octets pub =
GNUNET_RsaPublicKey.of_pub pub |> Bin.to_string GNUNET_RsaPublicKey.bin
end)
module ExchangePublicKeyP = struct
type t = Mirage_crypto_ec.Ed25519.pub