This commit is contained in:
parent
df181b590d
commit
4475f4f3d4
3 changed files with 36 additions and 49 deletions
13
src/api.ml
13
src/api.ml
|
|
@ -922,6 +922,19 @@ module SignKey = struct
|
||||||
master_sig: ExchangeSigningKeyValidity.t;
|
master_sig: ExchangeSigningKeyValidity.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(* TODO rm one of them *)
|
||||||
|
let of_signkey
|
||||||
|
Signkey.
|
||||||
|
{
|
||||||
|
pub;
|
||||||
|
stamp_start;
|
||||||
|
stamp_expire;
|
||||||
|
stamp_end;
|
||||||
|
master_sig;
|
||||||
|
revoked_sig= _;
|
||||||
|
} =
|
||||||
|
{ key= pub; stamp_start; stamp_expire; stamp_end; master_sig }
|
||||||
|
|
||||||
let jsont =
|
let jsont =
|
||||||
let make key stamp_start stamp_expire stamp_end master_sig =
|
let make key stamp_start stamp_expire stamp_end master_sig =
|
||||||
{ key; stamp_start; stamp_expire; stamp_end; master_sig }
|
{ key; stamp_start; stamp_expire; stamp_end; master_sig }
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ let denomgroup_of_denomdata
|
||||||
master_sig;
|
master_sig;
|
||||||
revoked_sig= _;
|
revoked_sig= _;
|
||||||
} =
|
} =
|
||||||
let master_sig = match master_sig with None -> assert false | Some v -> v in
|
|
||||||
let denoms =
|
let denoms =
|
||||||
[
|
[
|
||||||
RsaDenom.
|
RsaDenom.
|
||||||
|
|
@ -112,92 +111,66 @@ let mk_keys ~db_conn (module Sm : Secmod.S) ~last_issue_date =
|
||||||
let wallet_balance_limit_without_kyc = None in
|
let wallet_balance_limit_without_kyc = None in
|
||||||
let hard_limits = [] in
|
let hard_limits = [] in
|
||||||
let zero_limits = [] in
|
let zero_limits = [] in
|
||||||
let denom_data_l =
|
let dn_l =
|
||||||
(* TODO sm-db *)
|
|
||||||
(*Pg.get_denominations db_conn |> unwrap_err_caqti *)
|
(*Pg.get_denominations db_conn |> unwrap_err_caqti *)
|
||||||
Sm.get_denoms_data ()
|
Sm.get_denominations ()
|
||||||
in
|
|>
|
||||||
let denom_data_l =
|
|
||||||
(* reverse chronological order *)
|
(* reverse chronological order *)
|
||||||
List.sort
|
List.sort (fun a b ->
|
||||||
(fun a b -> Stdlib.compare b.Denomination.stamp_start a.stamp_start)
|
Stdlib.compare b.Denomination.stamp_start a.stamp_start)
|
||||||
denom_data_l
|
|
||||||
in
|
in
|
||||||
let list_issue_date =
|
let list_issue_date =
|
||||||
match denom_data_l with
|
match dn_l with
|
||||||
| [] -> Time.Timestamp.never
|
| [] -> Timestamp.never
|
||||||
| v :: _ -> v.Denomination.stamp_start
|
| dn :: _ -> dn.Denomination.stamp_start
|
||||||
in
|
in
|
||||||
let denominations =
|
let denominations =
|
||||||
let open Denomination in
|
|
||||||
(* if `?last_issue_date` query param does not exactly match the `stamp_start`
|
(* if `?last_issue_date` query param does not exactly match the `stamp_start`
|
||||||
of one of the denomination keys, all keys are returned *)
|
of one of the denomination keys, all keys are returned *)
|
||||||
|
let open Denomination in
|
||||||
let l =
|
let l =
|
||||||
match last_issue_date with
|
match last_issue_date with
|
||||||
| None -> denom_data_l
|
| None -> dn_l
|
||||||
| Some last_issue_date -> (
|
| Some last_issue_date -> (
|
||||||
match
|
match
|
||||||
List.find_opt
|
List.find_opt
|
||||||
(fun v ->
|
(fun v -> Timestamp.compare v.stamp_start last_issue_date = 0)
|
||||||
Time.Timestamp.compare v.stamp_start last_issue_date = 0)
|
dn_l
|
||||||
denom_data_l
|
|
||||||
with
|
with
|
||||||
| None -> denom_data_l
|
| None -> dn_l
|
||||||
| Some _ ->
|
| Some _ ->
|
||||||
List.filter
|
List.filter
|
||||||
(fun v ->
|
(fun v ->
|
||||||
Time.Timestamp.compare v.stamp_start last_issue_date >= 0)
|
Time.Timestamp.compare v.stamp_start last_issue_date >= 0)
|
||||||
denom_data_l)
|
dn_l)
|
||||||
in
|
in
|
||||||
List.map denomgroup_of_denomdata l
|
List.map denomgroup_of_denomdata l
|
||||||
in
|
in
|
||||||
|
|
||||||
let signkeys =
|
let signkeys =
|
||||||
(* TODO sm-db
|
|
||||||
use database signkey data / verify secmod and database are in sync *)
|
|
||||||
(*
|
(*
|
||||||
let now = Ptime_clock.now () |> Option.some in
|
let now = Ptime_clock.now () |> Option.some in
|
||||||
let+ signkey_data_l = Pg.get_active_signkeys db_conn ~now |> unwrap_err_caqti in*)
|
let+ signkey_data_l = Pg.get_active_signkeys db_conn ~now |> unwrap_err_caqti in*)
|
||||||
let signkey_data_l = Sm.get_signkeys_data () in
|
Sm.get_signkeys ()
|
||||||
let signkey_data_l =
|
|> List.sort (fun a b ->
|
||||||
List.sort
|
|
||||||
(fun a b ->
|
|
||||||
let open Signkey in
|
let open Signkey in
|
||||||
Stdlib.compare b.stamp_start a.stamp_start)
|
Stdlib.compare b.stamp_start a.stamp_start)
|
||||||
signkey_data_l
|
|> List.map Api.SignKey.of_signkey
|
||||||
in
|
|
||||||
List.filter_map
|
|
||||||
(fun Signkey.
|
|
||||||
{
|
|
||||||
pub;
|
|
||||||
stamp_start;
|
|
||||||
stamp_expire;
|
|
||||||
stamp_end;
|
|
||||||
master_sig;
|
|
||||||
revoked_sig= _;
|
|
||||||
} ->
|
|
||||||
match master_sig with
|
|
||||||
| None -> None
|
|
||||||
| Some master_sig ->
|
|
||||||
Some
|
|
||||||
SignKey.
|
|
||||||
{ key= pub; stamp_start; stamp_expire; stamp_end; master_sig })
|
|
||||||
signkey_data_l
|
|
||||||
in
|
in
|
||||||
|
|
||||||
let exchange_pub =
|
let exchange_pub =
|
||||||
(* the eddsa pub key used to sign exchange_sig *)
|
(* the eddsa pub key used to sign exchange_sig *)
|
||||||
match signkeys with
|
match signkeys with
|
||||||
| [] -> Fmt.failwith "exchange has no active signkey"
|
| [] -> Fmt.failwith "exchange has no active signkey"
|
||||||
| v :: _ -> v.SignKey.key
|
| sk :: _ -> sk.SignKey.key
|
||||||
in
|
in
|
||||||
let exchange_sig =
|
let exchange_sig =
|
||||||
(* Compact EdDSA signature (binary-only) over the
|
(* Compact EdDSA signature (binary-only) over the
|
||||||
contatentation of all of the master_sigs (in reverse
|
contatentation of all of the master_sigs (in reverse
|
||||||
chronological order by group) in the arrays under "denominations". *)
|
chronological order by group) in the arrays under "denominations". *)
|
||||||
let hc =
|
let hc =
|
||||||
denom_data_l
|
dn_l
|
||||||
|> List.filter_map (fun v -> v.Denomination.master_sig)
|
|> List.map (fun dn -> dn.Denomination.master_sig)
|
||||||
|> List.map Signatures.DenominationKeyValidity.to_octets
|
|> List.map Signatures.DenominationKeyValidity.to_octets
|
||||||
|> String.concat ""
|
|> String.concat ""
|
||||||
|> Hash.H64.hash
|
|> Hash.H64.hash
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
open Crypto
|
open Crypto
|
||||||
|
|
||||||
|
(* TODO replace by Api.SignKey.t instead? (no revoked_sig) *)
|
||||||
type t = {
|
type t = {
|
||||||
pub: eddsa_pub;
|
pub: eddsa_pub;
|
||||||
stamp_start: Timestamp.t;
|
stamp_start: Timestamp.t;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue