+ DenominationKeyAnnouncementPS.bin
This commit is contained in:
parent
a27af0ecf1
commit
630964dcb6
5 changed files with 35 additions and 16 deletions
|
|
@ -442,6 +442,8 @@ module WithdrawConfirmationPS = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
module DenominationKeyAnnouncementPS = struct
|
module DenominationKeyAnnouncementPS = struct
|
||||||
|
(* TODO taler_signatures purpose
|
||||||
|
we use TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY instead here *)
|
||||||
(* purpose.purpose = TALER_SIGNATURE_SM_DENOMINATION_KEY *)
|
(* purpose.purpose = TALER_SIGNATURE_SM_DENOMINATION_KEY *)
|
||||||
type t = {
|
type t = {
|
||||||
h_denom_pub: DenominationHash.t;
|
h_denom_pub: DenominationHash.t;
|
||||||
|
|
@ -450,9 +452,18 @@ module DenominationKeyAnnouncementPS = struct
|
||||||
duration_withdraw: TimeRelativeNBO.t;
|
duration_withdraw: TimeRelativeNBO.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
(* TODO management *)
|
let bin =
|
||||||
(* let bin = ... *)
|
let open Bin in
|
||||||
let to_string _ = assert false
|
Purpose.make_bin Taler_signatures.sm_rsa_denomination_key @@ fun purpose ->
|
||||||
|
record
|
||||||
|
(fun _purpose h_denom_pub h_section_name anchor_time duration_withdraw ->
|
||||||
|
{ h_denom_pub; h_section_name; anchor_time; duration_withdraw })
|
||||||
|
|+ Purpose.field purpose
|
||||||
|
|+ field DenominationHash.bin (fun t -> t.h_denom_pub)
|
||||||
|
|+ field HashCode.bin (fun t -> t.h_section_name)
|
||||||
|
|+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time)
|
||||||
|
|+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw)
|
||||||
|
|> sealr
|
||||||
end
|
end
|
||||||
|
|
||||||
module SingleWithdrawRequestPS = struct
|
module SingleWithdrawRequestPS = struct
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,12 @@ let mk_future_denom denom_secmod_sign_f
|
||||||
ps
|
ps
|
||||||
|>
|
|>
|
||||||
(* TODO implement
|
(* TODO implement
|
||||||
DenominationKeyAnnouncementPS.bin
|
|
||||||
SigningKeyAnnouncementPS.bin *)
|
SigningKeyAnnouncementPS.bin *)
|
||||||
Binary_formats.DenominationKeyAnnouncementPS.to_string
|
Bin.to_string Binary_formats.DenominationKeyAnnouncementPS.bin
|
||||||
|>
|
|>
|
||||||
(* TODO sig type *)
|
(* TODO sig type *)
|
||||||
(* Signature by the denomination security module
|
(* Signature by the denomination security module
|
||||||
not this denomination rsa signature *)
|
(not this denomination rsa signature) *)
|
||||||
denom_secmod_sign_f
|
denom_secmod_sign_f
|
||||||
in
|
in
|
||||||
FutureDenom.
|
FutureDenom.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
let ( let* ) o f = match o with Ok v -> f v | Error _ as e -> e
|
let ( let* ) o f = match o with Ok v -> f v | Error _ as e -> e
|
||||||
let ( let+ ) o f = match o with Ok v -> Ok (f v) | Error _ as e -> e
|
let ( let+ ) o f = match o with Ok v -> Ok (f v) | Error _ as e -> e
|
||||||
|
|
||||||
|
(* TODO use polymorphic variant for errors *)
|
||||||
|
let unwrap_err_msg o = match o with Error (`Msg e) -> Error e | Ok v -> Ok v
|
||||||
|
|
||||||
let list_iter f l =
|
let list_iter f l =
|
||||||
let err = ref None in
|
let err = ref None in
|
||||||
try
|
try
|
||||||
|
|
|
||||||
15
src/types.ml
15
src/types.ml
|
|
@ -108,16 +108,11 @@ module RsaPublicKey = struct
|
||||||
type t = Mirage_crypto_pk.Rsa.pub
|
type t = Mirage_crypto_pk.Rsa.pub
|
||||||
|
|
||||||
let of_string s =
|
let of_string s =
|
||||||
(* TODO bin
|
let open Syntax in
|
||||||
- no [Bin.of_string] ?
|
let* s = B32.decode s in
|
||||||
- what to do with the int ref? *)
|
let* v = Util.bin_of_string Binary_formats.RsaPublicKey.bin s in
|
||||||
match B32.decode s with
|
let+ v = Mirage_crypto_pk.Rsa.pub ~n:v.n ~e:v.e |> unwrap_err_msg in
|
||||||
| Error _ as err -> err
|
v
|
||||||
| Ok s -> (
|
|
||||||
let off = ref 0 in
|
|
||||||
let v = Bin.decode Binary_formats.RsaPublicKey.bin s off in
|
|
||||||
let res = Mirage_crypto_pk.Rsa.pub ~n:v.n ~e:v.e in
|
|
||||||
match res with Error (`Msg e) -> Error e | Ok pub -> Ok pub)
|
|
||||||
|
|
||||||
let to_string ({ n; e } : Mirage_crypto_pk.Rsa.pub) =
|
let to_string ({ n; e } : Mirage_crypto_pk.Rsa.pub) =
|
||||||
let open Binary_formats.RsaPublicKey in
|
let open Binary_formats.RsaPublicKey in
|
||||||
|
|
|
||||||
11
src/util.ml
11
src/util.ml
|
|
@ -20,3 +20,14 @@ let ptime_add_span_exn p span =
|
||||||
match Ptime.add_span p span with
|
match Ptime.add_span p span with
|
||||||
| None -> Fmt.failwith "Ptime.add_span: not in the range [min;max]"
|
| None -> Fmt.failwith "Ptime.add_span: not in the range [min;max]"
|
||||||
| Some v -> v
|
| Some v -> v
|
||||||
|
|
||||||
|
(* -- *** -- *)
|
||||||
|
|
||||||
|
(* TODO bin
|
||||||
|
- no [Bin.of_string] ?
|
||||||
|
- what to do with the int ref?
|
||||||
|
is it for signaling error? *)
|
||||||
|
let bin_of_string bin s =
|
||||||
|
let off = ref 0 in
|
||||||
|
let v = Bin.decode bin s off in
|
||||||
|
Ok v
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue