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