2025-10-16 10:18:22 +02:00
|
|
|
open Types
|
|
|
|
|
|
|
|
|
|
(* TODO
|
|
|
|
|
- take secmod devices as param
|
|
|
|
|
- hash stuff
|
|
|
|
|
what is the hash algorithm
|
|
|
|
|
is it hash'ed then base32'ed in xxxP?
|
|
|
|
|
... *)
|
|
|
|
|
|
2025-10-17 15:09:47 +02:00
|
|
|
let mk_future_denom denom_secmod_sign_f
|
|
|
|
|
({
|
|
|
|
|
section_name;
|
|
|
|
|
value;
|
|
|
|
|
stamp_start;
|
|
|
|
|
stamp_expire_withdraw;
|
|
|
|
|
stamp_expire_deposit;
|
|
|
|
|
stamp_expire_legal;
|
|
|
|
|
fee_withdraw;
|
|
|
|
|
fee_deposit;
|
|
|
|
|
fee_refresh;
|
|
|
|
|
fee_refund;
|
|
|
|
|
pub;
|
|
|
|
|
sign= _;
|
|
|
|
|
} :
|
|
|
|
|
Secmod_denom.rsa_denom) =
|
2025-10-17 17:34:40 +02:00
|
|
|
let denom_pub =
|
|
|
|
|
DenominationKey.Rsa RsaDenominationKey.{ age_mask= 0; rsa_pub= pub }
|
|
|
|
|
in
|
2025-10-17 16:24:59 +02:00
|
|
|
let denom_secmod_sig =
|
|
|
|
|
let open Binary_formats in
|
2025-10-17 22:04:35 +02:00
|
|
|
let h_denom_pub = DenominationHash.hash pub in
|
2025-10-18 01:25:12 +02:00
|
|
|
let h_section_name = Cstring_hash_64.hash section_name in
|
2025-10-17 16:24:59 +02:00
|
|
|
let anchor_time =
|
|
|
|
|
TimeAbsoluteNBO.{ v= Util.ptime_to_int64_us stamp_start }
|
|
|
|
|
in
|
|
|
|
|
let duration_withdraw =
|
|
|
|
|
let v =
|
|
|
|
|
Ptime.diff stamp_start stamp_expire_withdraw
|
|
|
|
|
|> Util.ptime_of_span_exn
|
|
|
|
|
|> Util.ptime_to_int64_us
|
|
|
|
|
in
|
|
|
|
|
TimeRelativeNBO.{ v }
|
|
|
|
|
in
|
|
|
|
|
let ps =
|
|
|
|
|
DenominationKeyAnnouncementPS.
|
|
|
|
|
{ h_denom_pub; h_section_name; anchor_time; duration_withdraw }
|
|
|
|
|
in
|
|
|
|
|
ps |> Bin.to_string DenominationKeyAnnouncementPS.bin |> denom_secmod_sign_f
|
2025-10-16 10:18:22 +02:00
|
|
|
in
|
|
|
|
|
FutureDenom.
|
|
|
|
|
{
|
|
|
|
|
section_name;
|
|
|
|
|
value;
|
2025-10-17 15:09:47 +02:00
|
|
|
stamp_start= Timestamp.of_ptime stamp_start;
|
|
|
|
|
stamp_expire_withdraw= Timestamp.of_ptime stamp_expire_withdraw;
|
|
|
|
|
stamp_expire_deposit= Timestamp.of_ptime stamp_expire_deposit;
|
|
|
|
|
stamp_expire_legal= Timestamp.of_ptime stamp_expire_legal;
|
2025-10-16 10:18:22 +02:00
|
|
|
denom_pub;
|
|
|
|
|
fee_withdraw;
|
|
|
|
|
fee_deposit;
|
|
|
|
|
fee_refresh;
|
|
|
|
|
fee_refund;
|
|
|
|
|
denom_secmod_sig;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 15:09:47 +02:00
|
|
|
let mk_future_sign_key signkey_secmod_sign_f
|
|
|
|
|
({ pub; sign= _; stamp_start; stamp_expire; stamp_end } : Secmod_keys.t) =
|
2025-10-17 16:24:59 +02:00
|
|
|
let signkey_secmod_sig =
|
|
|
|
|
let open Binary_formats in
|
2025-10-18 14:07:12 +02:00
|
|
|
let exchange_pub = pub in
|
2025-10-17 17:29:29 +02:00
|
|
|
let anchor_time =
|
|
|
|
|
TimeAbsoluteNBO.{ v= Util.ptime_to_int64_us stamp_start }
|
|
|
|
|
in
|
|
|
|
|
let duration =
|
|
|
|
|
let v =
|
|
|
|
|
Ptime.diff stamp_start stamp_expire
|
|
|
|
|
|> Util.ptime_of_span_exn
|
|
|
|
|
|> Util.ptime_to_int64_us
|
2025-10-17 15:09:47 +02:00
|
|
|
in
|
2025-10-17 17:29:29 +02:00
|
|
|
TimeRelativeNBO.{ v }
|
2025-10-17 15:09:47 +02:00
|
|
|
in
|
2025-10-17 17:29:29 +02:00
|
|
|
let ps = SigningKeyAnnouncementPS.{ exchange_pub; anchor_time; duration } in
|
2025-10-17 16:24:59 +02:00
|
|
|
ps |> Bin.to_string SigningKeyAnnouncementPS.bin |> signkey_secmod_sign_f
|
2025-10-16 10:18:22 +02:00
|
|
|
in
|
|
|
|
|
FutureSignKey.
|
|
|
|
|
{
|
2025-10-17 15:09:47 +02:00
|
|
|
key= pub;
|
|
|
|
|
stamp_start= Timestamp.of_ptime stamp_start;
|
|
|
|
|
stamp_expire= Timestamp.of_ptime stamp_expire;
|
|
|
|
|
stamp_end= Timestamp.of_ptime stamp_end;
|
2025-10-16 10:18:22 +02:00
|
|
|
signkey_secmod_sig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let keys req _server _env =
|
|
|
|
|
let open Vif.Response in
|
|
|
|
|
let open Syntax in
|
|
|
|
|
let* () = with_string req "keys .. \n" in
|
|
|
|
|
let* () = add ~field:"content-type" "application/json" in
|
|
|
|
|
respond `OK
|