add error for unsupported CS denom
This commit is contained in:
parent
4568b1bd4c
commit
03e206de6b
3 changed files with 17 additions and 43 deletions
41
src/api.ml
41
src/api.ml
|
|
@ -90,40 +90,23 @@ module RsaDenominationKey = struct
|
|||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
(* not acctually implemented *)
|
||||
module CSDenominationKey = struct
|
||||
(* Clause Schnorr *)
|
||||
type t = {
|
||||
age_mask: int;
|
||||
cs_pub: string;
|
||||
}
|
||||
|
||||
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.finish
|
||||
end
|
||||
|
||||
(* Clause Schnorr cipher is not supported *)
|
||||
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" RsaDenominationKey.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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue