add timestamp.ml

WIP better time
  revert this?
This commit is contained in:
swrup 2025-11-28 16:57:48 +01:00
parent d760a54b61
commit d7d302bafa
10 changed files with 143 additions and 142 deletions

View file

@ -5,9 +5,9 @@ open Crypto
type t = {
pub: EddsaPublicKey.t;
priv: EddsaPrivateKey.t;
stamp_start: Ptime.t;
stamp_expire: Ptime.t;
stamp_end: Ptime.t;
stamp_start: Timestamp.t;
stamp_expire: Timestamp.t;
stamp_end: Timestamp.t;
(* signature of this key by offline master key *)
master_sig: EddsaSignature.t option;
}
@ -17,13 +17,13 @@ let generate () =
- look if it exists
- if not, create it (TOFU initialization scheme)
- write it *)
(* TODO time
correctly set those: *)
let stamp_start = Ptime_clock.now () in
let stamp_start = Ptime_clock.now () |> Option.some in
let stamp_expire =
Util.ptime_add_span_exn stamp_start Config.Exchange.signkey_legal_duration
Timestamp.add_span_exn stamp_start
(Some Config.Exchange.signkey_legal_duration)
in
let stamp_end = stamp_expire in
let priv, pub = Mirage_crypto_ec.Ed25519.generate () in
let master_sig = None in
{ pub; priv; stamp_start; stamp_expire; stamp_end; master_sig }