From 3b5a98a0d5f66b5fecf62c8e9962e30901f36247 Mon Sep 17 00:00:00 2001 From: Swrup Date: Wed, 1 Oct 2025 20:22:32 +0200 Subject: [PATCH] + some type def --- src/types.ml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/types.ml b/src/types.ml index 97699500..3c32f09f 100644 --- a/src/types.ml +++ b/src/types.ml @@ -17,3 +17,50 @@ module ErrorDetail = struct let to_string v = Jsont_bytesrw.encode_string jsont v |> Result.get_ok let of_string v = Jsont_bytesrw.decode_string jsont v end + +module Timestamp = struct + (* Seconds since epoch, or the special + value "never" to represent an event that will + never happen. *) + type t = Never | Seconds of int +end + +module Amount = struct + (* Amounts of currency are always expressed in terms of a base value, a fractional value and the denomination of the currency. +Amounts of currency are serialized as a string of the format :. Taler treats monetary amounts as fixed-precision numbers, with 8 decimal places. Unlike floating point numbers, this allows accurate representation of monetary amounts. + +The following constrains apply for a valid amount: + - part must be at most 11 characters long and may only consist of ASCII letters (a-zA-Z). + - integer part of may be at most 2^52. + - fractional part of may contain at most 8 decimal digits. + +An amount that is prefixed with a + or - character is also used in certain contexts. When no sign is present, the amount is assumed to be positive. *) + type t = { + currency: [ `Eur ] + ; value: int + ; fraction: int + ; sign: [ `Plus | `Minus | `None ] + } +end + +module Eddsa = struct + (* EdDSA and ECDHE public keys always point on Curve25519 + and represented using the standard 256 bits Ed25519 compact format, + converted to Crockford Base32. *) + type pub = string + type priv = string + + (* EdDSA signatures are transmitted as 64-bytes base32 + binary-encoded objects with just the R and S values (base32_ binary-only). *) + type signature = string +end + +module Rsa = struct + (* RSA public key converted to Crockford Base32. *) + type pub = string +end + +module Hash_code = struct + (* 32-byte value representing a point on Curve25519. *) + type cs25519Point = string +end