add json+bin for MasterSignatures

This commit is contained in:
swrup 2025-11-28 13:40:37 +01:00
parent bee3533b9e
commit f3de6ea80d
2 changed files with 139 additions and 26 deletions

View file

@ -29,6 +29,12 @@ module ErrorDetail = struct
|> Jsont.Object.finish
end
module HashCode = struct
type t = B32.t
let jsont = Jsont.of_of_string ~kind:"HashCode" B32.decode ~enc:B32.encode
end
module Amount = struct
include Amount
@ -283,3 +289,54 @@ module FutureKeysResponse = struct
~enc:signkey_secmod_public_key
|> finish
end
module SignKeySignature = struct
type t = {
key: EddsaPublicKey.t;
master_sig: EddsaSignature.t;
}
let jsont =
let make key master_sig = { key; master_sig } in
let key v = v.key in
let master_sig v = v.master_sig in
let open Jsont.Object in
map ~kind:"SignKeySignature" make
|> mem "key" EddsaPublicKey.jsont ~enc:key
|> mem "master_sig" EddsaSignature.jsont ~enc:master_sig
|> finish
end
module DenomSignature = struct
type t = {
h_denom_pub: HashCode.t;
master_sig: EddsaSignature.t;
}
let jsont =
let make h_denom_pub master_sig = { h_denom_pub; master_sig } in
let h_denom_pub v = v.h_denom_pub in
let master_sig v = v.master_sig in
let open Jsont.Object in
map ~kind:"DenomSignature" make
|> mem "h_denom_pub" HashCode.jsont ~enc:h_denom_pub
|> mem "master_sig" EddsaSignature.jsont ~enc:master_sig
|> finish
end
module MasterSignatures = struct
type t = {
denom_sigs: DenomSignature.t list;
signkey_sigs: SignKeySignature.t list;
}
let jsont =
let make denom_sigs signkey_sigs = { denom_sigs; signkey_sigs } in
let denom_sigs v = v.denom_sigs in
let signkey_sigs v = v.signkey_sigs in
let open Jsont.Object in
map ~kind:"MasterSignatures" make
|> mem "denom_sigs" (Jsont.list DenomSignature.jsont) ~enc:denom_sigs
|> mem "signkey_sigs" (Jsont.list SignKeySignature.jsont) ~enc:signkey_sigs
|> finish
end

View file

@ -129,6 +129,88 @@ module SigningKeyAnnouncementPS = struct
|> 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
@ -190,16 +272,6 @@ module RefreshMeltConfirmationPS = struct
}
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;
}
end
module ExchangeKeySetPS = struct
(* purpose.purpose = TALER_SIGNATURE_EXCHANGE_KEY_SET *)
type t = {
@ -208,22 +280,6 @@ module ExchangeKeySetPS = struct
}
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;
}
end
module MasterWireDetailsPS = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_DETAILS *)
type t = {