2025-11-21 19:29:04 +01:00
|
|
|
(* https://docs.taler.net/core/api-common.html#binary-formats
|
|
|
|
|
|
|
|
|
|
numeric values are in network byte order (big endian) *)
|
|
|
|
|
|
|
|
|
|
(* structs that are 'packed' and do not contain pointers and are
|
|
|
|
|
thus suitable for hashing or similar operations are distinguished
|
|
|
|
|
by adding a 'P' at the end of the name.
|
|
|
|
|
(NEW) Note that this convention does not hold for the GNUnet-structs (yet).
|
|
|
|
|
|
|
|
|
|
structs that are used with a purpose for signatures,
|
|
|
|
|
additionally get an 'S' at the end of the name.
|
|
|
|
|
|
|
|
|
|
(from https://docs.taler.net/taler-developer-manual.html) *)
|
|
|
|
|
|
|
|
|
|
(* TODO
|
|
|
|
|
- correctly handle endianness
|
|
|
|
|
- check that our struct are well packed
|
|
|
|
|
- it looks like Bin only define packed structs
|
|
|
|
|
- we don't need to worry about struct having "P" suffix
|
|
|
|
|
remove them
|
|
|
|
|
- test them
|
|
|
|
|
- union: not sure what to do of them
|
|
|
|
|
not needed or relevant i think
|
|
|
|
|
- some purpose (`TALER_SIGNATURE_XXX`) are missing
|
|
|
|
|
- exchange and gana master branch are not in sync
|
|
|
|
|
and we should use a specific git tag instead
|
|
|
|
|
- outdated doc(?)
|
|
|
|
|
- some missing struct documentation
|
|
|
|
|
|
|
|
|
|
- better way to have module aliases?
|
|
|
|
|
*)
|
|
|
|
|
|
|
|
|
|
module Taler_signatures = Include.Taler_signatures
|
|
|
|
|
|
|
|
|
|
let int32_size = 4
|
|
|
|
|
let int64_size = 8
|
|
|
|
|
|
2026-02-05 18:11:04 +01:00
|
|
|
module Bytes32 = struct
|
2025-11-21 19:29:04 +01:00
|
|
|
type t = string
|
|
|
|
|
|
|
|
|
|
let bin = Bin.bytes 32
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-05 18:11:04 +01:00
|
|
|
module Bytes64 = struct
|
2025-11-21 19:29:04 +01:00
|
|
|
type t = string
|
|
|
|
|
|
|
|
|
|
let bin = Bin.bytes 64
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
(* -- Cryptographic primitives -- *)
|
|
|
|
|
|
|
|
|
|
(* --- Various --- *)
|
|
|
|
|
|
2026-02-05 18:11:04 +01:00
|
|
|
module TransferSecretP = Bytes64
|
|
|
|
|
module LinkSecretP = Bytes64
|
|
|
|
|
module EncryptedLinkSecretP = Bytes64
|
|
|
|
|
module BlindingMasterSeed = Bytes32
|
|
|
|
|
module BlindingMasterSecret = Bytes32
|
|
|
|
|
module WireTransferIdentifierRawP = Bytes32
|
|
|
|
|
module PublicRefreshCoinNonceP = Bytes64
|
2025-11-21 19:29:04 +01:00
|
|
|
|
|
|
|
|
(* TODO ? need to use/save a specific nonce for cryptographic blinding *)
|
|
|
|
|
(* Secret for blinding/unblinding.
|
|
|
|
|
An RSA blinding secret, which is basically
|
|
|
|
|
a 256-bit nonce, converted to Crockford `Base32`.
|
|
|
|
|
|
|
|
|
|
type DenominationBlindingKeyP = string; *)
|
2026-02-05 18:11:04 +01:00
|
|
|
module DenominationBlindingKeyP = Bytes32
|
|
|
|
|
module RefreshCommitmentP = Bytes64
|
2025-11-21 19:29:04 +01:00
|
|
|
|
|
|
|
|
(* -- TODO better: -- *)
|
|
|
|
|
module UUID = struct
|
|
|
|
|
(* uint32t value[4]; *)
|
|
|
|
|
type t = { value: string }
|
|
|
|
|
|
|
|
|
|
let size = 4 * int32_size
|
|
|
|
|
|
|
|
|
|
let bin =
|
|
|
|
|
let open Bin in
|
|
|
|
|
record (fun value -> { value })
|
|
|
|
|
|+ field (bytes size) (fun t -> t.value)
|
|
|
|
|
|> sealr
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
module WadId = struct
|
|
|
|
|
(* uint32t value[6]; *)
|
|
|
|
|
type t = { raw: string }
|
|
|
|
|
|
|
|
|
|
let size = 6 * int32_size
|
|
|
|
|
|
|
|
|
|
let bin =
|
|
|
|
|
let open Bin in
|
|
|
|
|
record (fun raw -> { raw }) |+ field (bytes size) (fun t -> t.raw) |> sealr
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
module AgeMask = struct
|
|
|
|
|
type t = { mask: int32 }
|
|
|
|
|
|
|
|
|
|
let bin =
|
|
|
|
|
let open Bin in
|
|
|
|
|
record (fun mask -> { mask }) |+ field beint32 (fun t -> t.mask) |> sealr
|
|
|
|
|
end
|