2025-11-21 19:07:36 +01:00
|
|
|
open Crypto
|
2025-10-17 16:50:21 +02:00
|
|
|
|
2025-10-18 18:09:04 +02:00
|
|
|
type t = {
|
2025-10-19 01:10:52 +02:00
|
|
|
pub: RsaPublicKey.t;
|
2025-11-29 14:03:37 +01:00
|
|
|
priv: RsaPrivateKey.t;
|
2025-10-17 15:09:47 +02:00
|
|
|
section_name: string;
|
|
|
|
|
value: Amount.t;
|
2025-11-28 16:57:48 +01:00
|
|
|
stamp_start: Timestamp.t;
|
|
|
|
|
stamp_expire_withdraw: Timestamp.t;
|
|
|
|
|
stamp_expire_deposit: Timestamp.t;
|
|
|
|
|
stamp_expire_legal: Timestamp.t;
|
2025-10-17 15:09:47 +02:00
|
|
|
fee_withdraw: Amount.t;
|
|
|
|
|
fee_deposit: Amount.t;
|
|
|
|
|
fee_refresh: Amount.t;
|
|
|
|
|
fee_refund: Amount.t;
|
2025-11-23 15:37:05 +01:00
|
|
|
age_mask: int;
|
2025-11-21 19:29:04 +01:00
|
|
|
h_pub: Bin_type.DenominationHash.t;
|
2025-12-07 05:37:19 +01:00
|
|
|
master_sig: Bin_sig.DenominationKeyValidityPS.t option;
|
2025-10-16 08:23:40 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-18 18:09:04 +02:00
|
|
|
let make
|
2025-10-17 15:09:47 +02:00
|
|
|
({
|
|
|
|
|
section_name;
|
|
|
|
|
value;
|
|
|
|
|
duration_withdraw;
|
|
|
|
|
duration_spend;
|
|
|
|
|
duration_legal;
|
|
|
|
|
fee_withdraw;
|
|
|
|
|
fee_deposit;
|
|
|
|
|
fee_refresh;
|
|
|
|
|
fee_refund;
|
|
|
|
|
cipher;
|
|
|
|
|
rsa_keysize;
|
|
|
|
|
age_restricted= _;
|
|
|
|
|
} :
|
2025-11-20 18:38:01 +01:00
|
|
|
Config.Coin.t) =
|
2025-10-17 15:09:47 +02:00
|
|
|
assert (cipher = `RSA);
|
|
|
|
|
|
2025-11-28 16:57:48 +01:00
|
|
|
let stamp_start = Ptime_clock.now () |> Option.some in
|
2025-10-17 15:09:47 +02:00
|
|
|
let stamp_expire_withdraw =
|
2025-11-28 16:57:48 +01:00
|
|
|
Timestamp.add_span_exn stamp_start (Some duration_withdraw)
|
2025-10-17 15:09:47 +02:00
|
|
|
in
|
|
|
|
|
let stamp_expire_deposit =
|
2025-11-28 16:57:48 +01:00
|
|
|
Timestamp.add_span_exn stamp_start (Some duration_spend)
|
|
|
|
|
in
|
|
|
|
|
let stamp_expire_legal =
|
|
|
|
|
Timestamp.add_span_exn stamp_start (Some duration_legal)
|
2025-10-17 15:09:47 +02:00
|
|
|
in
|
|
|
|
|
|
2025-10-16 08:23:40 +02:00
|
|
|
let open Mirage_crypto_pk.Rsa in
|
|
|
|
|
let priv = generate ~bits:rsa_keysize () in
|
|
|
|
|
let pub = pub_of_priv priv in
|
2025-11-21 19:29:04 +01:00
|
|
|
let h_pub = Bin_type.DenominationHash.hash (RsaPublicKey.to_octets pub) in
|
2025-10-19 01:10:52 +02:00
|
|
|
let master_sig = None in
|
2025-10-17 15:09:47 +02:00
|
|
|
{
|
2025-10-19 01:10:52 +02:00
|
|
|
pub;
|
2025-11-29 14:03:37 +01:00
|
|
|
priv;
|
2025-10-17 15:09:47 +02:00
|
|
|
section_name;
|
|
|
|
|
value;
|
|
|
|
|
stamp_start;
|
|
|
|
|
stamp_expire_withdraw;
|
|
|
|
|
stamp_expire_deposit;
|
|
|
|
|
stamp_expire_legal;
|
|
|
|
|
fee_withdraw;
|
|
|
|
|
fee_deposit;
|
|
|
|
|
fee_refresh;
|
|
|
|
|
fee_refund;
|
2025-11-23 15:37:05 +01:00
|
|
|
age_mask= 0;
|
2025-10-19 01:10:52 +02:00
|
|
|
h_pub;
|
|
|
|
|
master_sig;
|
2025-10-17 15:09:47 +02:00
|
|
|
}
|