From f93f03f7b208f7708547d52a1268807f7e4c3e6c Mon Sep 17 00:00:00 2001 From: swrup Date: Thu, 5 Feb 2026 19:11:59 +0100 Subject: [PATCH] rm bin_type.ml --- src/bin_sig.ml | 53 +++++++++++++++++++++++-- src/bin_type.ml | 102 ------------------------------------------------ 2 files changed, 50 insertions(+), 105 deletions(-) delete mode 100644 src/bin_type.ml diff --git a/src/bin_sig.ml b/src/bin_sig.ml index 6cda3669..97152fff 100644 --- a/src/bin_sig.ml +++ b/src/bin_sig.ml @@ -1,7 +1,5 @@ -(* Packed Signature *) - -open Bin_type open Hash +module Taler_signatures = Include.Taler_signatures module Aliases = struct module Timestamp = struct @@ -64,6 +62,53 @@ end open Aliases +let int32_size = 4 +let int64_size = 8 + +module Bytes32 = struct + type t = string + + let bin = Bin.bytes 32 +end + +module Bytes64 = struct + type t = string + + let bin = Bin.bytes 64 +end + +module TransferSecretP = Bytes64 +module LinkSecretP = Bytes64 +module EncryptedLinkSecretP = Bytes64 +module BlindingMasterSeed = Bytes32 +module BlindingMasterSecret = Bytes32 +module WireTransferIdentifierRawP = Bytes32 +module PublicRefreshCoinNonceP = Bytes64 +module DenominationBlindingKeyP = Bytes32 +module RefreshCommitmentP = Bytes64 + +module UUID = struct + type t = string + + let size = 4 * int32_size + let bin = Bin.bytes size +end + +module WadId = struct + type t = string + + let size = 6 * int32_size + let bin = Bin.bytes size +end + +module AgeMask = struct + type t = int32 + + let bin = Bin.beint32 +end + +(* --- *) + (* EccSignaturePurpose *) module Purpose = struct type t = { @@ -96,6 +141,8 @@ module Purpose = struct let field purpose = Bin.field bin (fun _t -> purpose) end +(* --- Packed Signatures --- *) + module MK (R : sig type r diff --git a/src/bin_type.ml b/src/bin_type.ml deleted file mode 100644 index 9d3fd4a7..00000000 --- a/src/bin_type.ml +++ /dev/null @@ -1,102 +0,0 @@ -(* 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 - -module Bytes32 = struct - type t = string - - let bin = Bin.bytes 32 -end - -module Bytes64 = struct - type t = string - - let bin = Bin.bytes 64 -end - -(* -- Cryptographic primitives -- *) - -(* --- Various --- *) - -module TransferSecretP = Bytes64 -module LinkSecretP = Bytes64 -module EncryptedLinkSecretP = Bytes64 -module BlindingMasterSeed = Bytes32 -module BlindingMasterSecret = Bytes32 -module WireTransferIdentifierRawP = Bytes32 -module PublicRefreshCoinNonceP = Bytes64 - -(* 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; *) -module DenominationBlindingKeyP = Bytes32 -module RefreshCommitmentP = Bytes64 - -(* -- 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