mte/src/signkey.ml

30 lines
822 B
OCaml
Raw Normal View History

2025-11-21 19:07:36 +01:00
open Crypto
2025-10-17 16:50:21 +02:00
2025-11-23 15:37:05 +01:00
(* TODO master_sig
not sur how to handle master_sig initialization *)
2025-10-16 08:23:40 +02:00
type t = {
2025-10-19 01:10:52 +02:00
pub: EddsaPublicKey.t;
2025-11-28 07:47:51 +01:00
priv: EddsaPrivateKey.t;
2025-10-17 15:09:47 +02:00
stamp_start: Ptime.t;
stamp_expire: Ptime.t;
stamp_end: Ptime.t;
2025-10-19 01:10:52 +02:00
(* signature of this key by offline master key *)
master_sig: EddsaSignature.t option;
2025-10-16 08:23:40 +02:00
}
2025-10-19 01:10:52 +02:00
let generate () =
2025-10-16 08:23:40 +02:00
(* TODO
- look if it exists
- if not, create it (TOFU initialization scheme)
- write it *)
2025-10-17 15:09:47 +02:00
(* TODO time
correctly set those: *)
let stamp_start = Ptime_clock.now () in
let stamp_expire =
2025-10-19 01:10:52 +02:00
Util.ptime_add_span_exn stamp_start Config.Exchange.signkey_legal_duration
2025-10-17 15:09:47 +02:00
in
let stamp_end = stamp_expire in
2025-10-16 08:23:40 +02:00
let priv, pub = Mirage_crypto_ec.Ed25519.generate () in
2025-10-19 01:10:52 +02:00
let master_sig = None in
2025-11-28 07:47:51 +01:00
{ pub; priv; stamp_start; stamp_expire; stamp_end; master_sig }