abstr type for signature

This commit is contained in:
swrup 2025-10-17 16:50:21 +02:00
parent a9a2409a12
commit 9929a4a324
5 changed files with 74 additions and 57 deletions

View file

@ -73,30 +73,34 @@ module RelativeTime = struct
|> Jsont.Object.finish
end
let amount_jsont =
Jsont.of_of_string ~kind:"Amount" Amount.of_string ~enc:Amount.to_string
module Amount = struct
open Amount
let jsont = Jsont.of_of_string ~kind:"Amount" of_string ~enc:to_string
end
module EddsaPublicKey = struct
open EddsaPublicKey
(* todo?: rewrite with of_of_string *)
let jsont =
let dec = Jsont.Base.dec_result of_string in
let enc = Jsont.Base.enc to_string in
Jsont.Base.string (Jsont.Base.map ~kind:"EddsaPublicKey" ~dec ~enc ())
let jsont = Jsont.of_of_string ~kind:"EddsaPublicKey" of_b32 ~enc:to_b32
end
module EddsaSignature = struct
let jsont = Jsont.string
open EddsaSignature
let jsont = Jsont.of_of_string ~kind:"EddsaSignature" of_b32 ~enc:to_b32
end
module RsaPublicKey = struct
open RsaPublicKey
let jsont =
let dec = Jsont.Base.dec_result of_string in
let enc = Jsont.Base.enc to_string in
Jsont.Base.string (Jsont.Base.map ~kind:"RsaPublicKey" ~dec ~enc ())
let jsont = Jsont.of_of_string ~kind:"RsaPublicKey" of_b32 ~enc:to_b32
end
module RsaSignature = struct
open RsaSignature
let jsont = Jsont.of_of_string ~kind:"RsaSignature" of_b32 ~enc:to_b32
end
module RsaDenominationKey = struct
@ -149,7 +153,6 @@ module FutureSignKey = struct
open FutureSignKey
let jsont =
(* TODO ppx? *)
let make key stamp_start stamp_expire stamp_end signkey_secmod_sig =
{ key; stamp_start; stamp_expire; stamp_end; signkey_secmod_sig }
in