This commit is contained in:
parent
d4c1181946
commit
de8cd8526e
4 changed files with 33 additions and 8 deletions
|
|
@ -154,7 +154,7 @@ module FutureDenom = struct
|
||||||
fee_deposit: Amount.t;
|
fee_deposit: Amount.t;
|
||||||
fee_refresh: Amount.t;
|
fee_refresh: Amount.t;
|
||||||
fee_refund: Amount.t;
|
fee_refund: Amount.t;
|
||||||
denom_secmod_sig: EddsaSignature.t;
|
denom_secmod_sig: Bin_signature.DenominationKeyAnnouncementPS.Sig.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
let jsont =
|
let jsont =
|
||||||
|
|
@ -201,7 +201,9 @@ module FutureDenom = struct
|
||||||
|> mem "fee_deposit" Amount.jsont ~enc:fee_deposit
|
|> mem "fee_deposit" Amount.jsont ~enc:fee_deposit
|
||||||
|> mem "fee_refresh" Amount.jsont ~enc:fee_refresh
|
|> mem "fee_refresh" Amount.jsont ~enc:fee_refresh
|
||||||
|> mem "fee_refund" Amount.jsont ~enc:fee_refund
|
|> mem "fee_refund" Amount.jsont ~enc:fee_refund
|
||||||
|> mem "denom_secmod_sig" EddsaSignature.jsont ~enc:denom_secmod_sig
|
|> mem "denom_secmod_sig"
|
||||||
|
Bin_signature.DenominationKeyAnnouncementPS.Sig.jsont
|
||||||
|
~enc:denom_secmod_sig
|
||||||
|> finish
|
|> finish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ module DenominationKeyAnnouncementPS = struct
|
||||||
(* TODO taler_signatures purpose
|
(* TODO taler_signatures purpose
|
||||||
we use TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY instead here *)
|
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 r = {
|
||||||
h_denom_pub: DenominationHash.t;
|
h_denom_pub: DenominationHash.t;
|
||||||
h_section_name: Hash_64_cstr.t;
|
h_section_name: Hash_64_cstr.t;
|
||||||
anchor_time: TimeAbsoluteNBO.t;
|
anchor_time: TimeAbsoluteNBO.t;
|
||||||
|
|
@ -107,6 +107,24 @@ module DenominationKeyAnnouncementPS = struct
|
||||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time)
|
|+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time)
|
||||||
|+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw)
|
|+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw)
|
||||||
|> sealr
|
|> sealr
|
||||||
|
|
||||||
|
module type SIG = sig
|
||||||
|
type t
|
||||||
|
|
||||||
|
val sign : (string -> string) -> r -> t
|
||||||
|
val verify : (string -> msg:string -> bool) -> t -> r -> bool
|
||||||
|
val jsont : t Jsont.t
|
||||||
|
end
|
||||||
|
|
||||||
|
module Sig : SIG = struct
|
||||||
|
type t = string
|
||||||
|
|
||||||
|
let sign f r = f @@ Bin.to_string bin r
|
||||||
|
let verify f s r = f s ~msg:(Bin.to_string bin r)
|
||||||
|
|
||||||
|
(* TODO use B32.jsont, for others types too *)
|
||||||
|
let jsont = Jsont.string
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module SigningKeyAnnouncementPS = struct
|
module SigningKeyAnnouncementPS = struct
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ module EddsaSignature : sig
|
||||||
type t
|
type t
|
||||||
|
|
||||||
val sign : key:Mirage_crypto_ec.Ed25519.priv -> string -> t
|
val sign : key:Mirage_crypto_ec.Ed25519.priv -> string -> t
|
||||||
|
val sign_as_string : key:Mirage_crypto_ec.Ed25519.priv -> string -> string
|
||||||
val of_b32 : string -> (t, string) result
|
val of_b32 : string -> (t, string) result
|
||||||
val to_b32 : t -> string
|
val to_b32 : t -> string
|
||||||
val to_octets : t -> string
|
val to_octets : t -> string
|
||||||
|
|
@ -81,6 +82,8 @@ end = struct
|
||||||
(* mirage_crypto: "The result is the concatenation of r and s, as specified in RFC 8032." *)
|
(* mirage_crypto: "The result is the concatenation of r and s, as specified in RFC 8032." *)
|
||||||
Mirage_crypto_ec.Ed25519.sign ~key s
|
Mirage_crypto_ec.Ed25519.sign ~key s
|
||||||
|
|
||||||
|
let sign_as_string ~key s = sign ~key s
|
||||||
|
|
||||||
let check_size t =
|
let check_size t =
|
||||||
match String.length t = 64 with
|
match String.length t = 64 with
|
||||||
| false -> Error "EddsaSignature: invalid string length"
|
| false -> Error "EddsaSignature: invalid string length"
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ let mk_future_denom denom_key_signf
|
||||||
let duration_withdraw =
|
let duration_withdraw =
|
||||||
Timestamp.diff stamp_start stamp_expire_withdraw |> Timestamp.of_span_exn
|
Timestamp.diff stamp_start stamp_expire_withdraw |> Timestamp.of_span_exn
|
||||||
in
|
in
|
||||||
let ps = { h_denom_pub; h_section_name; anchor_time; duration_withdraw } in
|
Sig.sign denom_key_signf
|
||||||
ps |> Bin.to_string bin |> denom_key_signf
|
{ h_denom_pub; h_section_name; anchor_time; duration_withdraw }
|
||||||
in
|
in
|
||||||
FutureDenom.
|
FutureDenom.
|
||||||
{
|
{
|
||||||
|
|
@ -60,8 +60,9 @@ let mk_future_signkey signkey_signf
|
||||||
let duration =
|
let duration =
|
||||||
Timestamp.diff stamp_start stamp_expire |> Timestamp.of_span_exn
|
Timestamp.diff stamp_start stamp_expire |> Timestamp.of_span_exn
|
||||||
in
|
in
|
||||||
let ps = { exchange_pub; anchor_time; duration } in
|
{ exchange_pub; anchor_time; duration }
|
||||||
ps |> Bin.to_string bin |> signkey_signf
|
|> Bin.to_string bin
|
||||||
|
|> signkey_signf
|
||||||
in
|
in
|
||||||
FutureSignKey.
|
FutureSignKey.
|
||||||
{ key= pub; stamp_start; stamp_expire; stamp_end; signkey_secmod_sig }
|
{ key= pub; stamp_start; stamp_expire; stamp_end; signkey_secmod_sig }
|
||||||
|
|
@ -73,7 +74,8 @@ let mk_future_keys_response (secmod_signkey : Secmod_signkey.t)
|
||||||
|> List.filter (fun k -> Option.is_none k.Denomination.master_sig)
|
|> List.filter (fun k -> Option.is_none k.Denomination.master_sig)
|
||||||
|> List.map (fun denom ->
|
|> List.map (fun denom ->
|
||||||
let signf s =
|
let signf s =
|
||||||
Crypto.EddsaSignature.sign ~key:secmod_denom.sm_key.Signkey.priv s
|
Crypto.EddsaSignature.sign_as_string
|
||||||
|
~key:secmod_denom.sm_key.Signkey.priv s
|
||||||
in
|
in
|
||||||
mk_future_denom signf denom)
|
mk_future_denom signf denom)
|
||||||
in
|
in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue