From 6029743dfb3ad5992b788d0654d165548ed5b602 Mon Sep 17 00:00:00 2001 From: swrup Date: Mon, 6 Oct 2025 23:56:10 +0200 Subject: [PATCH] --- src/dune | 1 + src/signatures.ml | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/dune b/src/dune index d8040682..09f9cdfd 100644 --- a/src/dune +++ b/src/dune @@ -13,6 +13,7 @@ ; include ; + bin angstrom zarith ; mirage-crypto diff --git a/src/signatures.ml b/src/signatures.ml index 9db5dbb2..5331b96b 100644 --- a/src/signatures.ml +++ b/src/signatures.ml @@ -1,18 +1,29 @@ -(* https://docs.taler.net/core/api-common.html#id7 *) +(* https://docs.taler.net/core/api-common.html#id7 + + - numeric values are in network byte order (big endian) *) module Purpose = struct (* defined in gnunet_crypto_lib.h *) type t = { (* This field equals the number of bytes being signed, namely 'sizeof (struct Data)'. *) - size: Int32.t; (* = uint32_t *) + size: int32; (* = uint32_t *) (* This field is used to express the context in which the signature is made, ensuring that a signature cannot be lifted from one part of the protocol - to another. See `src/include/taler/taler_signatures.h` within the - exchange's codebase (git://taler.net/exchange). *) - purpose: Int32.t; (* = uint32_t *) + to another. *) + purpose: int32; (* = uint32_t *) } + + (* TODO endianess? *) + let bin_t = + let open Bin in + record (fun size purpose -> { size; purpose }) + |+ field beint32 (fun t -> t.size) + |+ field beint32 (fun t -> t.purpose) + |> sealr + + let to_string t = Bin.to_string bin_t t end module Data = struct