From ef6a208273422d9fa0e2cd16ff96b99a07153952 Mon Sep 17 00:00:00 2001 From: swrup Date: Tue, 7 Oct 2025 01:02:50 +0200 Subject: [PATCH] --- src/binary_formats.ml | 82 ++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 55 deletions(-) diff --git a/src/binary_formats.ml b/src/binary_formats.ml index 75a8b47f..50e71f07 100644 --- a/src/binary_formats.ml +++ b/src/binary_formats.ml @@ -59,69 +59,41 @@ module Short_hash_code = struct record (fun hash -> { hash }) |+ field (bytes 32) (fun t -> t.hash) |> sealr end -module Denomination_hash = struct - type t = { hash: Hash_code.t } +module MAKE_H (H : sig + type t + + val bin : t Bin.t +end) = +struct + type t = { hash: H.t } let bin = let open Bin in - record (fun hash -> { hash }) - |+ field Hash_code.bin (fun t -> t.hash) - |> sealr + record (fun hash -> { hash }) |+ field H.bin (fun t -> t.hash) |> sealr end -module Private_contract_hash = struct - type t = { hash: Hash_code.t } +module Denomination_hash = MAKE_H (Hash_code) +module Private_contract_hash = MAKE_H (Hash_code) +module Extensions_policy_hash = MAKE_H (Hash_code) +module Merchant_wire_hash = MAKE_H (Hash_code) - let bin = - let open Bin in - record (fun hash -> { hash }) - |+ field Hash_code.bin (fun t -> t.hash) - |> sealr -end +(* Hash over a full payto://-URI, including receiver-name + (and possibly BIC and other optional fields). *) +module Full_payto_hash = MAKE_H (Short_hash_code) -module Extensions_policy_hash = struct - type t = { hash: Hash_code.t } +(* Hash over a normalized payto://-URI, including all optional + fields and also with account-part canonicalized (so no BIC). *) +module Normalized_payto_hash = MAKE_H (Short_hash_code) - let bin = - let open Bin in - record (fun hash -> { hash }) - |+ field Hash_code.bin (fun t -> t.hash) - |> sealr -end - -module Merchant_wire_hash = struct - type t = { hash: Hash_code.t } - - let bin = - let open Bin in - record (fun hash -> { hash }) - |+ field Hash_code.bin (fun t -> t.hash) - |> sealr -end - -module Full_payto_hash = struct - (* Hash over a full payto://-URI, including receiver-name - (and possibly BIC and other optional fields). *) - type t = { hash: Short_hash_code.t } - - let bin = - let open Bin in - record (fun hash -> { hash }) - |+ field Short_hash_code.bin (fun t -> t.hash) - |> sealr -end - -module Normalized_payto_hash = struct - (* Hash over a normalized payto://-URI, including all optional - fields and also with account-part canonicalized (so no BIC). *) - type t = { hash: Short_hash_code.t } - - let bin = - let open Bin in - record (fun hash -> { hash }) - |+ field Short_hash_code.bin (fun t -> t.hash) - |> sealr -end +(* Hash over: + a) the hash of the denomination's public key, + b) an enum value identifying the cipher, and + c) cipher-dependant blinded information. + See implementation of `TALER_coin_ev_hash` + in libtalerexchange for details. *) +module Blinded_coin_hash = MAKE_H (Hash_code) +module Coin_pub_hash = MAKE_H (Hash_code) +module Output_commitment_hash = MAKE_H (Hash_code) (* -- Signatures -- *)