69 lines
1.5 KiB
OCaml
69 lines
1.5 KiB
OCaml
open Crypto
|
|
|
|
type t = {
|
|
pub: RsaPublicKey.t;
|
|
priv: RsaPrivateKey.t;
|
|
section_name: string;
|
|
value: Amount.t;
|
|
stamp_start: Timestamp.t;
|
|
stamp_expire_withdraw: Timestamp.t;
|
|
stamp_expire_deposit: Timestamp.t;
|
|
stamp_expire_legal: Timestamp.t;
|
|
fee_withdraw: Amount.t;
|
|
fee_deposit: Amount.t;
|
|
fee_refresh: Amount.t;
|
|
fee_refund: Amount.t;
|
|
age_mask: int;
|
|
h_pub: Bin_type.DenominationHash.t;
|
|
master_sig: Bin_sig.DenominationKeyValidity.t option;
|
|
}
|
|
|
|
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 = Timestamp.now () in
|
|
let stamp_expire_withdraw =
|
|
Timestamp.add_span_exn stamp_start duration_withdraw
|
|
in
|
|
let stamp_expire_deposit =
|
|
Timestamp.add_span_exn stamp_start duration_spend
|
|
in
|
|
let stamp_expire_legal = Timestamp.add_span_exn stamp_start 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;
|
|
}
|