+ type for signature
This commit is contained in:
parent
eb56150120
commit
577b2117a4
5 changed files with 217 additions and 201 deletions
|
|
@ -35,6 +35,180 @@ module Purpose = struct
|
|||
let field purpose = Bin.field bin (fun _t -> purpose)
|
||||
end
|
||||
|
||||
module MK (R : sig
|
||||
type r
|
||||
|
||||
val bin : r Bin.t
|
||||
end) : sig
|
||||
type r = R.r
|
||||
type t
|
||||
|
||||
val sign : key:Crypto.EddsaPrivateKey.t -> r -> t
|
||||
val verify : key:Crypto.EddsaPublicKey.t -> t -> r -> bool
|
||||
val jsont : t Jsont.t
|
||||
end = struct
|
||||
open Crypto
|
||||
|
||||
type r = R.r
|
||||
type t = EddsaSignature.t
|
||||
|
||||
let bin = R.bin
|
||||
let sign ~key r = EddsaSignature.sign ~key (Bin.to_string bin r)
|
||||
let verify ~key t r = EddsaSignature.verify ~key t ~msg:(Bin.to_string bin r)
|
||||
let jsont = EddsaSignature.jsont
|
||||
end
|
||||
|
||||
module DenominationKeyAnnouncementPS = struct
|
||||
module R = struct
|
||||
(* TODO taler_signatures purpose
|
||||
we use TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY instead here *)
|
||||
(* purpose.purpose = TALER_SIGNATURE_SM_DENOMINATION_KEY *)
|
||||
type r = {
|
||||
h_denom_pub: DenominationHash.t;
|
||||
h_section_name: Hash_64_cstr.t;
|
||||
anchor_time: TimeAbsoluteNBO.t;
|
||||
duration_withdraw: TimeRelativeNBO.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
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 Hash_64_cstr.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
|
||||
|
||||
include R
|
||||
include MK (R)
|
||||
end
|
||||
|
||||
module SigningKeyAnnouncementPS = struct
|
||||
module R = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_SM_SIGNING_KEY *)
|
||||
type r = {
|
||||
exchange_pub: ExchangePublicKeyP.t;
|
||||
anchor_time: TimeAbsoluteNBO.t;
|
||||
duration: TimeRelativeNBO.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
Purpose.make_bin Taler_signatures.sm_signing_key @@ fun purpose ->
|
||||
record (fun _purpose exchange_pub anchor_time duration ->
|
||||
{ exchange_pub; anchor_time; duration })
|
||||
|+ Purpose.field purpose
|
||||
|+ field ExchangePublicKeyP.bin (fun t -> t.exchange_pub)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time)
|
||||
|+ field TimeRelativeNBO.bin (fun t -> t.duration)
|
||||
|> sealr
|
||||
end
|
||||
|
||||
include R
|
||||
include MK (R)
|
||||
end
|
||||
|
||||
module DenominationKeyValidityPS = struct
|
||||
module R = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY *)
|
||||
type r = {
|
||||
master: MasterPublicKeyP.t;
|
||||
start: TimeAbsoluteNBO.t;
|
||||
expire_withdraw: TimeAbsoluteNBO.t;
|
||||
expire_spend: TimeAbsoluteNBO.t;
|
||||
expire_legal: TimeAbsoluteNBO.t;
|
||||
value: AmountNBO.t;
|
||||
fee_withdraw: AmountNBO.t;
|
||||
fee_deposit: AmountNBO.t;
|
||||
fee_refresh: AmountNBO.t;
|
||||
denom_hash: DenominationHash.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
Purpose.make_bin Taler_signatures.master_denomination_key_validity
|
||||
@@ fun purpose ->
|
||||
record
|
||||
(fun
|
||||
_purpose
|
||||
master
|
||||
start
|
||||
expire_withdraw
|
||||
expire_spend
|
||||
expire_legal
|
||||
value
|
||||
fee_withdraw
|
||||
fee_deposit
|
||||
fee_refresh
|
||||
denom_hash
|
||||
->
|
||||
{
|
||||
master;
|
||||
start;
|
||||
expire_withdraw;
|
||||
expire_spend;
|
||||
expire_legal;
|
||||
value;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
fee_refresh;
|
||||
denom_hash;
|
||||
})
|
||||
|+ Purpose.field purpose
|
||||
|+ field MasterPublicKeyP.bin (fun t -> t.master)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.start)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire_withdraw)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire_spend)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire_legal)
|
||||
|+ field AmountNBO.bin (fun t -> t.value)
|
||||
|+ field AmountNBO.bin (fun t -> t.fee_withdraw)
|
||||
|+ field AmountNBO.bin (fun t -> t.fee_deposit)
|
||||
|+ field AmountNBO.bin (fun t -> t.fee_refresh)
|
||||
|+ field DenominationHash.bin (fun t -> t.denom_hash)
|
||||
|> sealr
|
||||
end
|
||||
|
||||
include R
|
||||
include MK (R)
|
||||
end
|
||||
|
||||
module ExchangeSigningKeyValidityPS = struct
|
||||
module R = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY *)
|
||||
type r = {
|
||||
start: TimeAbsoluteNBO.t;
|
||||
expire: TimeAbsoluteNBO.t;
|
||||
end_: TimeAbsoluteNBO.t; (* "end" renamed to end_ *)
|
||||
signkey_pub: ExchangePublicKeyP.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
Purpose.make_bin Taler_signatures.master_signing_key_validity
|
||||
@@ fun purpose ->
|
||||
record (fun _purpose start expire end_ signkey_pub ->
|
||||
{ start; expire; end_; signkey_pub })
|
||||
|+ Purpose.field purpose
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.start)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.end_)
|
||||
|+ field ExchangePublicKeyP.bin (fun t -> t.signkey_pub)
|
||||
|> sealr
|
||||
end
|
||||
|
||||
include R
|
||||
include MK (R)
|
||||
end
|
||||
|
||||
(* ### BIN IMPL END ### *)
|
||||
|
||||
module WithdrawRequestPS = struct
|
||||
(* Purpose is #TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW *)
|
||||
type t = {
|
||||
|
|
@ -84,153 +258,6 @@ module WithdrawConfirmationPS = struct
|
|||
|> sealr
|
||||
end
|
||||
|
||||
module DenominationKeyAnnouncementPS = struct
|
||||
(* TODO taler_signatures purpose
|
||||
we use TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY instead here *)
|
||||
(* purpose.purpose = TALER_SIGNATURE_SM_DENOMINATION_KEY *)
|
||||
type r = {
|
||||
h_denom_pub: DenominationHash.t;
|
||||
h_section_name: Hash_64_cstr.t;
|
||||
anchor_time: TimeAbsoluteNBO.t;
|
||||
duration_withdraw: TimeRelativeNBO.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
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 Hash_64_cstr.bin (fun t -> t.h_section_name)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time)
|
||||
|+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw)
|
||||
|> 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 B32.jsont, for others types too *)
|
||||
let jsont = Jsont.string
|
||||
end
|
||||
end
|
||||
|
||||
module SigningKeyAnnouncementPS = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_SM_SIGNING_KEY *)
|
||||
type t = {
|
||||
exchange_pub: ExchangePublicKeyP.t;
|
||||
anchor_time: TimeAbsoluteNBO.t;
|
||||
duration: TimeRelativeNBO.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
Purpose.make_bin Taler_signatures.sm_signing_key @@ fun purpose ->
|
||||
record (fun _purpose exchange_pub anchor_time duration ->
|
||||
{ exchange_pub; anchor_time; duration })
|
||||
|+ Purpose.field purpose
|
||||
|+ field ExchangePublicKeyP.bin (fun t -> t.exchange_pub)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time)
|
||||
|+ field TimeRelativeNBO.bin (fun t -> t.duration)
|
||||
|> sealr
|
||||
end
|
||||
|
||||
module DenominationKeyValidityPS = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY *)
|
||||
type t = {
|
||||
master: MasterPublicKeyP.t;
|
||||
start: TimeAbsoluteNBO.t;
|
||||
expire_withdraw: TimeAbsoluteNBO.t;
|
||||
expire_spend: TimeAbsoluteNBO.t;
|
||||
expire_legal: TimeAbsoluteNBO.t;
|
||||
value: AmountNBO.t;
|
||||
fee_withdraw: AmountNBO.t;
|
||||
fee_deposit: AmountNBO.t;
|
||||
fee_refresh: AmountNBO.t;
|
||||
denom_hash: DenominationHash.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
Purpose.make_bin Taler_signatures.master_denomination_key_validity
|
||||
@@ fun purpose ->
|
||||
record
|
||||
(fun
|
||||
_purpose
|
||||
master
|
||||
start
|
||||
expire_withdraw
|
||||
expire_spend
|
||||
expire_legal
|
||||
value
|
||||
fee_withdraw
|
||||
fee_deposit
|
||||
fee_refresh
|
||||
denom_hash
|
||||
->
|
||||
{
|
||||
master;
|
||||
start;
|
||||
expire_withdraw;
|
||||
expire_spend;
|
||||
expire_legal;
|
||||
value;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
fee_refresh;
|
||||
denom_hash;
|
||||
})
|
||||
|+ Purpose.field purpose
|
||||
|+ field MasterPublicKeyP.bin (fun t -> t.master)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.start)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire_withdraw)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire_spend)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire_legal)
|
||||
|+ field AmountNBO.bin (fun t -> t.value)
|
||||
|+ field AmountNBO.bin (fun t -> t.fee_withdraw)
|
||||
|+ field AmountNBO.bin (fun t -> t.fee_deposit)
|
||||
|+ field AmountNBO.bin (fun t -> t.fee_refresh)
|
||||
|+ field DenominationHash.bin (fun t -> t.denom_hash)
|
||||
|> sealr
|
||||
end
|
||||
|
||||
module ExchangeSigningKeyValidityPS = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY *)
|
||||
type t = {
|
||||
start: TimeAbsoluteNBO.t;
|
||||
expire: TimeAbsoluteNBO.t;
|
||||
end_: TimeAbsoluteNBO.t; (* "end" renamed to end_ *)
|
||||
signkey_pub: ExchangePublicKeyP.t;
|
||||
}
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
Purpose.make_bin Taler_signatures.master_signing_key_validity
|
||||
@@ fun purpose ->
|
||||
record (fun _purpose start expire end_ signkey_pub ->
|
||||
{ start; expire; end_; signkey_pub })
|
||||
|+ Purpose.field purpose
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.start)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.expire)
|
||||
|+ field TimeAbsoluteNBO.bin (fun t -> t.end_)
|
||||
|+ field ExchangePublicKeyP.bin (fun t -> t.signkey_pub)
|
||||
|> sealr
|
||||
end
|
||||
|
||||
(* ### BIN IMPL END ### *)
|
||||
|
||||
module SingleWithdrawRequestPS = struct
|
||||
(* purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW *)
|
||||
type t = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue