From 44ddee9dab9b43c11ba63f0d87d402f0c3ed5ce3 Mon Sep 17 00:00:00 2001 From: swrup Date: Thu, 5 Feb 2026 17:03:53 +0100 Subject: [PATCH] rm use of TimeAbsolute in signatures --- src/bin_sig.ml | 152 ++++++++++++++++++++++++------------------------- 1 file changed, 74 insertions(+), 78 deletions(-) diff --git a/src/bin_sig.ml b/src/bin_sig.ml index 1aee423e..76c11e32 100644 --- a/src/bin_sig.ml +++ b/src/bin_sig.ml @@ -27,10 +27,6 @@ module Aliases = struct let bin = Time.Relative.bin_nbo end - (* TODO rm? *) - module TimeAbsolute = Timestamp - module TimeAbsoluteNBO = TimestampNBO - module AmountNBO = struct type t = Amount.t @@ -144,7 +140,7 @@ module DenominationKeyAnnouncement = struct type r = { h_denom_pub: DenominationHash.t; h_section_name: Hash_64_cstr.t; - anchor_time: TimeAbsoluteNBO.t; + anchor_time: TimestampNBO.t; duration_withdraw: TimeRelativeNBO.t; } @@ -159,7 +155,7 @@ module DenominationKeyAnnouncement = struct |+ Purpose.field purpose |+ field DenominationHash.bin (fun t -> t.h_denom_pub) |+ field Hash_64_cstr.bin (fun t -> t.h_section_name) - |+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time) + |+ field TimestampNBO.bin (fun t -> t.anchor_time) |+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw) |> sealr end @@ -173,7 +169,7 @@ module SigningKeyAnnouncement = struct (* purpose.purpose = TALER_SIGNATURE_SM_SIGNING_KEY *) type r = { exchange_pub: ExchangePublicKeyP.t; - anchor_time: TimeAbsoluteNBO.t; + anchor_time: TimestampNBO.t; duration: TimeRelativeNBO.t; } @@ -184,7 +180,7 @@ module SigningKeyAnnouncement = struct { exchange_pub; anchor_time; duration }) |+ Purpose.field purpose |+ field ExchangePublicKeyP.bin (fun t -> t.exchange_pub) - |+ field TimeAbsoluteNBO.bin (fun t -> t.anchor_time) + |+ field TimestampNBO.bin (fun t -> t.anchor_time) |+ field TimeRelativeNBO.bin (fun t -> t.duration) |> sealr end @@ -198,10 +194,10 @@ module DenominationKeyValidity = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY *) type r = { master: MasterPublicKeyP.t; - start: TimeAbsoluteNBO.t; - expire_withdraw: TimeAbsoluteNBO.t; - expire_spend: TimeAbsoluteNBO.t; - expire_legal: TimeAbsoluteNBO.t; + start: TimestampNBO.t; + expire_withdraw: TimestampNBO.t; + expire_spend: TimestampNBO.t; + expire_legal: TimestampNBO.t; value: AmountNBO.t; fee_withdraw: AmountNBO.t; fee_deposit: AmountNBO.t; @@ -241,10 +237,10 @@ module DenominationKeyValidity = struct }) |+ Purpose.field purpose |+ field MasterPublicKeyP.bin (fun t -> t.master) - |+ field TimeAbsoluteNBO.bin (fun t -> t.start) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire_withdraw) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire_spend) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire_legal) + |+ field TimestampNBO.bin (fun t -> t.start) + |+ field TimestampNBO.bin (fun t -> t.expire_withdraw) + |+ field TimestampNBO.bin (fun t -> t.expire_spend) + |+ field TimestampNBO.bin (fun t -> t.expire_legal) |+ field AmountNBO.bin (fun t -> t.value) |+ field AmountNBO.bin (fun t -> t.fee_withdraw) |+ field AmountNBO.bin (fun t -> t.fee_deposit) @@ -261,9 +257,9 @@ module ExchangeSigningKeyValidity = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY *) type r = { - start: TimeAbsoluteNBO.t; - expire: TimeAbsoluteNBO.t; - end_: TimeAbsoluteNBO.t; + start: TimestampNBO.t; + expire: TimestampNBO.t; + end_: TimestampNBO.t; signkey_pub: ExchangePublicKeyP.t; } @@ -274,9 +270,9 @@ module ExchangeSigningKeyValidity = struct record (fun _purpose start expire end_ signkey_pub -> { start; expire; end_; signkey_pub }) |+ Purpose.field purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.start) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire) - |+ field TimeAbsoluteNBO.bin (fun t -> t.end_) + |+ field TimestampNBO.bin (fun t -> t.start) + |+ field TimestampNBO.bin (fun t -> t.expire) + |+ field TimestampNBO.bin (fun t -> t.end_) |+ field ExchangePublicKeyP.bin (fun t -> t.signkey_pub) |> sealr end @@ -327,7 +323,7 @@ module MasterAddAuditor = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_ADD_AUDITOR *) type r = { - start_date: TimeAbsoluteNBO.t; + start_date: TimestampNBO.t; auditor_pub: AuditorPublicKeyP.t; h_auditor_url: Hash_64_cstr.t; } @@ -338,7 +334,7 @@ module MasterAddAuditor = struct record (fun _purpose start_date auditor_pub h_auditor_url -> { start_date; auditor_pub; h_auditor_url }) |+ Purpose.field purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.start_date) + |+ 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) |> sealr @@ -352,7 +348,7 @@ module MasterDelAuditor = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DEL_AUDITOR *) type r = { - end_date: TimeAbsoluteNBO.t; + end_date: TimestampNBO.t; auditor_pub: AuditorPublicKeyP.t; } @@ -361,7 +357,7 @@ module MasterDelAuditor = struct Purpose.make_bin Taler_signatures.master_del_auditor @@ fun purpose -> record (fun _purpose end_date auditor_pub -> { end_date; auditor_pub }) |+ Purpose.field purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.end_date) + |+ field TimestampNBO.bin (fun t -> t.end_date) |+ field AuditorPublicKeyP.bin (fun t -> t.auditor_pub) |> sealr end @@ -374,8 +370,8 @@ module GlobalFees = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_GLOBAL_FEES *) type r = { - start_date: TimeAbsoluteNBO.t; - end_date: TimeAbsoluteNBO.t; + start_date: TimestampNBO.t; + end_date: TimestampNBO.t; purse_timeout: TimeRelativeNBO.t; kyc_timeout: TimeRelativeNBO.t; history_expiration: TimeRelativeNBO.t; @@ -416,8 +412,8 @@ module GlobalFees = struct purse_account_limit; }) |+ Purpose.field purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.start_date) - |+ field TimeAbsoluteNBO.bin (fun t -> t.end_date) + |+ field TimestampNBO.bin (fun t -> t.start_date) + |+ field TimestampNBO.bin (fun t -> t.end_date) |+ field TimeRelativeNBO.bin (fun t -> t.purse_timeout) |+ field TimeRelativeNBO.bin (fun t -> t.kyc_timeout) |+ field TimeRelativeNBO.bin (fun t -> t.history_expiration) @@ -476,7 +472,7 @@ module MasterAddWire = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_ADD_WIRE *) type r = { - start_date: TimeAbsoluteNBO.t; + start_date: TimestampNBO.t; h_wire: FullPaytoHash.t; h_conversion_url: Hash_64_cstr.t; h_credit_restrictions: Hash_64_cstr.t; @@ -503,7 +499,7 @@ module MasterAddWire = struct h_debit_restrictions; }) |+ Purpose.field _purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.start_date) + |+ 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) @@ -519,7 +515,7 @@ module MasterDelWire = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DEL_WIRE *) type r = { - end_date: TimeAbsoluteNBO.t; + end_date: TimestampNBO.t; h_wire: FullPaytoHash.t; } @@ -528,7 +524,7 @@ module MasterDelWire = struct Purpose.make_bin Taler_signatures.master_del_wire @@ fun _purpose -> record (fun _purpose end_date h_wire -> { end_date; h_wire }) |+ Purpose.field _purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.end_date) + |+ field TimestampNBO.bin (fun t -> t.end_date) |+ field FullPaytoHash.bin (fun t -> t.h_wire) |> sealr end @@ -542,7 +538,7 @@ module MasterDrainProfit = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DRAIN_PROFITS *) type r = { wtid: WireTransferIdentifierRawP.t; - date: TimeAbsoluteNBO.t; + date: TimestampNBO.t; amount: AmountNBO.t; h_section: Hash_64_cstr.t; h_payto: FullPaytoHash.t; @@ -555,7 +551,7 @@ module MasterDrainProfit = struct { wtid; date; amount; h_section; h_payto }) |+ Purpose.field _purpose |+ field WireTransferIdentifierRawP.bin (fun t -> t.wtid) - |+ field TimeAbsoluteNBO.bin (fun t -> t.date) + |+ 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 FullPaytoHash.bin (fun t -> t.h_payto) @@ -641,8 +637,8 @@ module WadPartnerSignature = struct type r = { h_partner_base_url: Hash_64_cstr.t; master_public_key: MasterPublicKeyP.t; - start_date: TimeAbsoluteNBO.t; - end_date: TimeAbsoluteNBO.t; + start_date: TimestampNBO.t; + end_date: TimestampNBO.t; wad_fee: AmountNBO.t; wad_frequency: TimeRelativeNBO.t; } @@ -672,8 +668,8 @@ module WadPartnerSignature = struct |+ Purpose.field _purpose |+ field Hash_64_cstr.bin (fun t -> t.h_partner_base_url) |+ field MasterPublicKeyP.bin (fun t -> t.master_public_key) - |+ field TimeAbsoluteNBO.bin (fun t -> t.start_date) - |+ field TimeAbsoluteNBO.bin (fun t -> t.end_date) + |+ field TimestampNBO.bin (fun t -> t.start_date) + |+ field TimestampNBO.bin (fun t -> t.end_date) |+ field AmountNBO.bin (fun t -> t.wad_fee) |+ field TimeRelativeNBO.bin (fun t -> t.wad_frequency) |> sealr @@ -688,8 +684,8 @@ module MasterWireFee = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_FEES *) type r = { h_wire_method: Hash_64_cstr.t; - start_date: TimeAbsoluteNBO.t; - end_date: TimeAbsoluteNBO.t; + start_date: TimestampNBO.t; + end_date: TimestampNBO.t; wire_fee: AmountNBO.t; closing_fee: AmountNBO.t; } @@ -702,8 +698,8 @@ module MasterWireFee = struct { 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 TimeAbsoluteNBO.bin (fun t -> t.start_date) - |+ field TimeAbsoluteNBO.bin (fun t -> t.end_date) + |+ field TimestampNBO.bin (fun t -> t.start_date) + |+ field TimestampNBO.bin (fun t -> t.end_date) |+ field AmountNBO.bin (fun t -> t.wire_fee) |+ field AmountNBO.bin (fun t -> t.closing_fee) |> sealr @@ -719,10 +715,10 @@ module ExchangeKeyValidity = struct type r = { auditor_url_hash: Hash_64_cstr.t; master: MasterPublicKeyP.t; - start: TimeAbsoluteNBO.t; - expire_withdraw: TimeAbsoluteNBO.t; - expire_spend: TimeAbsoluteNBO.t; - expire_legal: TimeAbsoluteNBO.t; + start: TimestampNBO.t; + expire_withdraw: TimestampNBO.t; + expire_spend: TimestampNBO.t; + expire_legal: TimestampNBO.t; value: AmountNBO.t; fee_withdraw: AmountNBO.t; fee_deposit: AmountNBO.t; @@ -764,10 +760,10 @@ module ExchangeKeyValidity = struct |+ Purpose.field _purpose |+ field Hash_64_cstr.bin (fun t -> t.auditor_url_hash) |+ field MasterPublicKeyP.bin (fun t -> t.master) - |+ field TimeAbsoluteNBO.bin (fun t -> t.start) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire_withdraw) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire_spend) - |+ field TimeAbsoluteNBO.bin (fun t -> t.expire_legal) + |+ field TimestampNBO.bin (fun t -> t.start) + |+ field TimestampNBO.bin (fun t -> t.expire_withdraw) + |+ field TimestampNBO.bin (fun t -> t.expire_spend) + |+ field TimestampNBO.bin (fun t -> t.expire_legal) |+ field AmountNBO.bin (fun t -> t.value) |+ field AmountNBO.bin (fun t -> t.fee_withdraw) |+ field AmountNBO.bin (fun t -> t.fee_deposit) @@ -784,7 +780,7 @@ module ExchangeKeySet = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_KEY_SET *) type r = { - list_issue_date: TimeAbsoluteNBO.t; + list_issue_date: TimestampNBO.t; hc: Hash_64.t; } @@ -793,7 +789,7 @@ module ExchangeKeySet = struct Purpose.make_bin Taler_signatures.exchange_key_set @@ fun _purpose -> record (fun _purpose list_issue_date hc -> { list_issue_date; hc }) |+ Purpose.field _purpose - |+ field TimeAbsoluteNBO.bin (fun t -> t.list_issue_date) + |+ field TimestampNBO.bin (fun t -> t.list_issue_date) |+ field Hash_64.bin (fun t -> t.hc) |> sealr end @@ -870,8 +866,8 @@ module DepositRequest = struct h_policy: ExtensionsPolicyHash.t; h_wire: MerchantWireHash.t; h_denom_pub: DenominationHash.t; - timestamp: TimeAbsoluteNBO.t; - refund_deadline: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; + refund_deadline: TimestampNBO.t; amount_with_fee: AmountNBO.t; deposit_fee: AmountNBO.t; merchant: MerchantPublicKeyP.t; @@ -885,8 +881,8 @@ module DepositConfirmation = struct h_contract_terms: PrivateContractHash.t; h_wire: MerchantWireHash.t; h_policy: ExtensionsPolicyHash.t; - timestamp: TimeAbsoluteNBO.t; - refund_deadline: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; + refund_deadline: TimestampNBO.t; amount_without_fee: AmountNBO.t; coin_pub: CoinSpendPublicKeyP.t; merchant: MerchantPublicKeyP.t; @@ -924,7 +920,7 @@ end module WireDepositDetailP = struct type t = { h_contract_terms: PrivateContractHash.t; - execution_time: TimeAbsoluteNBO.t; + execution_time: TimestampNBO.t; coin_pub: CoinSpendPublicKeyP.t; deposit_value: AmountNBO.t; deposit_fee: AmountNBO.t; @@ -959,7 +955,7 @@ module ConfirmWire = struct h_contract_terms: PrivateContractHash.t; wtid: WireTransferIdentifierRawP.t; coin_pub: CoinSpendPublicKeyP.t; - execution_time: TimeAbsoluteNBO.t; + execution_time: TimestampNBO.t; coin_contribution: AmountNBO.t; } end @@ -1013,7 +1009,7 @@ end module RecoupRefreshConfirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH *) type t = { - timestamp: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; recoup_amount: AmountNBO.t; coin_pub: CoinSpendPublicKeyP.t; old_coin_pub: CoinSpendPublicKeyP.t; @@ -1023,7 +1019,7 @@ end module RecoupConfirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP *) type t = { - timestamp: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; recoup_amount: AmountNBO.t; coin_pub: CoinSpendPublicKeyP.t; reserve_pub: ReservePublicKeyP.t; @@ -1033,7 +1029,7 @@ end module DenominationUnknownAffirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_AFFIRM_DENOM_UNKNOWN *) type t = { - timestamp: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; h_denom_pub: DenominationHash.t; } end @@ -1041,7 +1037,7 @@ end module DenominationExpiredAffirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_GENERIC_DENOMINATIN_EXPIRED *) type t = { - timestamp: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; operation: string; (* char[8] → string *) h_denom_pub: DenominationHash.t; } @@ -1050,7 +1046,7 @@ end module ReserveCloseConfirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED *) type t = { - timestamp: TimeAbsoluteNBO.t; + timestamp: TimestampNBO.t; closing_amount: AmountNBO.t; reserve_pub: ReservePublicKeyP.t; h_wire: FullPaytoHash.t; @@ -1074,14 +1070,14 @@ end module ReserveStatusRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_RESERVE_STATUS_REQUEST *) - type t = { request_timestamp: TimeAbsoluteNBO.t } + type t = { request_timestamp: TimestampNBO.t } end module ReserveHistoryRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_RESERVE_HISTORY_REQUEST *) type t = { history_fee: AmountNBO.t; - request_timestamp: TimeAbsoluteNBO.t; + request_timestamp: TimestampNBO.t; } end @@ -1096,8 +1092,8 @@ module PurseStatusResponseSignature = struct total_purse_amount: AmountNBO.t; total_deposit_amount: AmountNBO.t; max_deposit_fees: AmountNBO.t; - purse_expiration: TimeAbsoluteNBO.t; - status_timestamp: TimeAbsoluteNBO.t; + purse_expiration: TimestampNBO.t; + status_timestamp: TimestampNBO.t; h_contract_terms: PrivateContractHash.t; } end @@ -1110,7 +1106,7 @@ end module PurseRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_PURSE_CREATE *) type t = { - purse_expiration: TimeAbsoluteNBO.t; + purse_expiration: TimestampNBO.t; merge_value_after_fees: AmountNBO.t; h_contract_terms: PrivateContractHash.t; min_age: int; @@ -1142,7 +1138,7 @@ module PurseDepositConfirmedSignature = struct total_purse_amount: AmountNBO.t; total_deposit_fees: AmountNBO.t; purse_pub: PursePublicKey.t; - purse_expiration: TimeAbsoluteNBO.t; + purse_expiration: TimestampNBO.t; h_contract_terms: PrivateContractHash.t; } end @@ -1150,7 +1146,7 @@ end module PurseMergeSignature = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_PURSE_MERGE *) type t = { - merge_timestamp: TimeAbsoluteNBO.t; + merge_timestamp: TimestampNBO.t; h_wire: NormalizedPaytoHash.t; } end @@ -1161,8 +1157,8 @@ module AccountMergeSignature = struct reserve_pub: ReservePublicKeyP.t; purse_pub: PursePublicKey.t; merge_amount_after_fees: AmountNBO.t; - merge_timestamp: TimeAbsoluteNBO.t; - purse_expiration: TimeAbsoluteNBO.t; + merge_timestamp: TimestampNBO.t; + purse_expiration: TimestampNBO.t; h_contract_terms: PrivateContractHash.t; min_age: int; } @@ -1179,7 +1175,7 @@ module PurseMergeSuccessSignature = struct reserve_pub: ReservePublicKeyP.t; purse_pub: PursePublicKey.t; merge_amount_after_fees: AmountNBO.t; - contract_time: TimeAbsoluteNBO.t; + contract_time: TimestampNBO.t; h_contract_terms: PrivateContractHash.t; h_wire: NormalizedPaytoHash.t; min_age: int; @@ -1189,7 +1185,7 @@ end module WadDataSignature = struct (* purpose.purpose = TALER_SIGNATURE_WAD_DATA *) type t = { - wad_execution_time: TimeAbsoluteNBO.t; + wad_execution_time: TimestampNBO.t; total_amount: AmountNBO.t; h_items: Hash_64_cstr.t; wad_id: WadId.t; @@ -1199,8 +1195,8 @@ end module P2PFees = struct (* purpose.purpose = TALER_SIGNATURE_P2P_FEES *) type t = { - start_date: TimeAbsoluteNBO.t; - end_date: TimeAbsoluteNBO.t; + start_date: TimestampNBO.t; + end_date: TimestampNBO.t; kyc_fee: AmountNBO.t; purse_fee: AmountNBO.t; account_history_fee: AmountNBO.t;