rollback on master pub sigs refacto

This commit is contained in:
swrup 2026-02-23 04:35:42 +01:00 committed by Swrup
parent 05f4b39a7b
commit 4a66ce5932
2 changed files with 40 additions and 49 deletions

View file

@ -20,7 +20,7 @@ module Keys_post = struct
let verify_dn (module Keys : Keys.S) fdn denom_hash master_sig =
let open FutureDenom in
let open Signatures.DenominationKeyValidity in
let r =
verify Config.master_public_key master_sig
{
R.master= Config.master_public_key;
start= fdn.stamp_start;
@ -34,8 +34,6 @@ module Keys_post = struct
fee_refund= fdn.fee_refund;
denom_hash;
}
in
verify master_sig r
let verify_denom_sigs (module Keys : Keys.S) denom_sigs =
let* fdn_l = Keys.future_denominations () in
@ -62,15 +60,13 @@ module Keys_post = struct
{ key; stamp_start; stamp_expire; stamp_end; signkey_secmod_sig= _ }
master_sig =
let open Signatures.ExchangeSigningKeyValidity in
let r =
verify Config.master_public_key master_sig
{
R.start= stamp_start;
expire= stamp_expire;
end_= stamp_end;
signkey_pub= key;
}
in
verify master_sig r
let verify_signkey_sigs (module Keys : Keys.S) signkey_sigs =
let* fsk_l = Keys.future_signkeys () in
@ -121,7 +117,7 @@ module Denom_revoke = struct
let verify (module Keys : Keys.S) h_denom_pub
DenomRevocationSignature.{ master_sig } =
let open Signatures.MasterDenominationKeyRevocation in
verify master_sig { h_denom_pub }
verify Config.master_public_key master_sig { h_denom_pub }
let do_ (module Keys : Keys.S) h_denom_pub
DenomRevocationSignature.{ master_sig } =
@ -147,7 +143,7 @@ module Signkey_revoke = struct
let verify (module Keys : Keys.S) exchange_pub
SignkeyRevocationSignature.{ master_sig } =
let open Signatures.MasterSigningKeyRevocation in
verify master_sig { exchange_pub }
verify Config.master_public_key master_sig { exchange_pub }
let do_ (module Keys : Keys.S) exchange_pub
SignkeyRevocationSignature.{ master_sig } =
@ -180,7 +176,7 @@ module Auditors = struct
validity_start;
} =
let open Signatures.MasterAddAuditor in
verify master_sig
verify Config.master_public_key master_sig
{
start_date= validity_start;
auditor_pub;
@ -227,7 +223,8 @@ module Auditors_disable = struct
let verify (module Keys : Keys.S) auditor_pub
AuditorTeardownMessage.{ master_sig; validity_end } =
let open Signatures.MasterDelAuditor in
verify master_sig { end_date= validity_end; auditor_pub }
verify Config.master_public_key master_sig
{ end_date= validity_end; auditor_pub }
let do_ ~db_conn auditor_pub
AuditorTeardownMessage.{ master_sig= _; validity_end } =
@ -275,7 +272,7 @@ module Wire_fee = struct
wire_fee;
} =
let open Signatures.MasterWireFee in
verify master_sig_wire
verify Config.master_public_key master_sig_wire
{
h_wire_method= Hash.Cstring.H64.hash wire_method;
start_date= fee_start;
@ -337,7 +334,7 @@ module Global_fees = struct
master_sig;
} =
let open Signatures.GlobalFees in
verify master_sig
verify Config.master_public_key master_sig
{
start_date;
end_date;
@ -410,7 +407,7 @@ module Wire = struct
let debit_restrictions = "" in
let* () =
let open Signatures.MasterWireDetails in
verify master_sig_wire
verify Config.master_public_key master_sig_wire
{
h_wire_details= FullPaytoHash.hash payto_uri;
h_conversion_url= Hash.Cstring.H64.hash conversion_url;
@ -420,7 +417,7 @@ module Wire = struct
in
let* () =
let open Signatures.MasterAddWire in
verify master_sig_add
verify Config.master_public_key master_sig_add
{
start_date= validity_start;
h_wire= FullPaytoHash.hash payto_uri;
@ -476,7 +473,7 @@ module Wire_disable = struct
let verify (module Keys : Keys.S)
WireTeardownMessage.{ payto_uri; master_sig_del; validity_end } =
let open Signatures.MasterDelWire in
verify master_sig_del
verify Config.master_public_key master_sig_del
{ end_date= validity_end; h_wire= FullPaytoHash.hash payto_uri }
let do_ ~db_conn
@ -519,7 +516,7 @@ module Drain = struct
amount;
} =
let open Signatures.MasterDrainProfit in
verify master_sig
verify Config.master_public_key master_sig
{
wtid;
date;
@ -560,7 +557,7 @@ module AmlOfficer = struct
} =
let open Signatures.MasterAmlOfficerStatus in
let is_active = match is_active with true -> 1_l | false -> 0_l in
verify master_sig
verify Config.master_public_key master_sig
{
change_date;
officer_pub;
@ -600,7 +597,7 @@ module Partners = struct
wad_fee;
} =
let open Signatures.PartnerConfiguration in
verify master_sig
verify Config.master_public_key master_sig
{
partner_pub;
start_date;

View file

@ -145,33 +145,33 @@ end
(* --- Packed Signatures --- *)
module type R = sig
module MK (R : sig
type r
val bin : r Bin.t
end
module type SIGNATURE = sig
end) : sig
open Crypto
type r
type t
(* record type of data to sign *)
type r = R.r
val signf : (string -> EddsaSignature.t) -> r -> t
(* type of signature over r *)
type t
(* todo
- type for unknown/verified signatures? (nk/ok) *)
val verify : EddsaPublicKey.t -> t -> r -> (unit, string) result
val signf : (string -> EddsaSignature.t) -> r -> t
val jsont : t Jsont.t
val caqti : t Caqti_type.t
(* escape hatch, only needed for /keys `exchange_sig` (signature over contatentation of all of the master_sigs) *)
(* only needed for /keys `exchange_sig`
(signature over contatentation of all of the master_sigs) *)
val to_octets : t -> string
end
module MK (R : R) : SIGNATURE with type r := R.r = struct
end = struct
open Crypto
type r = R.r
type t = EddsaSignature.t
let to_string = Bin.to_string R.bin
@ -182,12 +182,6 @@ module MK (R : R) : SIGNATURE with type r := R.r = struct
let to_octets t = EddsaSignature.to_octets t
end
module MK_master_sig (R : R) = struct
include MK (R)
let verify = verify Config.Exchange.master_public_key
end
(* ---- *)
module DenominationKeyAnnouncement = struct
@ -309,7 +303,7 @@ module DenominationKeyValidity = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module ExchangeSigningKeyValidity = struct
@ -336,7 +330,7 @@ module ExchangeSigningKeyValidity = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterDenominationKeyRevocation = struct
@ -354,7 +348,7 @@ module MasterDenominationKeyRevocation = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterSigningKeyRevocation = struct
@ -372,7 +366,7 @@ module MasterSigningKeyRevocation = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterAddAuditor = struct
@ -396,7 +390,7 @@ module MasterAddAuditor = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterDelAuditor = struct
@ -417,7 +411,7 @@ module MasterDelAuditor = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module GlobalFees = struct
@ -472,7 +466,7 @@ module GlobalFees = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterWireDetails = struct
@ -510,7 +504,7 @@ module MasterWireDetails = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterAddWire = struct
@ -552,7 +546,7 @@ module MasterAddWire = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterDelWire = struct
@ -573,7 +567,7 @@ module MasterDelWire = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterDrainProfit = struct
@ -601,7 +595,7 @@ module MasterDrainProfit = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module MasterAmlOfficerStatus = struct
@ -627,7 +621,7 @@ module MasterAmlOfficerStatus = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module PartnerConfiguration = struct
@ -666,7 +660,7 @@ module PartnerConfiguration = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module WadPartnerSignature = struct
@ -742,7 +736,7 @@ module MasterWireFee = struct
|> sealr
end
include MK_master_sig (R)
include MK (R)
end
module ExchangeKeyValidity = struct