diff --git a/src/config.ml b/src/config.ml index 21666cf7..e7066f5c 100644 --- a/src/config.ml +++ b/src/config.ml @@ -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 (* -- *) diff --git a/src/secmod_eddsa.ml b/src/secmod_eddsa.ml new file mode 100644 index 00000000..e8f71342 --- /dev/null +++ b/src/secmod_eddsa.ml @@ -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 +*)