This commit is contained in:
swrup 2026-02-05 17:57:27 +01:00
parent 258db38b52
commit d2a0ff93dc

View file

@ -8,6 +8,18 @@
open Digestif
module type S = sig
type t
val bin : t Bin.t
val caqti : t Caqti_type.t
val jsont : t Jsont.t
val hash : string -> t
val of_octets : string -> t
val to_octets : t -> string
val of_b32 : B32.t -> (t, string) result
end
module H32 = struct
type t = SHA256.t
@ -74,42 +86,32 @@ module H64 = struct
end
(* Hash over string + '\0' *)
module H32_cstr = struct
include H32
module Cstring = struct
module H32 = struct
include H32
let hash s =
let s = s ^ "\x00" in
SHA256.(digest_string s)
let hash s =
let s = s ^ "\x00" in
hash s
end
module H64 = struct
include H64
let hash s =
let s = s ^ "\x00" in
hash s
end
end
module H64_cstr = struct
include H64
let hash s =
let s = s ^ "\x00" in
SHA512.(digest_string s)
end
module type Hash_S = sig
type t
val bin : t Bin.t
val caqti : t Caqti_type.t
val jsont : t Jsont.t
val hash : string -> t
val of_octets : string -> t
val to_octets : t -> string
val of_b32 : B32.t -> (t, string) result
end
module FullPaytoHash : Hash_S = H32
module NormalizedPaytoHash : Hash_S = H32
module DenominationHash : Hash_S = H64
module PrivateContractHash : Hash_S = H64
module ExtensionsPolicyHash : Hash_S = H64
module MerchantWireHash : Hash_S = H64
module AgeCommitmentHash : Hash_S = H64
module BlindedCoinHash : Hash_S = H64
module CoinPubHash : Hash_S = H64
module OutputCommitmentHash : Hash_S = H64
module HashPlanchetsP : Hash_S = H64
module FullPaytoHash : S = H32
module NormalizedPaytoHash : S = H32
module DenominationHash : S = H64
module PrivateContractHash : S = H64
module ExtensionsPolicyHash : S = H64
module MerchantWireHash : S = H64
module AgeCommitmentHash : S = H64
module BlindedCoinHash : S = H64
module CoinPubHash : S = H64
module OutputCommitmentHash : S = H64
module HashPlanchetsP : S = H64