add timestamps; use Ptime
This commit is contained in:
parent
112ece6d9a
commit
a27af0ecf1
8 changed files with 163 additions and 77 deletions
|
|
@ -2,7 +2,7 @@ open Types
|
|||
|
||||
(* TODO
|
||||
- take secmod devices as param
|
||||
- key stamp/time stuff
|
||||
- time stuff
|
||||
- hash stuff
|
||||
what is the hash algorithm
|
||||
is it hash'ed then base32'ed in xxxP?
|
||||
|
|
@ -11,30 +11,27 @@ open Types
|
|||
let mk_denomination_key rsa_pub =
|
||||
DenominationKey.Rsa RsaDenominationKey.{ age_mask= 0; rsa_pub }
|
||||
|
||||
let mk_future_denom denom_secmod_sign_f (denom : Secmod_denom.rsa) =
|
||||
let Config_types.Coin.
|
||||
{
|
||||
section_name;
|
||||
value;
|
||||
duration_withdraw= _;
|
||||
duration_spend= _;
|
||||
duration_legal= _;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
fee_refresh;
|
||||
fee_refund;
|
||||
cipher= _;
|
||||
rsa_keysize= _;
|
||||
age_restricted= _;
|
||||
} =
|
||||
denom.coin
|
||||
in
|
||||
let denom_pub = mk_denomination_key denom.pub in
|
||||
let stamp_x = Timestamp.Never in
|
||||
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) =
|
||||
let denom_pub = mk_denomination_key pub in
|
||||
let ps =
|
||||
let h_denom_pub =
|
||||
(* TODO hash *)
|
||||
let v = denom.pub |> RsaPublicKey.to_string in
|
||||
let v = pub |> RsaPublicKey.to_string in
|
||||
Binary_formats.DenominationHash.{ v= { v } }
|
||||
in
|
||||
let h_section_name =
|
||||
|
|
@ -64,10 +61,10 @@ let mk_future_denom denom_secmod_sign_f (denom : Secmod_denom.rsa) =
|
|||
{
|
||||
section_name;
|
||||
value;
|
||||
stamp_start= stamp_x;
|
||||
stamp_expire_withdraw= stamp_x;
|
||||
stamp_expire_deposit= stamp_x;
|
||||
stamp_expire_legal= stamp_x;
|
||||
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;
|
||||
denom_pub;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
|
|
@ -76,10 +73,8 @@ let mk_future_denom denom_secmod_sign_f (denom : Secmod_denom.rsa) =
|
|||
denom_secmod_sig;
|
||||
}
|
||||
|
||||
let mk_future_sign_key signkey_secmod_sign_f exchange_pub_key =
|
||||
let stamp_start = Timestamp.Seconds 0.0 in
|
||||
let stamp_expire = Timestamp.Never in
|
||||
let stamp_end = Timestamp.Never in
|
||||
let mk_future_sign_key signkey_secmod_sign_f
|
||||
({ pub; sign= _; stamp_start; stamp_expire; stamp_end } : Secmod_keys.t) =
|
||||
let exchange_pub =
|
||||
(* TODO
|
||||
- I don't think its in crockford base 32 here
|
||||
|
|
@ -90,26 +85,34 @@ let mk_future_sign_key signkey_secmod_sign_f exchange_pub_key =
|
|||
to not mixup hashed values with others
|
||||
- have a make function for wrapped HashCode structs
|
||||
make it take the relevant type *)
|
||||
let v = EddsaPublicKey.to_string exchange_pub_key in
|
||||
let v = EddsaPublicKey.to_string pub in
|
||||
Binary_formats.ExchangePublicKeyP.{ v= { v } }
|
||||
in
|
||||
let anchor_time = Binary_formats.TimeAbsoluteNBO.{ v= 0_L } in
|
||||
let duration = Binary_formats.TimeRelativeNBO.{ v= 0_L } in
|
||||
let signing_key_announcement_ps =
|
||||
let anchor_time =
|
||||
Binary_formats.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
|
||||
in
|
||||
Binary_formats.TimeRelativeNBO.{ v }
|
||||
in
|
||||
Binary_formats.SigningKeyAnnouncementPS.
|
||||
{ exchange_pub; anchor_time; duration }
|
||||
in
|
||||
let signkey_secmod_sig = signkey_secmod_sign_f signing_key_announcement_ps in
|
||||
FutureSignKey.
|
||||
{
|
||||
key= exchange_pub_key;
|
||||
stamp_start;
|
||||
stamp_expire;
|
||||
stamp_end;
|
||||
key= pub;
|
||||
stamp_start= Timestamp.of_ptime stamp_start;
|
||||
stamp_expire= Timestamp.of_ptime stamp_expire;
|
||||
stamp_end= Timestamp.of_ptime stamp_end;
|
||||
signkey_secmod_sig;
|
||||
}
|
||||
|
||||
(* TODO *)
|
||||
let keys req _server _env =
|
||||
let open Vif.Response in
|
||||
let open Syntax in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue