use correct denomination hash

This commit is contained in:
swrup 2026-02-27 23:36:05 +01:00 committed by Swrup
parent 6bba30e6be
commit 71b9d59174
14 changed files with 142 additions and 61 deletions

View file

@ -10,6 +10,7 @@ module type S = sig
val of_octets : string -> t
val to_octets : t -> string
val of_b32 : B32.t -> (t, string) result
val to_b32 : t -> B32.t
end
module H32 = struct
@ -24,6 +25,7 @@ module H32 = struct
let to_octets = SHA256.to_raw_string
let of_b32 s = Result.map of_octets (B32.decode s)
let to_b32 t = B32.encode (to_octets t)
let bin =
let open Bin in
@ -37,9 +39,7 @@ module H32 = struct
~decode:(fun v -> Ok (of_octets v))
octets
let jsont =
let enc v = B32.encode (to_octets v) in
Jsont.of_of_string ~kind:"Hash 32" of_b32 ~enc
let jsont = Jsont.of_of_string ~kind:"Hash 32" of_b32 ~enc:to_b32
end
module H64 = struct
@ -54,6 +54,7 @@ module H64 = struct
let to_octets = SHA512.to_raw_string
let of_b32 s = Result.map of_octets (B32.decode s)
let to_b32 t = B32.encode (to_octets t)
let bin =
let open Bin in
@ -67,9 +68,7 @@ module H64 = struct
~decode:(fun v -> Ok (of_octets v))
octets
let jsont =
let enc v = B32.encode (to_octets v) in
Jsont.of_of_string ~kind:"Hash 64" of_b32 ~enc
let jsont = Jsont.of_of_string ~kind:"Hash 64" of_b32 ~enc:to_b32
end
(* C-terminated strings
@ -92,7 +91,6 @@ end
check which hash algorithm to use for each hash type *)
module FullPaytoHash : S = H32
module NormalizedPaytoHash : S = H32
module DenominationHash : S = H64
module PrivateContractHash : S = H64
module ExtensionsPolicyHash : S = H64
module MerchantWireHash : S = H64