refacto
This commit is contained in:
parent
2596733033
commit
305818ae4a
20 changed files with 649 additions and 757 deletions
|
|
@ -42,9 +42,7 @@ let keys content =
|
|||
|
||||
let sk_l = List.map SignKey.to_signkey v.signkeys in
|
||||
let* () =
|
||||
sk_l
|
||||
|> list_iter
|
||||
(Signkey.verify_exchange_signing_key_validity ~key:v.master_public_key)
|
||||
sk_l |> list_iter (Signkey.verify ~master_key:v.master_public_key)
|
||||
in
|
||||
|
||||
let* () =
|
||||
|
|
@ -71,13 +69,12 @@ let keys content =
|
|||
|
||||
let denom_l = v.denominations |> Denomination.denoms_of_denomgroups in
|
||||
let* () =
|
||||
denom_l
|
||||
|> list_iter
|
||||
(Denomination.verify_denomination_key_validity ~key:v.master_public_key)
|
||||
denom_l |> list_iter (Denomination.verify ~master_key:v.master_public_key)
|
||||
in
|
||||
|
||||
let* () =
|
||||
(* TODO O(n^2) *)
|
||||
let dn_ht = Hashtbl.create 0xff in
|
||||
List.iter (fun dn -> Hashtbl.replace dn_ht dn.Denomination.h_pub dn) denom_l;
|
||||
v.auditors
|
||||
|> List.concat_map
|
||||
(fun
|
||||
|
|
@ -87,30 +84,29 @@ let keys content =
|
|||
let auditor_url_hash = H64_cstring.hash auditor_url in
|
||||
denomination_keys
|
||||
|> List.map
|
||||
(fun AuditorDenominationKey.{ denom_pub_h; auditor_sig } ->
|
||||
(denom_pub_h, auditor_url_hash, auditor_pub, auditor_sig)))
|
||||
|> list_iter
|
||||
(fun (denom_pub_h, auditor_url_hash, auditor_pub, auditor_sig) ->
|
||||
let open Denomination in
|
||||
denom_l |> List.find_opt (fun dn -> dn.h_pub = denom_pub_h)
|
||||
|> function
|
||||
| None -> Fmt.error_msg "auditor denomination key not found"
|
||||
| Some dn ->
|
||||
let open Signatures.ExchangeKeyValidity in
|
||||
verify auditor_pub auditor_sig
|
||||
{
|
||||
auditor_url_hash;
|
||||
master= auditor_pub;
|
||||
start= dn.stamp_start;
|
||||
expire_withdraw= dn.stamp_expire_withdraw;
|
||||
expire_spend= dn.stamp_expire_deposit;
|
||||
expire_legal= dn.stamp_expire_legal;
|
||||
value= dn.value;
|
||||
fee_withdraw= dn.fee_withdraw;
|
||||
fee_deposit= dn.fee_deposit;
|
||||
fee_refresh= dn.fee_refresh;
|
||||
denom_hash= dn.h_pub;
|
||||
})
|
||||
(fun
|
||||
AuditorDenominationKey.{ denom_pub_h= h_pub; auditor_sig } ->
|
||||
(h_pub, (auditor_url_hash, auditor_pub, auditor_sig))))
|
||||
|> list_iter (fun (h_pub, (auditor_url_hash, auditor_pub, auditor_sig)) ->
|
||||
Hashtbl.find_opt dn_ht h_pub |> function
|
||||
| None -> Fmt.error_msg "auditor denomination key not found"
|
||||
| Some dn ->
|
||||
let open Denomination in
|
||||
let open Signatures.ExchangeKeyValidity in
|
||||
verify auditor_pub auditor_sig
|
||||
{
|
||||
auditor_url_hash;
|
||||
master= auditor_pub;
|
||||
start= dn.stamp_start;
|
||||
expire_withdraw= dn.stamp_expire_withdraw;
|
||||
expire_spend= dn.stamp_expire_deposit;
|
||||
expire_legal= dn.stamp_expire_legal;
|
||||
value= dn.value;
|
||||
fee_withdraw= dn.fee_withdraw;
|
||||
fee_deposit= dn.fee_deposit;
|
||||
fee_refresh= dn.fee_refresh;
|
||||
denom_hash= dn.h_pub;
|
||||
})
|
||||
in
|
||||
|
||||
Ok ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue