use Jsont.Error for unsupported CS denom + wip type binary signature
This commit is contained in:
parent
4568b1bd4c
commit
eb56150120
6 changed files with 66 additions and 45 deletions
38
src/api.ml
38
src/api.ml
|
|
@ -90,40 +90,42 @@ module RsaDenominationKey = struct
|
|||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
(* not acctually implemented *)
|
||||
(* ! Clause Schnorr cipher is not supported *)
|
||||
module CSDenominationKey = struct
|
||||
(* Clause Schnorr *)
|
||||
type t = {
|
||||
age_mask: int;
|
||||
cs_pub: string;
|
||||
cs_pub: B32.t;
|
||||
}
|
||||
|
||||
(* TODO B32.jsont *)
|
||||
let b32_jsont = Jsont.of_of_string ~kind:"B32" B32.decode ~enc:B32.encode
|
||||
|
||||
let jsont =
|
||||
let make age_mask cs_pub = { age_mask; cs_pub } in
|
||||
let age_mask v = v.age_mask in
|
||||
let cs_pub v = v.cs_pub in
|
||||
Jsont.Object.map ~kind:"CSDenominationKey" make
|
||||
|> Jsont.Object.mem "age_mask" Jsont.int ~enc:age_mask
|
||||
|> Jsont.Object.mem "cs_pub" Jsont.string ~enc:cs_pub
|
||||
|> Jsont.Object.mem "cs_pub" b32_jsont ~enc:cs_pub
|
||||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
module DenominationKey = struct
|
||||
type t =
|
||||
| Rsa of RsaDenominationKey.t
|
||||
| CS of CSDenominationKey.t
|
||||
type t = Rsa of RsaDenominationKey.t
|
||||
(*| CS of CSDenominationKey.t*)
|
||||
|
||||
let rsa v = Rsa v
|
||||
let cs v = CS v
|
||||
let to_octets = function Rsa denom -> RsaPublicKey.to_octets denom.rsa_pub
|
||||
|
||||
let of_cs _v =
|
||||
Jsont.Error.msg Jsont.Meta.none "CSDenominationKey are not supported"
|
||||
|
||||
let of_rsa v = Rsa v
|
||||
|
||||
let jsont =
|
||||
let open Jsont.Object in
|
||||
let rsa = Case.map "RSA" RsaDenominationKey.jsont ~dec:rsa in
|
||||
let cs = Case.map "CS" CSDenominationKey.jsont ~dec:cs in
|
||||
let enc_case = function
|
||||
| Rsa v -> Case.value rsa v
|
||||
| CS v -> Case.value cs v
|
||||
in
|
||||
let rsa = Case.map "RSA" RsaDenominationKey.jsont ~dec:of_rsa in
|
||||
let cs = Case.map "CS" CSDenominationKey.jsont ~dec:of_cs in
|
||||
let enc_case = function Rsa v -> Case.value rsa v in
|
||||
let cases = Case.[ make rsa; make cs ] in
|
||||
map ~kind:"DenominationKey" Fun.id
|
||||
|> case_mem "cipher" Jsont.string ~enc:Fun.id ~enc_case cases
|
||||
|
|
@ -171,7 +173,7 @@ module FutureDenom = struct
|
|||
fee_deposit: Amount.t;
|
||||
fee_refresh: Amount.t;
|
||||
fee_refund: Amount.t;
|
||||
denom_secmod_sig: EddsaSignature.t;
|
||||
denom_secmod_sig: Bin_signature.DenominationKeyAnnouncementPS.Sig.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
|
|
@ -218,7 +220,9 @@ module FutureDenom = struct
|
|||
|> mem "fee_deposit" Amount.jsont ~enc:fee_deposit
|
||||
|> mem "fee_refresh" Amount.jsont ~enc:fee_refresh
|
||||
|> 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
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue