This commit is contained in:
parent
eee7f43ab2
commit
56694e9b3e
1 changed files with 63 additions and 36 deletions
|
|
@ -41,29 +41,38 @@
|
||||||
let int32_size = 4
|
let int32_size = 4
|
||||||
let int64_size = 8
|
let int64_size = 8
|
||||||
|
|
||||||
|
(* -- Time -- *)
|
||||||
|
|
||||||
|
(* microseconds since the UNIX Epoch
|
||||||
|
UINT64_MAX represents "never" *)
|
||||||
|
module MK_TIME () = struct
|
||||||
|
type t = { v: int64 }
|
||||||
|
|
||||||
|
(* not BE (?) *)
|
||||||
|
let bin =
|
||||||
|
let open Bin in
|
||||||
|
record (fun v -> { v }) |+ field neint64 (fun t -> t.v) |> sealr
|
||||||
|
end
|
||||||
|
|
||||||
|
module MK_TIME_NBO () = struct
|
||||||
|
type t = { v: int64 }
|
||||||
|
|
||||||
|
let bin =
|
||||||
|
let open Bin in
|
||||||
|
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
|
(* TODO clean up
|
||||||
? rm all of UTIL
|
? rm all of UTIL
|
||||||
? Bin.map int64 to Ptime.t here *)
|
? Bin.map int64 to Ptime.t here *)
|
||||||
module UTIL = struct
|
module UTIL = struct
|
||||||
(* microseconds since the UNIX Epoch
|
|
||||||
UINT64_MAX represents "never" *)
|
|
||||||
module MK_TIME () = struct
|
|
||||||
type t = { v: int64 }
|
|
||||||
|
|
||||||
(* not BE (?) *)
|
|
||||||
let bin =
|
|
||||||
let open Bin in
|
|
||||||
record (fun v -> { v }) |+ field neint64 (fun t -> t.v) |> sealr
|
|
||||||
end
|
|
||||||
|
|
||||||
module MK_TIME_NBO () = struct
|
|
||||||
type t = { v: int64 }
|
|
||||||
|
|
||||||
let bin =
|
|
||||||
let open Bin in
|
|
||||||
record (fun v -> { v }) |+ field beint64 (fun t -> t.v) |> sealr
|
|
||||||
end
|
|
||||||
|
|
||||||
module type Bytes_sig = sig
|
module type Bytes_sig = sig
|
||||||
type t = { v: string }
|
type t = { v: string }
|
||||||
|
|
||||||
|
|
@ -196,20 +205,41 @@ module UTIL = struct
|
||||||
module MK_HASH_32 () : H_sig = struct
|
module MK_HASH_32 () : H_sig = struct
|
||||||
include HHH_32
|
include HHH_32
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
include UTIL
|
include UTIL
|
||||||
module Taler_signatures = Include.Taler_signatures
|
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 -- *)
|
(* -- Cryptographic primitives -- *)
|
||||||
|
|
||||||
(* GNUNET_CRYPTO format *)
|
(* GNUNET_CRYPTO format *)
|
||||||
|
|
@ -274,15 +304,12 @@ module GNUNET_RsaPublicKey = struct
|
||||||
t
|
t
|
||||||
end
|
end
|
||||||
|
|
||||||
module DenominationHash = struct
|
module DenominationHash = MK_SRC_HASH_32 (struct
|
||||||
include Hash_64
|
type src = Mirage_crypto_pk.Rsa.pub
|
||||||
|
|
||||||
let hash (pub : Mirage_crypto_pk.Rsa.pub) =
|
let to_octets pub =
|
||||||
pub
|
GNUNET_RsaPublicKey.of_pub pub |> Bin.to_string GNUNET_RsaPublicKey.bin
|
||||||
|> GNUNET_RsaPublicKey.of_pub
|
end)
|
||||||
|> Bin.to_string GNUNET_RsaPublicKey.bin
|
|
||||||
|> hash
|
|
||||||
end
|
|
||||||
|
|
||||||
module ExchangePublicKeyP = struct
|
module ExchangePublicKeyP = struct
|
||||||
type t = Mirage_crypto_ec.Ed25519.pub
|
type t = Mirage_crypto_ec.Ed25519.pub
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue