This commit is contained in:
swrup 2026-02-18 23:08:55 +01:00
parent 2dafed2273
commit 8a99e174a1
3 changed files with 93 additions and 0 deletions

View file

@ -4,6 +4,9 @@ let config_filename = "mte.conf"
let secrets_dir = Fpath.v "secrets"
let secmod_dir = Fpath.(secrets_dir / "secmod")
(* TODO config *)
let secmod_eddsa_dir = Fpath.(secrets_dir / "secmod_eddsa")
let config_data =
match Assets_crunch.read config_filename with
| None -> fail "static file not found: `%s`" config_filename
@ -197,6 +200,28 @@ module Exchange_secmod_eddsa = struct
let lookahead_sign = get "lookahead_sign" |> duration
let overlap_duration = get "overlap_duration" |> duration
let duration = get "duration" |> duration
(* TODO config
LOOKAHEAD_SIGN
How long do we generate denomination and signing keys ahead of time?
OVERLAP_DURATION
How much should validity periods for coins overlap? Should be long enough to avoid problems with wallets picking one key and then due to network latency another key being valid. The DURATION_WITHDRAW period must be longer than this value.
DURATION
For how long should EdDSA keys be valid for signing?
SM_PRIV_KEY
Where should the security module store its long-term private key?
KEY_DIR
Where should the security module store the private keys it manages?
UNIXPATH
On which path should the security module listen for signing requests?
*)
end
(* -- *)

8
src/secmod_eddsa.c Normal file
View file

@ -0,0 +1,8 @@
let read fname = Bos.OS.File.read fname |> unwrap_err_msg
let write fname s = Bos.OS.File.write fname s |> unwrap_err_msg
let write_eddsa fname priv = write fname (EddsaPrivateKey.to_octets priv)
let write_rsa fname priv = write fname (RsaPrivateKey.to_octets priv)
let read_eddsa fname =
let* data = read fname in
EddsaPrivateKey.of_octets data

60
src/secmod_eddsa.ml Normal file
View file

@ -0,0 +1,60 @@
open Syntax
open Crypto
let read fname = Bos.OS.File.read fname |> unwrap_err_msg
let write fname s = Bos.OS.File.write fname s |> unwrap_err_msg
let read_eddsa fname =
let* data = read fname in
EddsaPrivateKey.of_octets data
let write_eddsa fname priv = write fname (EddsaPrivateKey.to_octets priv)
module Config = struct
(* TODO config *)
open Config.Exchange_secmod_eddsa
let dir = Config.secmod_eddsa_dir
let lookahead_sign = lookahead_sign
let overlap_duration = overlap_duration
let duration = duration
end
open Mirage_crypto_ec
type priv = Ed25519.priv
type pub = Ed25519.pub
type t = {
priv: priv;
pub: pub;
start: Timestamp.t;
end_: Timestamp.t;
}
(*
create dir if not exists
read dir contents
init sm_key
check filename
build sorted list
check overlaps
just fail if not good
add keys until lookahead
- sign
- verify
- expose future_sk list
- purge
- schedule tasks
- !lock
todo taler doc/config is confusing
how is computed stamp_expire stamp_end
what to do of 'Exchange.signkey_legal_duration'
=> (??)
stamp_expire = stamp_start + duration
stamp_end = stamp_start + signkey_legal_duration
*)