+ validate exchange_pub

This commit is contained in:
swrup 2026-02-27 18:37:37 +01:00
parent 49fd96927c
commit fad25f8abd
2 changed files with 17 additions and 1 deletions

View file

@ -915,6 +915,10 @@ module SignKey = struct
Signkey.{ pub; stamp_start; stamp_expire; stamp_end; master_sig } =
{ key= pub; stamp_start; stamp_expire; stamp_end; master_sig }
let to_signkey { key= pub; stamp_start; stamp_expire; stamp_end; master_sig }
=
Signkey.{ pub; stamp_start; stamp_expire; stamp_end; master_sig }
let jsont =
let make key stamp_start stamp_expire stamp_end master_sig =
{ key; stamp_start; stamp_expire; stamp_end; master_sig }

View file

@ -51,7 +51,19 @@ let keys content =
})
in
(* validate exchange_pub *)
let* () =
let opt =
List.find_opt (fun sk -> sk.SignKey.key = v.exchange_pub) v.signkeys
in
match opt with
| None -> Fmt.error "exchange_pub is not in signkeys list"
| Some sk ->
let sk = SignKey.to_signkey sk in
(* todo will need to fake time to validate expired data *)
let now = Timestamp.of_ptime (Ptime_clock.now ()) in
if Signkey.is_valid_at ~timestamp:now sk then Ok ()
else Fmt.error "exchange_pub is not valid at the current time"
in
(* validate exchange_sig *)
(* validate denominations *)