wip /management
This commit is contained in:
parent
b27ebea6ee
commit
ec80a32f29
9 changed files with 154 additions and 5 deletions
114
src/management.ml
Normal file
114
src/management.ml
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
open Types
|
||||
|
||||
(* TODO
|
||||
- take secmod devices as param
|
||||
- key stamp/time stuff
|
||||
- hash stuff
|
||||
... *)
|
||||
|
||||
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 ps =
|
||||
let h_denom_pub =
|
||||
(* TODO hash *)
|
||||
let v = denom.pub |> RsaPublicKey.to_string in
|
||||
Binary_formats.DenominationHash.{ v= { v } }
|
||||
in
|
||||
let h_section_name =
|
||||
(* TODO hash *)
|
||||
let v = section_name in
|
||||
Binary_formats.HashCode.{ v }
|
||||
in
|
||||
let anchor_time = Binary_formats.TimeAbsoluteNBO.{ v= 0_L } in
|
||||
let duration_withdraw = Binary_formats.TimeRelativeNBO.{ v= 0_L } in
|
||||
Binary_formats.DenominationKeyAnnouncementPS.
|
||||
{ h_denom_pub; h_section_name; anchor_time; duration_withdraw }
|
||||
in
|
||||
let denom_secmod_sig =
|
||||
ps
|
||||
|>
|
||||
(* TODO implement DenominationKeyAnnouncementPS.bin *)
|
||||
Binary_formats.DenominationKeyAnnouncementPS.to_string
|
||||
|>
|
||||
(* TODO sig type *)
|
||||
(* Signature by the denomination security module
|
||||
not this denomination rsa signature *)
|
||||
denom_secmod_sign_f
|
||||
in
|
||||
FutureDenom.
|
||||
{
|
||||
section_name;
|
||||
value;
|
||||
stamp_start= stamp_x;
|
||||
stamp_expire_withdraw= stamp_x;
|
||||
stamp_expire_deposit= stamp_x;
|
||||
stamp_expire_legal= stamp_x;
|
||||
denom_pub;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
fee_refresh;
|
||||
fee_refund;
|
||||
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 exchange_pub =
|
||||
(* TODO
|
||||
- I don't think its in crockford base 32 here
|
||||
maybe SHA-512?
|
||||
or maybe SHA-512 in crockford base 32
|
||||
-> no, its not a hash here
|
||||
need to change ugly binary_formats functor
|
||||
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
|
||||
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 =
|
||||
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;
|
||||
signkey_secmod_sig;
|
||||
}
|
||||
|
||||
(* TODO *)
|
||||
let keys req _server _env =
|
||||
let open Vif.Response in
|
||||
let open Syntax in
|
||||
let* () = with_string req "keys .. \n" in
|
||||
let* () = add ~field:"content-type" "application/json" in
|
||||
respond `OK
|
||||
Loading…
Add table
Add a link
Reference in a new issue