This commit is contained in:
parent
27a940deed
commit
8828017b10
2 changed files with 68 additions and 51 deletions
|
|
@ -18,54 +18,71 @@ type t = {
|
||||||
master_sig: Api_sig.DenominationKeyValidityPS.t option;
|
master_sig: Api_sig.DenominationKeyValidityPS.t option;
|
||||||
}
|
}
|
||||||
|
|
||||||
let make
|
module Unsigned = struct
|
||||||
({
|
type t = {
|
||||||
section_name;
|
pub: RsaPublicKey.t;
|
||||||
value;
|
priv: RsaPrivateKey.t;
|
||||||
duration_withdraw;
|
section_name: string;
|
||||||
duration_spend;
|
value: Amount.t;
|
||||||
duration_legal;
|
stamp_start: Timestamp.t;
|
||||||
fee_withdraw;
|
stamp_expire_withdraw: Timestamp.t;
|
||||||
fee_deposit;
|
stamp_expire_deposit: Timestamp.t;
|
||||||
fee_refresh;
|
stamp_expire_legal: Timestamp.t;
|
||||||
fee_refund;
|
fee_withdraw: Amount.t;
|
||||||
cipher;
|
fee_deposit: Amount.t;
|
||||||
rsa_keysize;
|
fee_refresh: Amount.t;
|
||||||
age_restricted= _;
|
fee_refund: Amount.t;
|
||||||
} :
|
age_mask: int;
|
||||||
Config.Coin.t) =
|
h_pub: Bin_type.DenominationHash.t;
|
||||||
assert (cipher = `RSA);
|
|
||||||
|
|
||||||
let stamp_start = Ptime_clock.now () |> Option.some in
|
|
||||||
let stamp_expire_withdraw =
|
|
||||||
Timestamp.add_span_exn stamp_start (Some duration_withdraw)
|
|
||||||
in
|
|
||||||
let stamp_expire_deposit =
|
|
||||||
Timestamp.add_span_exn stamp_start (Some duration_spend)
|
|
||||||
in
|
|
||||||
let stamp_expire_legal =
|
|
||||||
Timestamp.add_span_exn stamp_start (Some duration_legal)
|
|
||||||
in
|
|
||||||
|
|
||||||
let open Mirage_crypto_pk.Rsa in
|
|
||||||
let priv = generate ~bits:rsa_keysize () in
|
|
||||||
let pub = pub_of_priv priv in
|
|
||||||
let h_pub = Bin_type.DenominationHash.hash (RsaPublicKey.to_octets pub) in
|
|
||||||
let master_sig = None in
|
|
||||||
{
|
|
||||||
pub;
|
|
||||||
priv;
|
|
||||||
section_name;
|
|
||||||
value;
|
|
||||||
stamp_start;
|
|
||||||
stamp_expire_withdraw;
|
|
||||||
stamp_expire_deposit;
|
|
||||||
stamp_expire_legal;
|
|
||||||
fee_withdraw;
|
|
||||||
fee_deposit;
|
|
||||||
fee_refresh;
|
|
||||||
fee_refund;
|
|
||||||
age_mask= 0;
|
|
||||||
h_pub;
|
|
||||||
master_sig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let make
|
||||||
|
({
|
||||||
|
section_name;
|
||||||
|
value;
|
||||||
|
duration_withdraw;
|
||||||
|
duration_spend;
|
||||||
|
duration_legal;
|
||||||
|
fee_withdraw;
|
||||||
|
fee_deposit;
|
||||||
|
fee_refresh;
|
||||||
|
fee_refund;
|
||||||
|
cipher;
|
||||||
|
rsa_keysize;
|
||||||
|
age_restricted= _;
|
||||||
|
} :
|
||||||
|
Config.Coin.t) =
|
||||||
|
assert (cipher = `RSA);
|
||||||
|
|
||||||
|
let stamp_start = Ptime_clock.now () |> Option.some in
|
||||||
|
let stamp_expire_withdraw =
|
||||||
|
Timestamp.add_span_exn stamp_start (Some duration_withdraw)
|
||||||
|
in
|
||||||
|
let stamp_expire_deposit =
|
||||||
|
Timestamp.add_span_exn stamp_start (Some duration_spend)
|
||||||
|
in
|
||||||
|
let stamp_expire_legal =
|
||||||
|
Timestamp.add_span_exn stamp_start (Some duration_legal)
|
||||||
|
in
|
||||||
|
|
||||||
|
let open Mirage_crypto_pk.Rsa in
|
||||||
|
let priv = generate ~bits:rsa_keysize () in
|
||||||
|
let pub = pub_of_priv priv in
|
||||||
|
let h_pub = Bin_type.DenominationHash.hash (RsaPublicKey.to_octets pub) in
|
||||||
|
{
|
||||||
|
pub;
|
||||||
|
priv;
|
||||||
|
section_name;
|
||||||
|
value;
|
||||||
|
stamp_start;
|
||||||
|
stamp_expire_withdraw;
|
||||||
|
stamp_expire_deposit;
|
||||||
|
stamp_expire_legal;
|
||||||
|
fee_withdraw;
|
||||||
|
fee_deposit;
|
||||||
|
fee_refresh;
|
||||||
|
fee_refund;
|
||||||
|
age_mask= 0;
|
||||||
|
h_pub;
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ let load conn =
|
||||||
let make_new () =
|
let make_new () =
|
||||||
let lock = Miou.Mutex.create () in
|
let lock = Miou.Mutex.create () in
|
||||||
let sm_key = Signkey.make () in
|
let sm_key = Signkey.make () in
|
||||||
let denoms = List.map Denomination.make Config.Coin.all_coins in
|
let denoms = List.map Denomination.Unsigned.make Config.Coin.all_coins in
|
||||||
let denom_ht =
|
let denom_ht =
|
||||||
denoms
|
denoms
|
||||||
|> List.map (fun v -> (v.Denomination.h_pub, v))
|
|> List.map (fun v -> (v.Denomination.h_pub, v))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue