use exchange_pub valid at this time
This commit is contained in:
parent
9df75d7ea4
commit
96ac74a0ab
5 changed files with 25 additions and 8 deletions
|
|
@ -68,7 +68,7 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date =
|
|||
| Some timestamp ->
|
||||
List.find_map
|
||||
(fun v ->
|
||||
if Timestamp.compare v.Denomination.stamp_start timestamp = 0 then
|
||||
if Timestamp.equal v.Denomination.stamp_start timestamp then
|
||||
Some v.stamp_start
|
||||
else None)
|
||||
denom_l
|
||||
|
|
@ -77,20 +77,24 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date =
|
|||
| None -> denom_l
|
||||
| Some timestamp ->
|
||||
List.filter
|
||||
(fun v -> Timestamp.compare v.Denomination.stamp_start timestamp >= 0)
|
||||
(fun v -> Timestamp.geq v.Denomination.stamp_start timestamp)
|
||||
denom_l
|
||||
in
|
||||
let* denominations = Denomination.make_denom_group_sorted denom_l in
|
||||
|
||||
let* signkeys = Keys.signkeys () in
|
||||
let signkeys = List.map Api.SignKey.of_signkey signkeys in
|
||||
|
||||
(* the eddsa pub key used to sign exchange_sig *)
|
||||
let* exchange_pub =
|
||||
match signkeys with
|
||||
| [] -> Fmt.error "exchange has no active signkey"
|
||||
| sk :: _ -> Ok sk.SignKey.key
|
||||
let now = Timestamp.of_ptime (Ptime_clock.now ()) in
|
||||
let opt =
|
||||
List.find_opt (fun sk -> Signkey.is_valid_at ~timestamp:now sk) signkeys
|
||||
in
|
||||
match opt with
|
||||
| None -> Fmt.error "exchange has no active signkey"
|
||||
| Some sk -> Ok sk.pub
|
||||
in
|
||||
let signkeys = List.map Api.SignKey.of_signkey signkeys in
|
||||
|
||||
(* ! depends on denominations order *)
|
||||
let exchange_sig =
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ module Auditors = struct
|
|||
Logs.info (fun m -> m "enabled auditor");
|
||||
()
|
||||
| Some auditor ->
|
||||
if Timestamp.compare auditor.last_change validity_start > 0 then
|
||||
if Timestamp.geq auditor.last_change validity_start then
|
||||
Error
|
||||
"database has more recent auditor data for this auditor public key"
|
||||
else
|
||||
|
|
@ -200,7 +200,7 @@ module Auditors_disable = struct
|
|||
match opt with
|
||||
| None -> Error "auditor not found"
|
||||
| Some auditor -> (
|
||||
match Timestamp.compare auditor.last_change validity_end > 0 with
|
||||
match Timestamp.geq auditor.last_change validity_end with
|
||||
| true ->
|
||||
Error
|
||||
"database has more recent auditor data for this auditor public \
|
||||
|
|
|
|||
|
|
@ -7,3 +7,6 @@ type t = {
|
|||
stamp_end: Timestamp.t;
|
||||
master_sig: Signatures.ExchangeSigningKeyValidity.t;
|
||||
}
|
||||
|
||||
let is_valid_at ~timestamp sk =
|
||||
Timestamp.geq sk.stamp_start timestamp && Timestamp.lt timestamp sk.stamp_end
|
||||
|
|
|
|||
|
|
@ -97,6 +97,11 @@ module Timestamp = struct
|
|||
let never = uint64_max
|
||||
let zero = 0L
|
||||
let compare = Int64.unsigned_compare
|
||||
let gt a b = compare a b > 0
|
||||
let geq a b = compare a b >= 0
|
||||
let lt a b = compare a b < 0
|
||||
let leq a b = compare a b <= 0
|
||||
let equal a b = compare a b = 0
|
||||
let min a b = if compare a b < 0 then a else b
|
||||
let max a b = if compare a b > 0 then a else b
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ module Timestamp : sig
|
|||
val never : t
|
||||
val zero : t
|
||||
val compare : t -> t -> int
|
||||
val gt : t -> t -> bool
|
||||
val geq : t -> t -> bool
|
||||
val lt : t -> t -> bool
|
||||
val leq : t -> t -> bool
|
||||
val equal : t -> t -> bool
|
||||
val min : t -> t -> t
|
||||
val max : t -> t -> t
|
||||
val diff : t -> t -> TimeRelative.t
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue