add hash.ml + refacto

This commit is contained in:
swrup 2026-02-05 17:51:24 +01:00 committed by Swrup
parent 44ddee9dab
commit 34f98b697f
11 changed files with 193 additions and 199 deletions

View file

@ -1,6 +1,7 @@
(* Packed Signature *)
open Bin_type
open Hash
module Aliases = struct
module Timestamp = struct
@ -139,7 +140,7 @@ module DenominationKeyAnnouncement = struct
(* purpose.purpose = TALER_SIGNATURE_SM_DENOMINATION_KEY *)
type r = {
h_denom_pub: DenominationHash.t;
h_section_name: Hash_64_cstr.t;
h_section_name: Hash.Cstring.H64.t;
anchor_time: TimestampNBO.t;
duration_withdraw: TimeRelativeNBO.t;
}
@ -154,7 +155,7 @@ module DenominationKeyAnnouncement = struct
{ h_denom_pub; h_section_name; anchor_time; duration_withdraw })
|+ Purpose.field purpose
|+ field DenominationHash.bin (fun t -> t.h_denom_pub)
|+ field Hash_64_cstr.bin (fun t -> t.h_section_name)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_section_name)
|+ field TimestampNBO.bin (fun t -> t.anchor_time)
|+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw)
|> sealr
@ -325,7 +326,7 @@ module MasterAddAuditor = struct
type r = {
start_date: TimestampNBO.t;
auditor_pub: AuditorPublicKeyP.t;
h_auditor_url: Hash_64_cstr.t;
h_auditor_url: Hash.Cstring.H64.t;
}
let bin =
@ -336,7 +337,7 @@ module MasterAddAuditor = struct
|+ Purpose.field purpose
|+ field TimestampNBO.bin (fun t -> t.start_date)
|+ field AuditorPublicKeyP.bin (fun t -> t.auditor_pub)
|+ field Hash_64_cstr.bin (fun t -> t.h_auditor_url)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_auditor_url)
|> sealr
end
@ -434,9 +435,9 @@ module MasterWireDetails = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_DETAILS *)
type r = {
h_wire_details: FullPaytoHash.t;
h_conversion_url: Hash_64_cstr.t;
h_credit_restrictions: Hash_64_cstr.t;
h_debit_restrictions: Hash_64_cstr.t;
h_conversion_url: Hash.Cstring.H64.t;
h_credit_restrictions: Hash.Cstring.H64.t;
h_debit_restrictions: Hash.Cstring.H64.t;
}
let bin =
@ -458,9 +459,9 @@ module MasterWireDetails = struct
})
|+ Purpose.field purpose
|+ field FullPaytoHash.bin (fun t -> t.h_wire_details)
|+ field Hash_64_cstr.bin (fun t -> t.h_conversion_url)
|+ field Hash_64_cstr.bin (fun t -> t.h_credit_restrictions)
|+ field Hash_64_cstr.bin (fun t -> t.h_debit_restrictions)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_conversion_url)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_credit_restrictions)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_debit_restrictions)
|> sealr
end
@ -474,9 +475,9 @@ module MasterAddWire = struct
type r = {
start_date: TimestampNBO.t;
h_wire: FullPaytoHash.t;
h_conversion_url: Hash_64_cstr.t;
h_credit_restrictions: Hash_64_cstr.t;
h_debit_restrictions: Hash_64_cstr.t;
h_conversion_url: Hash.Cstring.H64.t;
h_credit_restrictions: Hash.Cstring.H64.t;
h_debit_restrictions: Hash.Cstring.H64.t;
}
let bin =
@ -501,9 +502,9 @@ module MasterAddWire = struct
|+ Purpose.field _purpose
|+ field TimestampNBO.bin (fun t -> t.start_date)
|+ field FullPaytoHash.bin (fun t -> t.h_wire)
|+ field Hash_64_cstr.bin (fun t -> t.h_conversion_url)
|+ field Hash_64_cstr.bin (fun t -> t.h_credit_restrictions)
|+ field Hash_64_cstr.bin (fun t -> t.h_debit_restrictions)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_conversion_url)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_credit_restrictions)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_debit_restrictions)
|> sealr
end
@ -540,7 +541,7 @@ module MasterDrainProfit = struct
wtid: WireTransferIdentifierRawP.t;
date: TimestampNBO.t;
amount: AmountNBO.t;
h_section: Hash_64_cstr.t;
h_section: Hash.Cstring.H64.t;
h_payto: FullPaytoHash.t;
}
@ -553,7 +554,7 @@ module MasterDrainProfit = struct
|+ field WireTransferIdentifierRawP.bin (fun t -> t.wtid)
|+ field TimestampNBO.bin (fun t -> t.date)
|+ field AmountNBO.bin (fun t -> t.amount)
|+ field Hash_64_cstr.bin (fun t -> t.h_section)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_section)
|+ field FullPaytoHash.bin (fun t -> t.h_payto)
|> sealr
end
@ -568,7 +569,7 @@ module MasterAmlOfficerStatus = struct
type r = {
change_date: TimestampNBO.t;
officer_pub: AmlOfficerPublicKeyP.t;
h_officer_name: Hash_64_cstr.t;
h_officer_name: Hash.Cstring.H64.t;
is_active: int32;
}
@ -580,7 +581,7 @@ module MasterAmlOfficerStatus = struct
|+ Purpose.field _purpose
|+ field TimestampNBO.bin (fun t -> t.change_date)
|+ field AmlOfficerPublicKeyP.bin (fun t -> t.officer_pub)
|+ field Hash_64_cstr.bin (fun t -> t.h_officer_name)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_officer_name)
|+ field beint32 (fun t -> t.is_active)
|> sealr
end
@ -600,7 +601,7 @@ module PartnerConfiguration = struct
end_date: TimestampNBO.t;
wad_frequency: TimeRelativeNBO.t;
wad_fee: AmountNBO.t;
h_url: Hash_64_cstr.t;
h_url: Hash.Cstring.H64.t;
}
let bin =
@ -623,7 +624,7 @@ module PartnerConfiguration = struct
|+ field TimestampNBO.bin (fun t -> t.end_date)
|+ field TimeRelativeNBO.bin (fun t -> t.wad_frequency)
|+ field AmountNBO.bin (fun t -> t.wad_fee)
|+ field Hash_64_cstr.bin (fun t -> t.h_url)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_url)
|> sealr
end
@ -635,7 +636,7 @@ module WadPartnerSignature = struct
module R = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_PARTNER_DETAILS *)
type r = {
h_partner_base_url: Hash_64_cstr.t;
h_partner_base_url: Hash.Cstring.H64.t;
master_public_key: MasterPublicKeyP.t;
start_date: TimestampNBO.t;
end_date: TimestampNBO.t;
@ -666,7 +667,7 @@ module WadPartnerSignature = struct
wad_frequency;
})
|+ Purpose.field _purpose
|+ field Hash_64_cstr.bin (fun t -> t.h_partner_base_url)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_partner_base_url)
|+ field MasterPublicKeyP.bin (fun t -> t.master_public_key)
|+ field TimestampNBO.bin (fun t -> t.start_date)
|+ field TimestampNBO.bin (fun t -> t.end_date)
@ -683,7 +684,7 @@ module MasterWireFee = struct
module R = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_FEES *)
type r = {
h_wire_method: Hash_64_cstr.t;
h_wire_method: Hash.Cstring.H64.t;
start_date: TimestampNBO.t;
end_date: TimestampNBO.t;
wire_fee: AmountNBO.t;
@ -697,7 +698,7 @@ module MasterWireFee = struct
(fun _purpose h_wire_method start_date end_date wire_fee closing_fee ->
{ h_wire_method; start_date; end_date; wire_fee; closing_fee })
|+ Purpose.field _purpose
|+ field Hash_64_cstr.bin (fun t -> t.h_wire_method)
|+ field Hash.Cstring.H64.bin (fun t -> t.h_wire_method)
|+ field TimestampNBO.bin (fun t -> t.start_date)
|+ field TimestampNBO.bin (fun t -> t.end_date)
|+ field AmountNBO.bin (fun t -> t.wire_fee)
@ -713,7 +714,7 @@ module ExchangeKeyValidity = struct
module R = struct
(* purpose.purpose = TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS *)
type r = {
auditor_url_hash: Hash_64_cstr.t;
auditor_url_hash: Hash.Cstring.H64.t;
master: MasterPublicKeyP.t;
start: TimestampNBO.t;
expire_withdraw: TimestampNBO.t;
@ -758,7 +759,7 @@ module ExchangeKeyValidity = struct
denom_hash;
})
|+ Purpose.field _purpose
|+ field Hash_64_cstr.bin (fun t -> t.auditor_url_hash)
|+ field Hash.Cstring.H64.bin (fun t -> t.auditor_url_hash)
|+ field MasterPublicKeyP.bin (fun t -> t.master)
|+ field TimestampNBO.bin (fun t -> t.start)
|+ field TimestampNBO.bin (fun t -> t.expire_withdraw)
@ -781,7 +782,8 @@ module ExchangeKeySet = struct
(* purpose.purpose = TALER_SIGNATURE_EXCHANGE_KEY_SET *)
type r = {
list_issue_date: TimestampNBO.t;
hc: Hash_64.t;
(* hash over a concatenation of master_sigs *)
hc: H64.t;
}
let bin =
@ -790,7 +792,7 @@ module ExchangeKeySet = struct
record (fun _purpose list_issue_date hc -> { list_issue_date; hc })
|+ Purpose.field _purpose
|+ field TimestampNBO.bin (fun t -> t.list_issue_date)
|+ field Hash_64.bin (fun t -> t.hc)
|+ field H64.bin (fun t -> t.hc)
|> sealr
end
@ -871,7 +873,7 @@ module DepositRequest = struct
amount_with_fee: AmountNBO.t;
deposit_fee: AmountNBO.t;
merchant: MerchantPublicKeyP.t;
wallet_data_hash: Hash_64_cstr.t;
wallet_data_hash: Hash.Cstring.H64.t;
}
end
@ -934,7 +936,7 @@ module WireDepositData = struct
wire_fee: AmountNBO.t;
merchant_pub: MerchantPublicKeyP.t;
h_wire: MerchantWireHash.t;
h_details: Hash_64_cstr.t;
h_details: Hash.Cstring.H64.t;
}
end
@ -995,7 +997,7 @@ end
module MerchantRefundConfirmation = struct
(* purpose.purpose = TALER_SIGNATURE_MERCHANT_REFUND_OK *)
(* Hash of the order ID (a string), hashed without the 0-termination. *)
type t = { h_order_id: Hash_64_cstr.t }
type t = { h_order_id: Hash.Cstring.H64.t }
end
module RecoupRequest = struct
@ -1120,7 +1122,7 @@ module PurseDepositSignature = struct
h_denom_pub: DenominationHash.t;
h_age_commitment: AgeCommitmentHash.t;
purse_pub: PursePublicKey.t;
h_exchange_base_url: Hash_64_cstr.t;
h_exchange_base_url: Hash.Cstring.H64.t;
}
end
@ -1187,7 +1189,7 @@ module WadDataSignature = struct
type t = {
wad_execution_time: TimestampNBO.t;
total_amount: AmountNBO.t;
h_items: Hash_64_cstr.t;
h_items: Hash.Cstring.H64.t;
wad_id: WadId.t;
}
end
@ -1220,11 +1222,11 @@ end
module AmlDecision = struct
(* purpose.purpose = TALER_SIGNATURE_AML_DECISION *)
type t = {
h_justification: Hash_64_cstr.t;
h_justification: Hash.Cstring.H64.t;
decision_time: TimestampNBO.t;
new_threshold: AmountNBO.t;
h_payto: NormalizedPaytoHash.t;
h_kyc_requirements: Hash_64_cstr.t;
h_kyc_requirements: Hash.Cstring.H64.t;
new_state: int;
}
end
@ -1251,7 +1253,7 @@ module ReserveAttestRequest = struct
(* purpose.purpose = TALER_SIGNATURE_WALLET_ATTEST_REQUEST *)
type t = {
request_timestamp: TimestampNBO.t;
h_details: Hash_64_cstr.t;
h_details: Hash.Cstring.H64.t;
}
end
@ -1261,6 +1263,6 @@ module ExchangeAttest = struct
attest_timestamp: TimestampNBO.t;
expiration_time: TimestampNBO.t;
reserve_pub: ReservePublicKeyP.t;
h_attributes: Hash_64_cstr.t;
h_attributes: Hash.Cstring.H64.t;
}
end