This commit is contained in:
parent
365a67577f
commit
17628ac8ae
1 changed files with 14 additions and 18 deletions
|
|
@ -2,7 +2,7 @@ open Syntax
|
|||
open Api
|
||||
|
||||
module Keys_get = struct
|
||||
let mk_future_denom ~sm ~section_name
|
||||
let mk_future_denom (module Sm : Secmod.S) ~section_name
|
||||
({
|
||||
pub;
|
||||
value;
|
||||
|
|
@ -31,8 +31,7 @@ module Keys_get = struct
|
|||
let duration_withdraw =
|
||||
Timestamp.diff stamp_start stamp_expire_withdraw
|
||||
in
|
||||
sign_f
|
||||
~f:(Secmod.sign_with_sm_key sm)
|
||||
sign_f ~f:Sm.sign_with_sm_key
|
||||
{ h_denom_pub; h_section_name; anchor_time; duration_withdraw }
|
||||
in
|
||||
FutureDenom.
|
||||
|
|
@ -51,7 +50,7 @@ module Keys_get = struct
|
|||
denom_secmod_sig;
|
||||
}
|
||||
|
||||
let mk_future_signkey ~sm
|
||||
let mk_future_signkey (module Sm : Secmod.S)
|
||||
({
|
||||
pub;
|
||||
stamp_start;
|
||||
|
|
@ -66,33 +65,30 @@ module Keys_get = struct
|
|||
let exchange_pub = pub in
|
||||
let anchor_time = stamp_start in
|
||||
let duration = Timestamp.diff stamp_start stamp_expire in
|
||||
sign_f
|
||||
~f:(Secmod.sign_with_sm_key sm)
|
||||
{ exchange_pub; anchor_time; duration }
|
||||
sign_f ~f:Sm.sign_with_sm_key { exchange_pub; anchor_time; duration }
|
||||
in
|
||||
FutureSignKey.
|
||||
{ key= pub; stamp_start; stamp_expire; stamp_end; signkey_secmod_sig }
|
||||
|
||||
let mk_future_keys_response ~sm =
|
||||
let mk_future_keys_response (module Sm : Secmod.S) =
|
||||
let future_signkeys =
|
||||
Secmod.get_signkeys_data sm
|
||||
Sm.get_signkeys_data ()
|
||||
|> List.filter (fun k -> Option.is_none k.Signkey_data.master_sig)
|
||||
|> List.map (fun signkey -> mk_future_signkey ~sm signkey)
|
||||
|> List.map (fun signkey -> mk_future_signkey (module Sm) signkey)
|
||||
in
|
||||
let future_denoms =
|
||||
Secmod.get_denoms_data sm
|
||||
Sm.get_denoms_data ()
|
||||
|> List.filter (fun k -> Option.is_none k.Denom_data.master_sig)
|
||||
|> List.map (fun dn_data ->
|
||||
let opt =
|
||||
Secmod.find_denom_section_name sm dn_data.Denom_data.h_pub
|
||||
in
|
||||
let opt = Sm.find_denom_section_name dn_data.Denom_data.h_pub in
|
||||
match opt with
|
||||
| None -> Fmt.failwith "section_name not found."
|
||||
| Some section_name -> mk_future_denom ~sm ~section_name dn_data)
|
||||
| Some section_name ->
|
||||
mk_future_denom (module Sm) ~section_name dn_data)
|
||||
in
|
||||
let master_pub = Config.Exchange.master_public_key in
|
||||
let denom_secmod_public_key = Secmod.get_sm_key_pub sm in
|
||||
let signkey_secmod_public_key = Secmod.get_sm_key_pub sm in
|
||||
let denom_secmod_public_key = Sm.get_sm_key_pub () in
|
||||
let signkey_secmod_public_key = Sm.get_sm_key_pub () in
|
||||
FutureKeysResponse.
|
||||
{
|
||||
future_denoms;
|
||||
|
|
@ -108,7 +104,7 @@ module Keys_get = struct
|
|||
Logs.info (fun m -> m "GET /management/keys/");
|
||||
let sm = Vif.Server.device Devices.secmod server in
|
||||
let res =
|
||||
let v = mk_future_keys_response ~sm in
|
||||
let v = mk_future_keys_response sm in
|
||||
let s = Api.encode_exn jsont v in
|
||||
Ok s
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue