clean up
This commit is contained in:
parent
6bf2771f1c
commit
eddc8127a1
11 changed files with 40 additions and 165 deletions
|
|
@ -5,7 +5,8 @@
|
|||
option: correct use opt_mem or Jsont.option
|
||||
better types:
|
||||
- payto_uri
|
||||
- uri *)
|
||||
- uri
|
||||
use of monotonic time for some validity_start/_end fields *)
|
||||
|
||||
let protocol_version = "31:0:0"
|
||||
|
||||
|
|
@ -497,8 +498,6 @@ module AuditorSetupMessage = struct
|
|||
auditor_name: string;
|
||||
auditor_pub: EddsaPublicKey.t;
|
||||
master_sig: MasterAddAuditor.t;
|
||||
(* TODO monotonic time
|
||||
something about using monotonic system time here! *)
|
||||
validity_start: Timestamp.t;
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +522,6 @@ end
|
|||
module AuditorTeardownMessage = struct
|
||||
type t = {
|
||||
master_sig: MasterDelAuditor.t;
|
||||
(* TODO monotonic time *)
|
||||
validity_end: Timestamp.t;
|
||||
}
|
||||
|
||||
|
|
@ -630,7 +628,6 @@ module WireSetupMessage = struct
|
|||
payto_uri: string;
|
||||
master_sig_wire: MasterWireDetails.t;
|
||||
master_sig_add: MasterAddWire.t;
|
||||
(* TODO monotonic time *)
|
||||
validity_start: Timestamp.t;
|
||||
bank_label: string option;
|
||||
priority: int option;
|
||||
|
|
@ -668,7 +665,6 @@ module WireTeardownMessage = struct
|
|||
type t = {
|
||||
payto_uri: string;
|
||||
master_sig_del: MasterDelWire.t;
|
||||
(* TODO monotonic time *)
|
||||
validity_end: Timestamp.t;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,13 +80,7 @@ module Binary_format_rsa = struct
|
|||
| _ -> assert false
|
||||
end
|
||||
|
||||
(* TODO key format
|
||||
- check what is the exact format in GNUNET
|
||||
- endianess issue? *)
|
||||
module EddsaPublicKey = struct
|
||||
(* EdDSA and ECDHE public keys always point on Curve25519
|
||||
and represented using the standard 256 bits Ed25519 compact format,
|
||||
converted to Crockford Base32. *)
|
||||
open Mirage_crypto_ec.Ed25519
|
||||
|
||||
type t = pub
|
||||
|
|
@ -161,8 +155,6 @@ module EddsaSignature : sig
|
|||
val bin : t Bin.t
|
||||
val caqti : t Caqti_type.t
|
||||
end = struct
|
||||
(* TODO key format
|
||||
endianess issue? *)
|
||||
(* transmitted as 64-bytes base32
|
||||
binary-encoded objects with just the R and S values *)
|
||||
type t = string
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
(* TODO use SHA512.of_raw_string_opt *)
|
||||
open Digestif
|
||||
|
||||
module type S = sig
|
||||
|
|
@ -20,7 +19,7 @@ module H32 = struct
|
|||
|
||||
let of_octets s =
|
||||
match SHA256.of_raw_string_opt s with
|
||||
| None -> Fmt.failwith "H32.of_octets failure: data is not 32 bytes"
|
||||
| None -> Fmt.failwith "H32.of_octets failure"
|
||||
| Some t -> t
|
||||
|
||||
let to_octets = SHA256.to_raw_string
|
||||
|
|
@ -50,7 +49,7 @@ module H64 = struct
|
|||
|
||||
let of_octets s =
|
||||
match SHA512.of_raw_string_opt s with
|
||||
| None -> Fmt.failwith "H64.of_octets failure: data is not 64 bytes"
|
||||
| None -> Fmt.failwith "H64.of_octets failure"
|
||||
| Some t -> t
|
||||
|
||||
let to_octets = SHA512.to_raw_string
|
||||
|
|
|
|||
|
|
@ -167,25 +167,7 @@ module Keys_post = struct
|
|||
let* () = list_iter (verify_signkey_signature sm) signkey_sigs in
|
||||
Ok ()
|
||||
|
||||
(* TODO move to test *)
|
||||
let check_master_signatures_update ~db_conn (module Sm : Secmod.S) =
|
||||
Sm.get_denoms_data ()
|
||||
|> list_iter (fun denom ->
|
||||
let error = Error "update_master_signatures sanity check failure" in
|
||||
let* opt =
|
||||
Pg.find_denom db_conn denom.Denom_data.h_pub |> unwrap_err_caqti
|
||||
in
|
||||
let* v = match opt with None -> error | Some v -> Ok v in
|
||||
let check = function false -> error | true -> Ok () in
|
||||
let* () =
|
||||
check (Timestamp.compare v.stamp_start denom.stamp_start = 0)
|
||||
in
|
||||
let* () = check (v.value = denom.value) in
|
||||
let* () = check (v.fee_refund = denom.fee_refund) in
|
||||
let* () = check (v.age_mask = denom.age_mask) in
|
||||
Ok ())
|
||||
|
||||
let do_ ~db_conn (module Sm : Secmod.S)
|
||||
let do_ ~db_conn:_ (module Sm : Secmod.S)
|
||||
MasterSignatures.{ denom_sigs; signkey_sigs } =
|
||||
let* () =
|
||||
signkey_sigs
|
||||
|
|
@ -200,7 +182,6 @@ module Keys_post = struct
|
|||
|> Sm.add_denom_master_signatures
|
||||
in
|
||||
let* () = Sm.store () in
|
||||
let* () = check_master_signatures_update ~db_conn (module Sm) in
|
||||
Ok ()
|
||||
|
||||
let jsont = MasterSignatures.jsont
|
||||
|
|
@ -298,9 +279,7 @@ module Auditors = struct
|
|||
h_auditor_url= Hash.Cstring.H64.hash auditor_url;
|
||||
}
|
||||
|
||||
(* TODO timestamps last_change +/- checks *)
|
||||
(* todo: there is something about use of monotonic time
|
||||
+ protection against replay attack that I don't understand *)
|
||||
(* TODO monotonic time *)
|
||||
let do_ ~db_conn v =
|
||||
let auditor_pub = v.AuditorSetupMessage.auditor_pub in
|
||||
let validity_start = v.AuditorSetupMessage.validity_start in
|
||||
|
|
@ -490,7 +469,7 @@ module Global_fees = struct
|
|||
|
||||
let jsont = GlobalFees.jsont
|
||||
|
||||
(* TODO global_fees
|
||||
(* TODO better global_fees
|
||||
ensure it is defined for the current time.
|
||||
there should be only one global_fees for each moment in time
|
||||
and once set for a timeframe, it should not change. *)
|
||||
|
|
@ -518,7 +497,7 @@ module Wire = struct
|
|||
bank_label= _;
|
||||
priority= _;
|
||||
} =
|
||||
(* TODO wire *)
|
||||
(* TODO are those read from payto_uri? *)
|
||||
let conversion_url = "" in
|
||||
let credit_restrictions = "" in
|
||||
let debit_restrictions = "" in
|
||||
|
|
@ -553,9 +532,7 @@ module Wire = struct
|
|||
match last_change_opt with
|
||||
| Some _ -> Error "wire already setup"
|
||||
| None ->
|
||||
(* TODO wire *)
|
||||
let last_change = Timestamp.of_ptime (Ptime_clock.now ()) in
|
||||
let v =
|
||||
let r =
|
||||
ExchangeWireAccount.
|
||||
{
|
||||
payto_uri= v.payto_uri;
|
||||
|
|
@ -567,7 +544,10 @@ module Wire = struct
|
|||
priority= v.priority;
|
||||
}
|
||||
in
|
||||
let+ () = Pg.insert_wire db_conn ~last_change v |> unwrap_err_caqti in
|
||||
let+ () =
|
||||
Pg.insert_wire db_conn ~last_change:v.validity_start r
|
||||
|> unwrap_err_caqti
|
||||
in
|
||||
()
|
||||
|
||||
let jsont = WireSetupMessage.jsont
|
||||
|
|
|
|||
21
src/pg.ml
21
src/pg.ml
|
|
@ -1,21 +1,13 @@
|
|||
(* TODO
|
||||
|
||||
check there is no issues with signed/unsigned integers
|
||||
|
||||
how to fix postgres/caqti tuple type?
|
||||
try something with OID?
|
||||
need to add boilerplate in each query for amounts
|
||||
|
||||
GNU Taler db-events?
|
||||
it seems caqti/pgx does not support it
|
||||
check signed/unsigned ints
|
||||
check endianness
|
||||
can we avoid amount tuple boilerplate?
|
||||
clean up caqti error type
|
||||
|
||||
transaction
|
||||
|
||||
should check validity of signatures got from db, for /management at least
|
||||
|
||||
clean up caqti error type *)
|
||||
(* TODO time
|
||||
fix comparison with timestamp footgun *)
|
||||
GNU Taler use of db-events?
|
||||
it seems caqti/pgx does not support it *)
|
||||
|
||||
module type CONN = Caqti_miou.CONNECTION
|
||||
|
||||
|
|
@ -330,7 +322,6 @@ let update_wire =
|
|||
|
||||
let disable_wire =
|
||||
let disable_wire =
|
||||
(* TODO check syntax on this *)
|
||||
Caqti_type.(t2 payto_uri time ->. unit)
|
||||
"UPDATE wire_accounts SET conversion_url=NULL, debit_restrictions=NULL, \
|
||||
credit_restrictions=NULL, master_sig=NULL, bank_label=NULL, \
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@ open Caqti_type
|
|||
open Crypto
|
||||
open Api
|
||||
|
||||
(* TODO
|
||||
check that we use Caqti_type.octets for binary data *)
|
||||
|
||||
let amount : Amount.t t =
|
||||
let open Amount in
|
||||
custom
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
(* TODO debug sig
|
||||
(* TODO signatures
|
||||
check with taler-wallet-core/src/crypto/cryptoImplementation.js
|
||||
unsigned-ints
|
||||
check signed/unsigned ints
|
||||
check endianness
|
||||
|
||||
can we skip defining a specific record for signatures and directly use Api records? *)
|
||||
better handling of decoding failure *)
|
||||
open Hash
|
||||
|
||||
module Aliases = struct
|
||||
|
|
@ -185,7 +186,7 @@ end
|
|||
|
||||
module DenominationKeyAnnouncement = struct
|
||||
module R = struct
|
||||
(* TODO CS: use purpose TALER_SIGNATURE_SM_CS_DENOMINATION_KEY *)
|
||||
(* CS: use purpose TALER_SIGNATURE_SM_CS_DENOMINATION_KEY *)
|
||||
(* purpose.purpose = TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY *)
|
||||
type r = {
|
||||
h_denom_pub: DenominationHash.t;
|
||||
|
|
@ -252,8 +253,7 @@ module DenominationKeyValidity = struct
|
|||
fee_withdraw: AmountNBO.t;
|
||||
fee_deposit: AmountNBO.t;
|
||||
fee_refresh: AmountNBO.t;
|
||||
(* TODO debug sig
|
||||
missing field from taler doc *)
|
||||
(* TODO signatures taler doc *)
|
||||
fee_refund: AmountNBO.t;
|
||||
denom_hash: DenominationHash.t;
|
||||
}
|
||||
|
|
@ -424,8 +424,7 @@ end
|
|||
|
||||
module GlobalFees = struct
|
||||
module R = struct
|
||||
(* TODO debug sig
|
||||
taler doc *)
|
||||
(* TODO signatures taler doc *)
|
||||
(* purpose.purpose = TALER_SIGNATURE_MASTER_GLOBAL_FEES *)
|
||||
type r = {
|
||||
start_date: TimestampNBO.t;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue