diff --git a/src/binary_formats.ml b/src/binary_formats.ml index 7547bb34..772dd577 100644 --- a/src/binary_formats.ml +++ b/src/binary_formats.ml @@ -486,6 +486,8 @@ module SigningKeyAnnouncementPS = struct |> sealr end +(* --- BIN IMPL END --- *) + module SingleWithdrawRequestPS = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW *) type t = { diff --git a/src/json.ml b/src/json.ml index dacbe716..73a1c7c4 100644 --- a/src/json.ml +++ b/src/json.ml @@ -73,36 +73,6 @@ module RelativeTime = struct |> Jsont.Object.finish end -module Amount = struct - open Amount - - let jsont = Jsont.of_of_string ~kind:"Amount" of_string ~enc:to_string -end - -module EddsaPublicKey = struct - open EddsaPublicKey - - let jsont = Jsont.of_of_string ~kind:"EddsaPublicKey" of_b32 ~enc:to_b32 -end - -module EddsaSignature = struct - open EddsaSignature - - let jsont = Jsont.of_of_string ~kind:"EddsaSignature" of_b32 ~enc:to_b32 -end - -module RsaPublicKey = struct - open RsaPublicKey - - 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 open RsaDenominationKey diff --git a/src/types.ml b/src/types.ml index 2ae05611..ac07fe92 100644 --- a/src/types.ml +++ b/src/types.ml @@ -30,6 +30,10 @@ module Config_types = struct end end +module HashCode = struct + type t = string +end + (* https://docs.taler.net/core/api-common.html#tsref-type-ErrorDetail *) module ErrorDetail = struct (* TODO GANA error codes @@ -63,7 +67,11 @@ module RelativeTime = struct | Forever end -module Amount = Amount +module Amount = struct + include Amount + + let jsont = Jsont.of_of_string ~kind:"Amount" of_string ~enc:to_string +end (* TODO key format - check what is the exact format in GNUNET @@ -83,6 +91,7 @@ module EddsaPublicKey = struct | Ok pub -> Ok pub let to_b32 pub = pub |> Mirage_crypto_ec.Ed25519.pub_to_octets |> B32.encode + let jsont = Jsont.of_of_string ~kind:"EddsaPublicKey" of_b32 ~enc:to_b32 end module EddsaSignature : sig @@ -91,6 +100,7 @@ module EddsaSignature : sig val sign : key:Mirage_crypto_ec.Ed25519.priv -> string -> t val of_b32 : string -> (t, string) result val to_b32 : t -> string + val jsont : t Jsont.t end = struct (* EdDSA signatures are transmitted as 64-bytes base32 binary-encoded objects with just the R and S values (base32_ binary-only). @@ -111,6 +121,8 @@ end = struct let s = B32.encode t in assert (String.length s = 64); s + + let jsont = Jsont.of_of_string ~kind:"EddsaSignature" of_b32 ~enc:to_b32 end module RsaPublicKey = struct @@ -130,6 +142,8 @@ module RsaPublicKey = struct let s = Bin.to_string bin v in let s = B32.encode s in s + + let jsont = Jsont.of_of_string ~kind:"RsaPublicKey" of_b32 ~enc:to_b32 end module RsaSignature : sig @@ -138,6 +152,7 @@ module RsaSignature : sig val sign : key:Mirage_crypto_pk.Rsa.priv -> string -> t val of_b32 : string -> (t, string) result val to_b32 : t -> string + val jsont : t Jsont.t end = struct type t = string @@ -148,11 +163,7 @@ end = struct let of_b32 s = B32.decode s let to_b32 t = B32.encode t -end - -module HashCode = struct - (* 32-byte value representing a point on Curve25519. *) - type cs25519Point = string + let jsont = Jsont.of_of_string ~kind:"RsaSignature" of_b32 ~enc:to_b32 end module RsaDenominationKey = struct