From ca3e2e6a2efc2f0cc6686b7908d0af091455b03b Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 14 Feb 2025 14:25:23 +0100 Subject: [PATCH 1/3] Alpha/v15: explicitely use bls_aug --- .../environment_V15.ml | 10 +- .../environment_V15.mli | 7 +- src/lib_protocol_environment/sigs/v15.in.ml | 2 + src/lib_protocol_environment/sigs/v15.ml | 108 ++++++++++++------ src/lib_protocol_environment/sigs/v15/bls.mli | 2 - .../sigs/v15/bls_aug.mli | 40 +++++++ .../sigs/v15/signature.mli | 6 +- src/proto_alpha/lib_protocol/apply.ml | 2 +- .../lib_protocol/contract_delegate_storage.ml | 7 +- .../contract_delegate_storage.mli | 2 +- src/proto_alpha/lib_protocol/contract_repr.ml | 2 +- .../lib_protocol/delegate_consensus_key.ml | 8 +- .../lib_protocol/delegate_consensus_key.mli | 2 +- src/proto_alpha/lib_protocol/storage.ml | 8 +- .../lib_protocol/tx_rollup_l2_address.ml | 6 +- .../lib_protocol/tx_rollup_l2_address.mli | 3 +- src/proto_alpha/lib_protocol/validate.ml | 2 +- 17 files changed, 153 insertions(+), 64 deletions(-) create mode 100644 src/lib_protocol_environment/sigs/v15/bls_aug.mli diff --git a/src/lib_protocol_environment/environment_V15.ml b/src/lib_protocol_environment/environment_V15.ml index 82594d3516df..b8af8baa0cc8 100644 --- a/src/lib_protocol_environment/environment_V15.ml +++ b/src/lib_protocol_environment/environment_V15.ml @@ -78,10 +78,11 @@ module type T = sig Tezos_crypto.Signature.P256.Public_key_hash.t and type P256.Public_key.t = Tezos_crypto.Signature.P256.Public_key.t and type P256.t = Tezos_crypto.Signature.P256.t - and type Bls.Public_key_hash.t = + and type Bls_aug.Public_key_hash.t = Tezos_crypto.Signature.Bls_aug.Public_key_hash.t - and type Bls.Public_key.t = Tezos_crypto.Signature.Bls_aug.Public_key.t - and type Bls.t = Tezos_crypto.Signature.Bls_aug.t + and type Bls_aug.Public_key.t = + Tezos_crypto.Signature.Bls_aug.Public_key.t + and type Bls_aug.t = Tezos_crypto.Signature.Bls_aug.t and type Signature.public_key_hash = Tezos_crypto.Signature.V1.public_key_hash and type Signature.public_key = Tezos_crypto.Signature.V1.public_key @@ -336,6 +337,7 @@ struct module Secp256k1 = Tezos_crypto.Signature.Secp256k1 module P256 = Tezos_crypto.Signature.P256 module Bls = Tezos_crypto.Signature.Bls_aug + module Bls_aug = Tezos_crypto.Signature.Bls_aug module Signature = struct include Tezos_crypto.Signature.V1 @@ -353,7 +355,7 @@ struct | Ed25519 _ -> "check_signature_ed25519" | Secp256k1 _ -> "check_signature_secp256k1" | P256 _ -> "check_signature_p256" - | Bls _ -> "check_signature_bls"); + | Bls_aug _ -> "check_signature_bls_aug"); ]]) end diff --git a/src/lib_protocol_environment/environment_V15.mli b/src/lib_protocol_environment/environment_V15.mli index 2ec09e3d877b..798322d16d68 100644 --- a/src/lib_protocol_environment/environment_V15.mli +++ b/src/lib_protocol_environment/environment_V15.mli @@ -78,10 +78,11 @@ module type T = sig Tezos_crypto.Signature.P256.Public_key_hash.t and type P256.Public_key.t = Tezos_crypto.Signature.P256.Public_key.t and type P256.t = Tezos_crypto.Signature.P256.t - and type Bls.Public_key_hash.t = + and type Bls_aug.Public_key_hash.t = Tezos_crypto.Signature.Bls_aug.Public_key_hash.t - and type Bls.Public_key.t = Tezos_crypto.Signature.Bls_aug.Public_key.t - and type Bls.t = Tezos_crypto.Signature.Bls_aug.t + and type Bls_aug.Public_key.t = + Tezos_crypto.Signature.Bls_aug.Public_key.t + and type Bls_aug.t = Tezos_crypto.Signature.Bls_aug.t and type Signature.public_key_hash = Tezos_crypto.Signature.V1.public_key_hash and type Signature.public_key = Tezos_crypto.Signature.V1.public_key diff --git a/src/lib_protocol_environment/sigs/v15.in.ml b/src/lib_protocol_environment/sigs/v15.in.ml index a9820536d50e..a4b59db0fe8c 100644 --- a/src/lib_protocol_environment/sigs/v15.in.ml +++ b/src/lib_protocol_environment/sigs/v15.in.ml @@ -87,6 +87,8 @@ module type T = sig module Bls : [%sig "v15/bls.mli"] + module Bls_aug : [%sig "v15/bls_aug.mli"] + module Ed25519 : [%sig "v15/ed25519.mli"] module Secp256k1 : [%sig "v15/secp256k1.mli"] diff --git a/src/lib_protocol_environment/sigs/v15.ml b/src/lib_protocol_environment/sigs/v15.ml index 973d4e40d4e2..9206b7b126f7 100644 --- a/src/lib_protocol_environment/sigs/v15.ml +++ b/src/lib_protocol_environment/sigs/v15.ml @@ -9699,6 +9699,50 @@ end (** Tezos - BLS12-381 cryptography *) +(** Module to access/expose the primitives of BLS12-381 *) +module Primitive : sig + module Fr : S.PRIME_FIELD + + module G1 : S.CURVE with type Scalar.t = Fr.t + + module G2 : S.CURVE with type Scalar.t = Fr.t + + val pairing_check : (G1.t * G2.t) list -> bool +end +end +# 88 "v15.in.ml" + + + module Bls_aug : sig +# 1 "v15/bls_aug.mli" +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2022 Nomadic Labs. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Tezos - BLS12-381 cryptography *) + include S.AGGREGATE_SIGNATURE with type watermark := bytes (** Module to access/expose the primitives of BLS12-381 *) @@ -9712,7 +9756,7 @@ module Primitive : sig val pairing_check : (G1.t * G2.t) list -> bool end end -# 88 "v15.in.ml" +# 90 "v15.in.ml" module Ed25519 : sig @@ -9746,7 +9790,7 @@ end include S.SIGNATURE with type watermark := bytes end -# 90 "v15.in.ml" +# 92 "v15.in.ml" module Secp256k1 : sig @@ -9780,7 +9824,7 @@ end include S.SIGNATURE with type watermark := bytes end -# 92 "v15.in.ml" +# 94 "v15.in.ml" module P256 : sig @@ -9814,7 +9858,7 @@ end include S.SIGNATURE with type watermark := bytes end -# 94 "v15.in.ml" +# 96 "v15.in.ml" module Chain_id : sig @@ -9846,7 +9890,7 @@ end include S.HASH end -# 96 "v15.in.ml" +# 98 "v15.in.ml" module Signature : sig @@ -9881,13 +9925,13 @@ type public_key_hash = | Ed25519 of Ed25519.Public_key_hash.t | Secp256k1 of Secp256k1.Public_key_hash.t | P256 of P256.Public_key_hash.t - | Bls of Bls.Public_key_hash.t + | Bls of Bls_aug.Public_key_hash.t type public_key = | Ed25519 of Ed25519.Public_key.t | Secp256k1 of Secp256k1.Public_key.t | P256 of P256.Public_key.t - | Bls of Bls.Public_key.t + | Bls of Bls_aug.Public_key.t type watermark = | Block_header of Chain_id.t @@ -9899,7 +9943,7 @@ type signature = | Ed25519 of Ed25519.t | Secp256k1 of Secp256k1.t | P256 of P256.t - | Bls of Bls.t + | Bls of Bls_aug.t | Unknown of Bytes.t type prefix = Bls_prefix of Bytes.t @@ -9914,7 +9958,7 @@ include val size : t -> int end -# 98 "v15.in.ml" +# 100 "v15.in.ml" module Block_hash : sig @@ -9947,7 +9991,7 @@ end (** Blocks hashes / IDs. *) include S.HASH end -# 100 "v15.in.ml" +# 102 "v15.in.ml" module Operation_hash : sig @@ -9980,7 +10024,7 @@ end (** Operations hashes / IDs. *) include S.HASH end -# 102 "v15.in.ml" +# 104 "v15.in.ml" module Operation_list_hash : sig @@ -10013,7 +10057,7 @@ end (** Blocks hashes / IDs. *) include S.MERKLE_TREE with type elt = Operation_hash.t end -# 104 "v15.in.ml" +# 106 "v15.in.ml" module Operation_list_list_hash : sig @@ -10046,7 +10090,7 @@ end (** Blocks hashes / IDs. *) include S.MERKLE_TREE with type elt = Operation_list_hash.t end -# 106 "v15.in.ml" +# 108 "v15.in.ml" module Protocol_hash : sig @@ -10079,7 +10123,7 @@ end (** Protocol hashes / IDs. *) include S.HASH end -# 108 "v15.in.ml" +# 110 "v15.in.ml" module Context_hash : sig @@ -10132,7 +10176,7 @@ end type version = Version.t end -# 110 "v15.in.ml" +# 112 "v15.in.ml" module Sapling : sig @@ -10280,7 +10324,7 @@ module Verification : sig val final_check : t -> UTXO.transaction -> string -> bool end end -# 112 "v15.in.ml" +# 114 "v15.in.ml" module Timelock : sig @@ -10337,7 +10381,7 @@ val open_chest : chest -> chest_key -> time:int -> opening_result Used for gas accounting*) val get_plaintext_size : chest -> int end -# 114 "v15.in.ml" +# 116 "v15.in.ml" module Vdf : sig @@ -10425,7 +10469,7 @@ val prove : discriminant -> challenge -> difficulty -> result * proof @raise Invalid_argument when inputs are invalid *) val verify : discriminant -> challenge -> difficulty -> result -> proof -> bool end -# 116 "v15.in.ml" +# 118 "v15.in.ml" module Micheline : sig @@ -10485,7 +10529,7 @@ val annotations : ('l, 'p) node -> string list val strip_locations : (_, 'p) node -> 'p canonical end -# 118 "v15.in.ml" +# 120 "v15.in.ml" module Block_header : sig @@ -10542,7 +10586,7 @@ type t = {shell : shell_header; protocol_data : bytes} include S.HASHABLE with type t := t and type hash := Block_hash.t end -# 120 "v15.in.ml" +# 122 "v15.in.ml" module Bounded : sig @@ -10691,7 +10735,7 @@ module Int8 (B : BOUNDS with type ocaml_type := int) : module Uint8 (B : BOUNDS with type ocaml_type := int) : S with type ocaml_type := int end -# 122 "v15.in.ml" +# 124 "v15.in.ml" module Fitness : sig @@ -10725,7 +10769,7 @@ end compared in a lexicographical order (longer list are greater). *) include S.T with type t = bytes list end -# 124 "v15.in.ml" +# 126 "v15.in.ml" module Operation : sig @@ -10769,7 +10813,7 @@ type t = {shell : shell_header; proto : bytes} include S.HASHABLE with type t := t and type hash := Operation_hash.t end -# 126 "v15.in.ml" +# 128 "v15.in.ml" module Context : sig @@ -11406,7 +11450,7 @@ module Cache : and type key = cache_key and type value = cache_value end -# 128 "v15.in.ml" +# 130 "v15.in.ml" module Updater : sig @@ -11935,7 +11979,7 @@ end not complete until [init] in invoked. *) val activate : Context.t -> Protocol_hash.t -> Context.t Lwt.t end -# 130 "v15.in.ml" +# 132 "v15.in.ml" module RPC_context : sig @@ -12089,7 +12133,7 @@ val make_opt_call3 : 'i -> 'o option shell_tzresult Lwt.t end -# 132 "v15.in.ml" +# 134 "v15.in.ml" module Context_binary : sig @@ -12132,7 +12176,7 @@ module Tree : val make_empty_context : ?root:string -> unit -> t end -# 134 "v15.in.ml" +# 136 "v15.in.ml" module Wasm_2_0_0 : sig @@ -12206,7 +12250,7 @@ module Make val get_info : Tree.tree -> info Lwt.t end end -# 136 "v15.in.ml" +# 138 "v15.in.ml" module Plonk : sig @@ -12325,7 +12369,7 @@ val scalar_array_encoding : scalar array Data_encoding.t on the given [inputs] according to the [public_parameters]. *) val verify : public_parameters -> verifier_inputs -> proof -> bool end -# 138 "v15.in.ml" +# 140 "v15.in.ml" module Dal : sig @@ -12480,7 +12524,7 @@ val share_is_trap : traps_fraction:Q.t -> (bool, [> `Decoding_error]) Result.t end -# 140 "v15.in.ml" +# 142 "v15.in.ml" module Skip_list : sig @@ -12712,7 +12756,7 @@ module Make (_ : sig val basis : int end) : S end -# 142 "v15.in.ml" +# 144 "v15.in.ml" module Smart_rollup : sig @@ -12769,6 +12813,6 @@ module Inbox_hash : S.HASH (** Smart rollup merkelized payload hashes' hash *) module Merkelized_payload_hashes_hash : S.HASH end -# 144 "v15.in.ml" +# 146 "v15.in.ml" end diff --git a/src/lib_protocol_environment/sigs/v15/bls.mli b/src/lib_protocol_environment/sigs/v15/bls.mli index a016a71904ee..a754ba009288 100644 --- a/src/lib_protocol_environment/sigs/v15/bls.mli +++ b/src/lib_protocol_environment/sigs/v15/bls.mli @@ -26,8 +26,6 @@ (** Tezos - BLS12-381 cryptography *) -include S.AGGREGATE_SIGNATURE with type watermark := bytes - (** Module to access/expose the primitives of BLS12-381 *) module Primitive : sig module Fr : S.PRIME_FIELD diff --git a/src/lib_protocol_environment/sigs/v15/bls_aug.mli b/src/lib_protocol_environment/sigs/v15/bls_aug.mli new file mode 100644 index 000000000000..a016a71904ee --- /dev/null +++ b/src/lib_protocol_environment/sigs/v15/bls_aug.mli @@ -0,0 +1,40 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2022 Nomadic Labs. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Tezos - BLS12-381 cryptography *) + +include S.AGGREGATE_SIGNATURE with type watermark := bytes + +(** Module to access/expose the primitives of BLS12-381 *) +module Primitive : sig + module Fr : S.PRIME_FIELD + + module G1 : S.CURVE with type Scalar.t = Fr.t + + module G2 : S.CURVE with type Scalar.t = Fr.t + + val pairing_check : (G1.t * G2.t) list -> bool +end diff --git a/src/lib_protocol_environment/sigs/v15/signature.mli b/src/lib_protocol_environment/sigs/v15/signature.mli index 67b9dd7aca16..d97623b867bd 100644 --- a/src/lib_protocol_environment/sigs/v15/signature.mli +++ b/src/lib_protocol_environment/sigs/v15/signature.mli @@ -28,13 +28,13 @@ type public_key_hash = | Ed25519 of Ed25519.Public_key_hash.t | Secp256k1 of Secp256k1.Public_key_hash.t | P256 of P256.Public_key_hash.t - | Bls of Bls.Public_key_hash.t + | Bls of Bls_aug.Public_key_hash.t type public_key = | Ed25519 of Ed25519.Public_key.t | Secp256k1 of Secp256k1.Public_key.t | P256 of P256.Public_key.t - | Bls of Bls.Public_key.t + | Bls of Bls_aug.Public_key.t type watermark = | Block_header of Chain_id.t @@ -46,7 +46,7 @@ type signature = | Ed25519 of Ed25519.t | Secp256k1 of Secp256k1.t | P256 of P256.t - | Bls of Bls.t + | Bls of Bls_aug.t | Unknown of Bytes.t type prefix = Bls_prefix of Bytes.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index dea20068c272..e90b67ca03ec 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1437,7 +1437,7 @@ let apply_manager_operation : let*? ctxt = let gas_cost_for_sig_check = let open Saturation_repr.Syntax in - let size = Bls.Public_key.size bls_public_key in + let size = Bls_aug.Public_key.size bls_public_key in Operation_costs.serialization_cost size + Michelson_v1_gas.Cost_of.Interpreter.check_signature_on_algo Bls diff --git a/src/proto_alpha/lib_protocol/contract_delegate_storage.ml b/src/proto_alpha/lib_protocol/contract_delegate_storage.ml index 6fda4fde2dc5..c3d7df0f2db2 100644 --- a/src/proto_alpha/lib_protocol/contract_delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/contract_delegate_storage.ml @@ -23,7 +23,8 @@ (* *) (*****************************************************************************) -type error += (* `Permanent *) Forbidden_tz4_delegate of Bls.Public_key_hash.t +type error += + | (* `Permanent *) Forbidden_tz4_delegate of Bls_aug.Public_key_hash.t let () = register_error_kind @@ -35,9 +36,9 @@ let () = Format.fprintf ppf "The delegate %a is forbidden as it is a BLS public key hash." - Bls.Public_key_hash.pp + Bls_aug.Public_key_hash.pp implicit) - Data_encoding.(obj1 (req "delegate" Bls.Public_key_hash.encoding)) + Data_encoding.(obj1 (req "delegate" Bls_aug.Public_key_hash.encoding)) (function Forbidden_tz4_delegate d -> Some d | _ -> None) (fun d -> Forbidden_tz4_delegate d) diff --git a/src/proto_alpha/lib_protocol/contract_delegate_storage.mli b/src/proto_alpha/lib_protocol/contract_delegate_storage.mli index eeecd7367325..dbbad19bff7d 100644 --- a/src/proto_alpha/lib_protocol/contract_delegate_storage.mli +++ b/src/proto_alpha/lib_protocol/contract_delegate_storage.mli @@ -29,7 +29,7 @@ type error += | (* `Permanent *) - Forbidden_tz4_delegate of Bls.Public_key_hash.t + Forbidden_tz4_delegate of Bls_aug.Public_key_hash.t (** Delegates cannot be tz4 accounts (i.e. BLS public key hashes). This error is returned when we try to register such a delegate. *) diff --git a/src/proto_alpha/lib_protocol/contract_repr.ml b/src/proto_alpha/lib_protocol/contract_repr.ml index 96d9cc493312..3c304f3d9852 100644 --- a/src/proto_alpha/lib_protocol/contract_repr.ml +++ b/src/proto_alpha/lib_protocol/contract_repr.ml @@ -56,7 +56,7 @@ let implicit_of_b58data : Base58.data -> Signature.public_key_hash option = | Ed25519.Public_key_hash.Data h -> Some (Signature.Ed25519 h) | Secp256k1.Public_key_hash.Data h -> Some (Signature.Secp256k1 h) | P256.Public_key_hash.Data h -> Some (Signature.P256 h) - | Bls.Public_key_hash.Data h -> Some (Signature.Bls h) + | Bls_aug.Public_key_hash.Data h -> Some (Signature.Bls h) | _ -> None let originated_of_b58data = function diff --git a/src/proto_alpha/lib_protocol/delegate_consensus_key.ml b/src/proto_alpha/lib_protocol/delegate_consensus_key.ml index 004dd0d6816c..38cb284086bf 100644 --- a/src/proto_alpha/lib_protocol/delegate_consensus_key.ml +++ b/src/proto_alpha/lib_protocol/delegate_consensus_key.ml @@ -26,7 +26,7 @@ type error += | Invalid_consensus_key_update_noop of Cycle_repr.t | Invalid_consensus_key_update_active - | Invalid_consensus_key_update_tz4 of Bls.Public_key.t + | Invalid_consensus_key_update_tz4 of Bls_aug.Public_key.t let () = register_error_kind @@ -65,9 +65,9 @@ let () = Format.fprintf ppf "The consensus key %a is forbidden as it is a BLS public key." - Bls.Public_key_hash.pp - (Bls.Public_key.hash pk)) - Data_encoding.(obj1 (req "delegate_pk" Bls.Public_key.encoding)) + Bls_aug.Public_key_hash.pp + (Bls_aug.Public_key.hash pk)) + Data_encoding.(obj1 (req "delegate_pk" Bls_aug.Public_key.encoding)) (function Invalid_consensus_key_update_tz4 pk -> Some pk | _ -> None) (fun pk -> Invalid_consensus_key_update_tz4 pk) diff --git a/src/proto_alpha/lib_protocol/delegate_consensus_key.mli b/src/proto_alpha/lib_protocol/delegate_consensus_key.mli index 920ec51e028c..8ab26b700545 100644 --- a/src/proto_alpha/lib_protocol/delegate_consensus_key.mli +++ b/src/proto_alpha/lib_protocol/delegate_consensus_key.mli @@ -32,7 +32,7 @@ type error += | Invalid_consensus_key_update_noop of Cycle_repr.t | Invalid_consensus_key_update_active - | Invalid_consensus_key_update_tz4 of Bls.Public_key.t + | Invalid_consensus_key_update_tz4 of Bls_aug.Public_key.t (** The public key of a consensus key and the associated delegate. *) type pk = Raw_context.consensus_pk = { diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index c88f8dd04805..db7ac5b27737 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1066,14 +1066,14 @@ module Public_key_hash = struct module Path_Ed25519 = Path_encoding.Make_hex (Ed25519.Public_key_hash) module Path_Secp256k1 = Path_encoding.Make_hex (Secp256k1.Public_key_hash) module Path_P256 = Path_encoding.Make_hex (P256.Public_key_hash) - module Path_Bls = Path_encoding.Make_hex (Bls.Public_key_hash) + module Path_Bls_aug = Path_encoding.Make_hex (Bls_aug.Public_key_hash) let to_path (key : public_key_hash) l = match key with | Ed25519 h -> "ed25519" :: Path_Ed25519.to_path h l | Secp256k1 h -> "secp256k1" :: Path_Secp256k1.to_path h l | P256 h -> "p256" :: Path_P256.to_path h l - | Bls h -> "bls" :: Path_Bls.to_path h l + | Bls h -> "bls" :: Path_Bls_aug.to_path h l let of_path : _ -> public_key_hash option = function | "ed25519" :: rest -> ( @@ -1089,7 +1089,7 @@ module Public_key_hash = struct | Some pkh -> Some (P256 pkh) | None -> None) | "bls" :: rest -> ( - match Path_Bls.of_path rest with + match Path_Bls_aug.of_path rest with | Some pkh -> Some (Bls pkh) | None -> None) | _ -> None @@ -1098,7 +1098,7 @@ module Public_key_hash = struct let l1 = Path_Ed25519.path_length and l2 = Path_Secp256k1.path_length and l3 = Path_P256.path_length - and l4 = Path_Bls.path_length in + and l4 = Path_Bls_aug.path_length in assert (Compare.Int.(l1 = l2 && l2 = l3 && l3 = l4)) ; l1 + 1 end diff --git a/src/proto_alpha/lib_protocol/tx_rollup_l2_address.ml b/src/proto_alpha/lib_protocol/tx_rollup_l2_address.ml index 8959062241ae..b90e17df89de 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_l2_address.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_l2_address.ml @@ -25,16 +25,16 @@ (* *) (*****************************************************************************) -include Bls.Public_key_hash +include Bls_aug.Public_key_hash type address = t let in_memory_size : t -> Cache_memory_helpers.sint = fun _ -> let open Cache_memory_helpers in - header_size +! word_size +! string_size_gen Bls.Public_key_hash.size + header_size +! word_size +! string_size_gen Bls_aug.Public_key_hash.size -let size _ = Bls.Public_key_hash.size +let size _ = Bls_aug.Public_key_hash.size module Indexable = struct include Indexable.Make (struct diff --git a/src/proto_alpha/lib_protocol/tx_rollup_l2_address.mli b/src/proto_alpha/lib_protocol/tx_rollup_l2_address.mli index 534551d427df..01aa5d103c39 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_l2_address.mli +++ b/src/proto_alpha/lib_protocol/tx_rollup_l2_address.mli @@ -30,7 +30,8 @@ (** The hash of a BLS public key is used as the primary identifier of ticket holders within a transaction rollup. *) -include module type of Bls.Public_key_hash with type t = Bls.Public_key_hash.t +include + module type of Bls_aug.Public_key_hash with type t = Bls_aug.Public_key_hash.t type address = t diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index c6a7dee2aad8..9c090d59f387 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -2402,7 +2402,7 @@ module Manager = struct check the proof. *) let gas_cost_for_sig_check = let open Saturation_repr.Syntax in - let size = Bls.Public_key.size bls_public_key in + let size = Bls_aug.Public_key.size bls_public_key in Operation_costs.serialization_cost size + Michelson_v1_gas.Cost_of.Interpreter.check_signature_on_algo Bls -- GitLab From f40764f93187f7e6f35090aa4f2eb65503ed6099 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 14 Feb 2025 14:43:00 +0100 Subject: [PATCH 2/3] Env15: add bls_pop support --- .../environment_V15.ml | 6 + .../environment_V15.mli | 5 + src/lib_protocol_environment/sigs/v15.in.ml | 2 + src/lib_protocol_environment/sigs/v15.ml | 104 +++++++++++++----- .../sigs/v15/bls_pop.mli | 40 +++++++ .../sigs/v15/signature.mli | 2 +- 6 files changed, 129 insertions(+), 30 deletions(-) create mode 100644 src/lib_protocol_environment/sigs/v15/bls_pop.mli diff --git a/src/lib_protocol_environment/environment_V15.ml b/src/lib_protocol_environment/environment_V15.ml index b8af8baa0cc8..5b4485063671 100644 --- a/src/lib_protocol_environment/environment_V15.ml +++ b/src/lib_protocol_environment/environment_V15.ml @@ -83,6 +83,11 @@ module type T = sig and type Bls_aug.Public_key.t = Tezos_crypto.Signature.Bls_aug.Public_key.t and type Bls_aug.t = Tezos_crypto.Signature.Bls_aug.t + and type Bls_pop.Public_key_hash.t = + Tezos_crypto.Signature.Bls_pop.Public_key_hash.t + and type Bls_pop.Public_key.t = + Tezos_crypto.Signature.Bls_pop.Public_key.t + and type Bls_pop.t = Tezos_crypto.Signature.Bls_pop.t and type Signature.public_key_hash = Tezos_crypto.Signature.V1.public_key_hash and type Signature.public_key = Tezos_crypto.Signature.V1.public_key @@ -338,6 +343,7 @@ struct module P256 = Tezos_crypto.Signature.P256 module Bls = Tezos_crypto.Signature.Bls_aug module Bls_aug = Tezos_crypto.Signature.Bls_aug + module Bls_pop = Tezos_crypto.Signature.Bls_pop module Signature = struct include Tezos_crypto.Signature.V1 diff --git a/src/lib_protocol_environment/environment_V15.mli b/src/lib_protocol_environment/environment_V15.mli index 798322d16d68..b8a944fc2837 100644 --- a/src/lib_protocol_environment/environment_V15.mli +++ b/src/lib_protocol_environment/environment_V15.mli @@ -83,6 +83,11 @@ module type T = sig and type Bls_aug.Public_key.t = Tezos_crypto.Signature.Bls_aug.Public_key.t and type Bls_aug.t = Tezos_crypto.Signature.Bls_aug.t + and type Bls_pop.Public_key_hash.t = + Tezos_crypto.Signature.Bls_pop.Public_key_hash.t + and type Bls_pop.Public_key.t = + Tezos_crypto.Signature.Bls_pop.Public_key.t + and type Bls_pop.t = Tezos_crypto.Signature.Bls_pop.t and type Signature.public_key_hash = Tezos_crypto.Signature.V1.public_key_hash and type Signature.public_key = Tezos_crypto.Signature.V1.public_key diff --git a/src/lib_protocol_environment/sigs/v15.in.ml b/src/lib_protocol_environment/sigs/v15.in.ml index a4b59db0fe8c..840ffcdac4c9 100644 --- a/src/lib_protocol_environment/sigs/v15.in.ml +++ b/src/lib_protocol_environment/sigs/v15.in.ml @@ -89,6 +89,8 @@ module type T = sig module Bls_aug : [%sig "v15/bls_aug.mli"] + module Bls_pop : [%sig "v15/bls_pop.mli"] + module Ed25519 : [%sig "v15/ed25519.mli"] module Secp256k1 : [%sig "v15/secp256k1.mli"] diff --git a/src/lib_protocol_environment/sigs/v15.ml b/src/lib_protocol_environment/sigs/v15.ml index 9206b7b126f7..7240fd16122a 100644 --- a/src/lib_protocol_environment/sigs/v15.ml +++ b/src/lib_protocol_environment/sigs/v15.ml @@ -9759,6 +9759,52 @@ end # 90 "v15.in.ml" + module Bls_pop : sig +# 1 "v15/bls_pop.mli" +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2022 Nomadic Labs. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Tezos - BLS12-381 cryptography *) + +include S.SIGNATURE with type watermark := bytes + +(** Module to access/expose the primitives of BLS12-381 *) +module Primitive : sig + module Fr : S.PRIME_FIELD + + module G1 : S.CURVE with type Scalar.t = Fr.t + + module G2 : S.CURVE with type Scalar.t = Fr.t + + val pairing_check : (G1.t * G2.t) list -> bool +end +end +# 92 "v15.in.ml" + + module Ed25519 : sig # 1 "v15/ed25519.mli" (*****************************************************************************) @@ -9790,7 +9836,7 @@ end include S.SIGNATURE with type watermark := bytes end -# 92 "v15.in.ml" +# 94 "v15.in.ml" module Secp256k1 : sig @@ -9824,7 +9870,7 @@ end include S.SIGNATURE with type watermark := bytes end -# 94 "v15.in.ml" +# 96 "v15.in.ml" module P256 : sig @@ -9858,7 +9904,7 @@ end include S.SIGNATURE with type watermark := bytes end -# 96 "v15.in.ml" +# 98 "v15.in.ml" module Chain_id : sig @@ -9890,7 +9936,7 @@ end include S.HASH end -# 98 "v15.in.ml" +# 100 "v15.in.ml" module Signature : sig @@ -9946,7 +9992,7 @@ type signature = | Bls of Bls_aug.t | Unknown of Bytes.t -type prefix = Bls_prefix of Bytes.t +type prefix = Bls_aug_prefix of Bytes.t | Bls_pop_prefix of Bytes.t include S.SPLIT_SIGNATURE @@ -9958,7 +10004,7 @@ include val size : t -> int end -# 100 "v15.in.ml" +# 102 "v15.in.ml" module Block_hash : sig @@ -9991,7 +10037,7 @@ end (** Blocks hashes / IDs. *) include S.HASH end -# 102 "v15.in.ml" +# 104 "v15.in.ml" module Operation_hash : sig @@ -10024,7 +10070,7 @@ end (** Operations hashes / IDs. *) include S.HASH end -# 104 "v15.in.ml" +# 106 "v15.in.ml" module Operation_list_hash : sig @@ -10057,7 +10103,7 @@ end (** Blocks hashes / IDs. *) include S.MERKLE_TREE with type elt = Operation_hash.t end -# 106 "v15.in.ml" +# 108 "v15.in.ml" module Operation_list_list_hash : sig @@ -10090,7 +10136,7 @@ end (** Blocks hashes / IDs. *) include S.MERKLE_TREE with type elt = Operation_list_hash.t end -# 108 "v15.in.ml" +# 110 "v15.in.ml" module Protocol_hash : sig @@ -10123,7 +10169,7 @@ end (** Protocol hashes / IDs. *) include S.HASH end -# 110 "v15.in.ml" +# 112 "v15.in.ml" module Context_hash : sig @@ -10176,7 +10222,7 @@ end type version = Version.t end -# 112 "v15.in.ml" +# 114 "v15.in.ml" module Sapling : sig @@ -10324,7 +10370,7 @@ module Verification : sig val final_check : t -> UTXO.transaction -> string -> bool end end -# 114 "v15.in.ml" +# 116 "v15.in.ml" module Timelock : sig @@ -10381,7 +10427,7 @@ val open_chest : chest -> chest_key -> time:int -> opening_result Used for gas accounting*) val get_plaintext_size : chest -> int end -# 116 "v15.in.ml" +# 118 "v15.in.ml" module Vdf : sig @@ -10469,7 +10515,7 @@ val prove : discriminant -> challenge -> difficulty -> result * proof @raise Invalid_argument when inputs are invalid *) val verify : discriminant -> challenge -> difficulty -> result -> proof -> bool end -# 118 "v15.in.ml" +# 120 "v15.in.ml" module Micheline : sig @@ -10529,7 +10575,7 @@ val annotations : ('l, 'p) node -> string list val strip_locations : (_, 'p) node -> 'p canonical end -# 120 "v15.in.ml" +# 122 "v15.in.ml" module Block_header : sig @@ -10586,7 +10632,7 @@ type t = {shell : shell_header; protocol_data : bytes} include S.HASHABLE with type t := t and type hash := Block_hash.t end -# 122 "v15.in.ml" +# 124 "v15.in.ml" module Bounded : sig @@ -10735,7 +10781,7 @@ module Int8 (B : BOUNDS with type ocaml_type := int) : module Uint8 (B : BOUNDS with type ocaml_type := int) : S with type ocaml_type := int end -# 124 "v15.in.ml" +# 126 "v15.in.ml" module Fitness : sig @@ -10769,7 +10815,7 @@ end compared in a lexicographical order (longer list are greater). *) include S.T with type t = bytes list end -# 126 "v15.in.ml" +# 128 "v15.in.ml" module Operation : sig @@ -10813,7 +10859,7 @@ type t = {shell : shell_header; proto : bytes} include S.HASHABLE with type t := t and type hash := Operation_hash.t end -# 128 "v15.in.ml" +# 130 "v15.in.ml" module Context : sig @@ -11450,7 +11496,7 @@ module Cache : and type key = cache_key and type value = cache_value end -# 130 "v15.in.ml" +# 132 "v15.in.ml" module Updater : sig @@ -11979,7 +12025,7 @@ end not complete until [init] in invoked. *) val activate : Context.t -> Protocol_hash.t -> Context.t Lwt.t end -# 132 "v15.in.ml" +# 134 "v15.in.ml" module RPC_context : sig @@ -12133,7 +12179,7 @@ val make_opt_call3 : 'i -> 'o option shell_tzresult Lwt.t end -# 134 "v15.in.ml" +# 136 "v15.in.ml" module Context_binary : sig @@ -12176,7 +12222,7 @@ module Tree : val make_empty_context : ?root:string -> unit -> t end -# 136 "v15.in.ml" +# 138 "v15.in.ml" module Wasm_2_0_0 : sig @@ -12250,7 +12296,7 @@ module Make val get_info : Tree.tree -> info Lwt.t end end -# 138 "v15.in.ml" +# 140 "v15.in.ml" module Plonk : sig @@ -12369,7 +12415,7 @@ val scalar_array_encoding : scalar array Data_encoding.t on the given [inputs] according to the [public_parameters]. *) val verify : public_parameters -> verifier_inputs -> proof -> bool end -# 140 "v15.in.ml" +# 142 "v15.in.ml" module Dal : sig @@ -12524,7 +12570,7 @@ val share_is_trap : traps_fraction:Q.t -> (bool, [> `Decoding_error]) Result.t end -# 142 "v15.in.ml" +# 144 "v15.in.ml" module Skip_list : sig @@ -12756,7 +12802,7 @@ module Make (_ : sig val basis : int end) : S end -# 144 "v15.in.ml" +# 146 "v15.in.ml" module Smart_rollup : sig @@ -12813,6 +12859,6 @@ module Inbox_hash : S.HASH (** Smart rollup merkelized payload hashes' hash *) module Merkelized_payload_hashes_hash : S.HASH end -# 146 "v15.in.ml" +# 148 "v15.in.ml" end diff --git a/src/lib_protocol_environment/sigs/v15/bls_pop.mli b/src/lib_protocol_environment/sigs/v15/bls_pop.mli new file mode 100644 index 000000000000..b9f04fe1a975 --- /dev/null +++ b/src/lib_protocol_environment/sigs/v15/bls_pop.mli @@ -0,0 +1,40 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2022 Nomadic Labs. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Tezos - BLS12-381 cryptography *) + +include S.SIGNATURE with type watermark := bytes + +(** Module to access/expose the primitives of BLS12-381 *) +module Primitive : sig + module Fr : S.PRIME_FIELD + + module G1 : S.CURVE with type Scalar.t = Fr.t + + module G2 : S.CURVE with type Scalar.t = Fr.t + + val pairing_check : (G1.t * G2.t) list -> bool +end diff --git a/src/lib_protocol_environment/sigs/v15/signature.mli b/src/lib_protocol_environment/sigs/v15/signature.mli index d97623b867bd..39485d2ec379 100644 --- a/src/lib_protocol_environment/sigs/v15/signature.mli +++ b/src/lib_protocol_environment/sigs/v15/signature.mli @@ -49,7 +49,7 @@ type signature = | Bls of Bls_aug.t | Unknown of Bytes.t -type prefix = Bls_prefix of Bytes.t +type prefix = Bls_aug_prefix of Bytes.t | Bls_pop_prefix of Bytes.t include S.SPLIT_SIGNATURE -- GitLab From 7950759b6feed71f7ceb38c159fb95874132ea12 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 14 Feb 2025 15:29:36 +0100 Subject: [PATCH 3/3] Env15: upgrade signature version to V2 --- devtools/yes_wallet/get_delegates_alpha.ml | 16 ++++++++++--- manifest/product_octez.ml | 23 +++++++++++++++---- .../environment_V15.ml | 18 +++++++-------- .../environment_V15.mli | 10 ++++---- src/lib_protocol_environment/sigs/v15.ml | 9 +++++--- .../sigs/v15/signature.mli | 9 +++++--- src/lib_wasm_debugger/messages.ml | 4 ++-- src/proto_alpha/lib_benchmark/dune | 4 ++-- .../lib_benchmark/michelson_samplers.ml | 2 +- src/proto_alpha/lib_benchmarks_proto/dune | 2 +- .../interpreter_benchmarks.ml | 7 ++++-- .../interpreter_workload.ml | 7 +++++- .../lib_client/client_proto_context.ml | 6 ++--- src/proto_alpha/lib_client/dune | 4 ++-- src/proto_alpha/lib_client/injection.ml | 9 ++++++-- .../client_proto_context_commands.ml | 4 ++-- src/proto_alpha/lib_client_commands/dune | 4 ++-- .../lib_dal/dal_plugin_registration.ml | 4 ++-- src/proto_alpha/lib_dal/dune | 2 +- .../lib_delegate/baking_actions.ml | 2 +- src/proto_alpha/lib_delegate/dune | 4 ++-- src/proto_alpha/lib_delegate/node_rpc.ml | 4 ++-- .../lib_delegate/test/mockup_simulator/dune | 2 +- .../lib_delegate/test/tenderbrute/lib/dune | 2 +- src/proto_alpha/lib_injector/dune | 4 ++-- src/proto_alpha/lib_parameters/dune | 2 +- src/proto_alpha/lib_plugin/dune | 2 +- src/proto_alpha/lib_plugin/mempool.ml | 2 +- src/proto_alpha/lib_protocol/alpha_context.ml | 2 +- src/proto_alpha/lib_protocol/apply.ml | 6 ++--- .../lib_protocol/contract_delegate_storage.ml | 4 ++-- src/proto_alpha/lib_protocol/contract_repr.ml | 3 ++- .../lib_protocol/delegate_consensus_key.ml | 4 ++-- .../lib_protocol/michelson_v1_gas.ml | 11 +++++---- .../lib_protocol/michelson_v1_gas.mli | 2 +- .../lib_protocol/script_typed_ir_size.ml | 5 ++-- src/proto_alpha/lib_protocol/storage.ml | 15 ++++++++---- .../lib_protocol/test/helpers/account.ml | 3 ++- .../lib_protocol/test/helpers/dune | 2 +- .../lib_protocol/test/helpers/op.ml | 11 ++++----- .../test/helpers/operation_generator.ml | 21 +++++++++++++---- .../integration/consensus/test_aggregate.ml | 2 +- .../consensus/test_consensus_key.ml | 4 ++-- .../integration/consensus/test_delegation.ml | 4 ++-- .../validate/generator_descriptors.ml | 2 +- .../test/unit/test_operation_repr.ml | 2 +- src/proto_alpha/lib_protocol/validate.ml | 19 +++++++-------- .../sc_rollup_proto_types.ml | 12 +++++----- .../lib_sc_rollup_node/daemon_helpers.ml | 14 +++++------ src/proto_alpha/lib_sc_rollup_node/dune | 2 +- .../lib_sc_rollup_node/layer1_helpers.ml | 2 +- .../lib_sc_rollup_node/pvm_plugin.ml | 2 +- .../refutation_game_helpers.ml | 4 ++-- .../lib_sc_rollup_node/sc_rollup_injector.ml | 2 +- .../test/test_octez_conversions.ml | 8 ++++--- .../alpha_machine.real.ml | 12 +++++----- 56 files changed, 209 insertions(+), 139 deletions(-) diff --git a/devtools/yes_wallet/get_delegates_alpha.ml b/devtools/yes_wallet/get_delegates_alpha.ml index e76e68a1b31c..bd31bb98f63e 100644 --- a/devtools/yes_wallet/get_delegates_alpha.ml +++ b/devtools/yes_wallet/get_delegates_alpha.ml @@ -40,9 +40,19 @@ module Get_delegates = struct end module Signature = struct - include Tezos_crypto.Signature.V1 - module To_latest = Tezos_crypto.Signature.V_latest.Of_V1 - module Of_latest = Tezos_crypto.Signature.V1.Of_V_latest + include Tezos_crypto.Signature.V2 + + module To_latest = struct + let public_key_hash = Fun.id + + let public_key = Fun.id + + let secret_key = Fun.id + + let signature = Fun.id + end + + module Of_latest = Tezos_crypto.Signature.V2.Of_V_latest end module Contract = struct diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index 1aa574c58216..e8a690e89782 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -6453,7 +6453,12 @@ let hash = Protocol.hash module Ed25519 = Tezos_crypto.Signature.Ed25519 module P256 = Tezos_crypto.Signature.P256 module Secp256k1 = Tezos_crypto.Signature.Secp256k1 - include Tezos_crypto.Signature.V1|}); + %s|} + (if N.(number <= 022) then + {|include Tezos_crypto.Signature.V1|} + else + {|module Bls_pop = Tezos_crypto.Signature.Bls_pop + include Tezos_crypto.Signature.V2|})); ] in let dune_client_keys_version_rule = @@ -6464,7 +6469,10 @@ let hash = Protocol.hash [ S "write-file"; S "%{targets}"; - S (sf {|include Tezos_client_base.Client_keys_v1|}); + S + (sf + {|include Tezos_client_base.Client_keys_v%d|} + (if N.(number <= 022) then 1 else 2)); ]) in let parameters = @@ -7295,7 +7303,11 @@ let hash = Protocol.hash [ S "write-file"; S "%{targets}"; - S "include module type of Tezos_benchmark.Crypto_samplers.V1"; + S + (sf + "include module type of \ + Tezos_benchmark.Crypto_samplers.V%d" + (if N.(number <= 22) then 1 else 2)); ]; Dune.targets_rule ["crypto_samplers.ml"] @@ -7303,7 +7315,10 @@ let hash = Protocol.hash [ S "write-file"; S "%{targets}"; - S "include Tezos_benchmark.Crypto_samplers.V1"; + S + (sf + "include Tezos_benchmark.Crypto_samplers.V%d" + (if N.(number <= 22) then 1 else 2)); ]; ] in diff --git a/src/lib_protocol_environment/environment_V15.ml b/src/lib_protocol_environment/environment_V15.ml index 5b4485063671..ace0632bbbbe 100644 --- a/src/lib_protocol_environment/environment_V15.ml +++ b/src/lib_protocol_environment/environment_V15.ml @@ -89,11 +89,11 @@ module type T = sig Tezos_crypto.Signature.Bls_pop.Public_key.t and type Bls_pop.t = Tezos_crypto.Signature.Bls_pop.t and type Signature.public_key_hash = - Tezos_crypto.Signature.V1.public_key_hash - and type Signature.public_key = Tezos_crypto.Signature.V1.public_key - and type Signature.signature = Tezos_crypto.Signature.V1.signature - and type Signature.t = Tezos_crypto.Signature.V1.t - and type Signature.watermark = Tezos_crypto.Signature.V1.watermark + Tezos_crypto.Signature.V2.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.V2.public_key + and type Signature.signature = Tezos_crypto.Signature.V2.signature + and type Signature.t = Tezos_crypto.Signature.V2.t + and type Signature.watermark = Tezos_crypto.Signature.V2.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -346,7 +346,7 @@ struct module Bls_pop = Tezos_crypto.Signature.Bls_pop module Signature = struct - include Tezos_crypto.Signature.V1 + include Tezos_crypto.Signature.V2 let check ?watermark pk s bytes = (check @@ -361,7 +361,8 @@ struct | Ed25519 _ -> "check_signature_ed25519" | Secp256k1 _ -> "check_signature_secp256k1" | P256 _ -> "check_signature_p256" - | Bls_aug _ -> "check_signature_bls_aug"); + | Bls_aug _ -> "check_signature_bls_aug" + | Bls_pop _ -> "check_signature_bls_pop"); ]]) end @@ -1597,9 +1598,6 @@ struct | Ok () -> Ok true let share_is_trap delegate share ~traps_fraction = - let delegate = - Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash delegate - in match Tezos_crypto_dal.Trap.share_is_trap delegate share ~traps_fraction with diff --git a/src/lib_protocol_environment/environment_V15.mli b/src/lib_protocol_environment/environment_V15.mli index b8a944fc2837..6cd1f336665a 100644 --- a/src/lib_protocol_environment/environment_V15.mli +++ b/src/lib_protocol_environment/environment_V15.mli @@ -89,11 +89,11 @@ module type T = sig Tezos_crypto.Signature.Bls_pop.Public_key.t and type Bls_pop.t = Tezos_crypto.Signature.Bls_pop.t and type Signature.public_key_hash = - Tezos_crypto.Signature.V1.public_key_hash - and type Signature.public_key = Tezos_crypto.Signature.V1.public_key - and type Signature.signature = Tezos_crypto.Signature.V1.signature - and type Signature.t = Tezos_crypto.Signature.V1.t - and type Signature.watermark = Tezos_crypto.Signature.V1.watermark + Tezos_crypto.Signature.V2.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.V2.public_key + and type Signature.signature = Tezos_crypto.Signature.V2.signature + and type Signature.t = Tezos_crypto.Signature.V2.t + and type Signature.watermark = Tezos_crypto.Signature.V2.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t diff --git a/src/lib_protocol_environment/sigs/v15.ml b/src/lib_protocol_environment/sigs/v15.ml index 7240fd16122a..470a683428bd 100644 --- a/src/lib_protocol_environment/sigs/v15.ml +++ b/src/lib_protocol_environment/sigs/v15.ml @@ -9971,13 +9971,15 @@ type public_key_hash = | Ed25519 of Ed25519.Public_key_hash.t | Secp256k1 of Secp256k1.Public_key_hash.t | P256 of P256.Public_key_hash.t - | Bls of Bls_aug.Public_key_hash.t + | Bls_aug of Bls_aug.Public_key_hash.t + | Bls_pop of Bls_pop.Public_key_hash.t type public_key = | Ed25519 of Ed25519.Public_key.t | Secp256k1 of Secp256k1.Public_key.t | P256 of P256.Public_key.t - | Bls of Bls_aug.Public_key.t + | Bls_aug of Bls_aug.Public_key.t + | Bls_pop of Bls_pop.Public_key.t type watermark = | Block_header of Chain_id.t @@ -9989,7 +9991,8 @@ type signature = | Ed25519 of Ed25519.t | Secp256k1 of Secp256k1.t | P256 of P256.t - | Bls of Bls_aug.t + | Bls_aug of Bls_aug.t + | Bls_pop of Bls_pop.t | Unknown of Bytes.t type prefix = Bls_aug_prefix of Bytes.t | Bls_pop_prefix of Bytes.t diff --git a/src/lib_protocol_environment/sigs/v15/signature.mli b/src/lib_protocol_environment/sigs/v15/signature.mli index 39485d2ec379..c43ee41b1404 100644 --- a/src/lib_protocol_environment/sigs/v15/signature.mli +++ b/src/lib_protocol_environment/sigs/v15/signature.mli @@ -28,13 +28,15 @@ type public_key_hash = | Ed25519 of Ed25519.Public_key_hash.t | Secp256k1 of Secp256k1.Public_key_hash.t | P256 of P256.Public_key_hash.t - | Bls of Bls_aug.Public_key_hash.t + | Bls_aug of Bls_aug.Public_key_hash.t + | Bls_pop of Bls_pop.Public_key_hash.t type public_key = | Ed25519 of Ed25519.Public_key.t | Secp256k1 of Secp256k1.Public_key.t | P256 of P256.Public_key.t - | Bls of Bls_aug.Public_key.t + | Bls_aug of Bls_aug.Public_key.t + | Bls_pop of Bls_pop.Public_key.t type watermark = | Block_header of Chain_id.t @@ -46,7 +48,8 @@ type signature = | Ed25519 of Ed25519.t | Secp256k1 of Secp256k1.t | P256 of P256.t - | Bls of Bls_aug.t + | Bls_aug of Bls_aug.t + | Bls_pop of Bls_pop.t | Unknown of Bytes.t type prefix = Bls_aug_prefix of Bytes.t | Bls_pop_prefix of Bytes.t diff --git a/src/lib_wasm_debugger/messages.ml b/src/lib_wasm_debugger/messages.ml index 23cfc807ae1b..bee9fbae7e66 100644 --- a/src/lib_wasm_debugger/messages.ml +++ b/src/lib_wasm_debugger/messages.ml @@ -73,13 +73,13 @@ let input_encoding default_sender default_source default_destination : Sc_rollup.Inbox_message.( Internal (Transfer {payload; sender; source; destination})) -> let source = - Tezos_crypto.Signature.Of_V1.public_key_hash source + Tezos_crypto.Signature.Of_V2.public_key_hash source in Some (payload, sender, source, destination) | _ -> None) (fun (payload, sender, source, destination) -> let source = - Signature.V1.Of_V_latest.get_public_key_hash_exn source + Signature.V2.Of_V_latest.get_public_key_hash_exn source in `Inbox_message (Internal (Transfer {payload; sender; source; destination}))); diff --git a/src/proto_alpha/lib_benchmark/dune b/src/proto_alpha/lib_benchmark/dune index 64a0fb6e287d..84af6abdc23e 100644 --- a/src/proto_alpha/lib_benchmark/dune +++ b/src/proto_alpha/lib_benchmark/dune @@ -37,8 +37,8 @@ (action (write-file %{targets} - "include module type of Tezos_benchmark.Crypto_samplers.V1"))) + "include module type of Tezos_benchmark.Crypto_samplers.V2"))) (rule (targets crypto_samplers.ml) - (action (write-file %{targets} "include Tezos_benchmark.Crypto_samplers.V1"))) + (action (write-file %{targets} "include Tezos_benchmark.Crypto_samplers.V2"))) diff --git a/src/proto_alpha/lib_benchmark/michelson_samplers.ml b/src/proto_alpha/lib_benchmark/michelson_samplers.ml index 469df205b720..d048ecf46c14 100644 --- a/src/proto_alpha/lib_benchmark/michelson_samplers.ml +++ b/src/proto_alpha/lib_benchmark/michelson_samplers.ml @@ -605,7 +605,7 @@ module Make let signature rng_state = Script_signature.make - (Tezos_crypto.Signature.V1.Of_V_latest.get_signature_exn + (Tezos_crypto.Signature.V2.Of_V_latest.get_signature_exn (Michelson_base.signature rng_state)) let rec value : type a ac. (a, ac) Script_typed_ir.ty -> a sampler = diff --git a/src/proto_alpha/lib_benchmarks_proto/dune b/src/proto_alpha/lib_benchmarks_proto/dune index 49c990be9ef0..b1dbb68a2590 100644 --- a/src/proto_alpha/lib_benchmarks_proto/dune +++ b/src/proto_alpha/lib_benchmarks_proto/dune @@ -48,4 +48,4 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index ed15db1546c9..415e6f8b81db 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -3084,7 +3084,8 @@ module Registration_section = struct | Signature.Ed25519 -> Interpreter_workload.N_ICheck_signature_ed25519 | Signature.Secp256k1 -> Interpreter_workload.N_ICheck_signature_secp256k1 | Signature.P256 -> Interpreter_workload.N_ICheck_signature_p256 - | Signature.Bls -> Interpreter_workload.N_ICheck_signature_bls + | Signature.Bls_aug -> Interpreter_workload.N_ICheck_signature_bls + | Signature.Bls_pop -> Interpreter_workload.N_ICheck_signature_bls let check_signature (algo : Signature.algo) ~benchmark_type ~for_intercept = benchmark_with_stack_sampler @@ -3120,7 +3121,9 @@ module Registration_section = struct let () = check_signature Signature.P256 - let () = check_signature Signature.Bls + let () = check_signature Signature.Bls_aug + + let () = check_signature Signature.Bls_pop let () = simple_time_alloc_benchmark diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml index d18e6316cbd6..8dfb60450414 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml @@ -1459,10 +1459,15 @@ let extract_ir_sized_step : let signature = Size.of_int Signature.P256.size in let message = Size.bytes message in Instructions.check_signature_p256 pk signature message - | Signature.Bls pk -> + | Signature.Bls_aug pk -> let pk = Size.of_int (Signature.Bls_aug.Public_key.size pk) in let signature = Size.of_int Signature.Bls_aug.size in let message = Size.bytes message in + Instructions.check_signature_bls pk signature message + | Signature.Bls_pop pk -> + let pk = Size.of_int (Signature.Bls_pop.Public_key.size pk) in + let signature = Size.of_int Signature.Bls_pop.size in + let message = Size.bytes message in Instructions.check_signature_bls pk signature message) | IHash_key (_, _), _ -> Instructions.hash_key | IPack (_, ty, _), (v, _) -> ( diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index bb4c72523518..3bde6c0e24de 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -341,7 +341,7 @@ let build_update_consensus_key cctxt ?fee ?gas_limit ?storage_limit let open Lwt_result_syntax in let* proof = match ((public_key : Signature.public_key), secret_key_uri) with - | Bls _, Some secret_key_uri -> + | Bls_pop _, Some secret_key_uri -> let bytes = Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding @@ -833,8 +833,8 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run Signature.Ed25519.Public_key_hash.pp key.pkh) in - let pk = Tezos_crypto.Signature.Of_V1.public_key pk in - let sk = Tezos_crypto.Signature.Of_V1.secret_key sk in + let pk = Tezos_crypto.Signature.Of_V2.public_key pk in + let sk = Tezos_crypto.Signature.Of_V2.secret_key sk in let*? pk_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then diff --git a/src/proto_alpha/lib_client/dune b/src/proto_alpha/lib_client/dune index a6f90f08bf78..944bfcddc910 100644 --- a/src/proto_alpha/lib_client/dune +++ b/src/proto_alpha/lib_client/dune @@ -41,11 +41,11 @@ (rule (targets client_keys.ml) - (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v2"))) (rule (targets signature.ml) (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 0644eeeae20f..59378b90319a 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -616,10 +616,14 @@ let signature_size_of_algo : Signature.algo -> int = function | Ed25519 -> Signature.Ed25519.size | Secp256k1 -> Signature.Secp256k1.size | P256 -> Signature.P256.size - | Bls -> + | Bls_aug -> (* BLS signatures in operations are encoded with 2 extra bytes: a [ff] prefix and a tag [03]. *) Signature.Bls_aug.size + 2 + | Bls_pop -> + (* BLS signatures in operations are encoded with 2 extra bytes: a [ff] + prefix and a tag [03]. *) + Signature.Bls_pop.size + 2 (* This value is used as a safety guard for gas limit. *) let default_safety_guard = Gas.Arith.(integral_of_int_exn 100) @@ -1502,7 +1506,8 @@ let inject_manager_operation cctxt ~chain ~block ?successor_level ?branch | Ed25519 _ -> Signature.Ed25519 | Secp256k1 _ -> Secp256k1 | P256 _ -> P256 - | Bls _ -> Bls + | Bls_aug _ -> Bls_aug + | Bls_pop _ -> Bls_pop in match key with | None when not (has_reveal operations) -> ( diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index e58f81f0b19c..72f045722217 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -2345,7 +2345,7 @@ let commands_rw () = in let* secret_key_uri = match public_key with - | Bls _ -> + | Bls_pop _ -> let pkh = Signature.Public_key.hash public_key in let* _, _, secret_key_uri = Client_keys.get_key cctxt pkh in return_some secret_key_uri @@ -2401,7 +2401,7 @@ let commands_rw () = in let* secret_key_uri = match public_key with - | Bls _ -> + | Bls_pop _ -> let pkh = Signature.Public_key.hash public_key in let* _, _, secret_key_uri = Client_keys.get_key cctxt pkh in return_some secret_key_uri diff --git a/src/proto_alpha/lib_client_commands/dune b/src/proto_alpha/lib_client_commands/dune index 75ff918c1fe0..44c1c41cd228 100644 --- a/src/proto_alpha/lib_client_commands/dune +++ b/src/proto_alpha/lib_client_commands/dune @@ -43,11 +43,11 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) (rule (targets client_keys.ml) - (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v2"))) (library (name tezos_client_alpha_commands_registration) diff --git a/src/proto_alpha/lib_dal/dal_plugin_registration.ml b/src/proto_alpha/lib_dal/dal_plugin_registration.ml index 6c6a735d7967..de94df4be339 100644 --- a/src/proto_alpha/lib_dal/dal_plugin_registration.ml +++ b/src/proto_alpha/lib_dal/dal_plugin_registration.ml @@ -203,7 +203,7 @@ module Plugin = struct match operation_metadata.contents with | Single_result (Attestation_result result) -> let delegate = - Tezos_crypto.Signature.Of_V1.public_key_hash + Tezos_crypto.Signature.Of_V2.public_key_hash result.delegate in Some @@ -230,7 +230,7 @@ module Plugin = struct in List.fold_left (fun acc ({delegate; indexes} : Plugin.RPC.Dal.S.shards_assignment) -> - let delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate in + let delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate in Tezos_crypto.Signature.Public_key_hash.Map.add delegate indexes acc) Tezos_crypto.Signature.Public_key_hash.Map.empty pkh_to_shards diff --git a/src/proto_alpha/lib_dal/dune b/src/proto_alpha/lib_dal/dune index 23cc3edbe6ee..e5535884fe05 100644 --- a/src/proto_alpha/lib_dal/dune +++ b/src/proto_alpha/lib_dal/dune @@ -42,4 +42,4 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index 7e80347a0cc3..ac49e48988bd 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -680,7 +680,7 @@ let forge_and_sign_consensus_vote global_state ~branch unsigned_consensus_vote : let unsigned_operation = (shell, Contents_list contents) in let bls_mode = match delegate.consensus_key.public_key with - | Bls _ -> global_state.constants.parametric.aggregate_attestation + | Bls_pop _ -> global_state.constants.parametric.aggregate_attestation | _ -> false in let encoding = diff --git a/src/proto_alpha/lib_delegate/dune b/src/proto_alpha/lib_delegate/dune index 31efb026db58..2087ef618bfb 100644 --- a/src/proto_alpha/lib_delegate/dune +++ b/src/proto_alpha/lib_delegate/dune @@ -59,11 +59,11 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) (rule (targets client_keys.ml) - (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v2"))) (library (name tezos_baking_alpha_commands) diff --git a/src/proto_alpha/lib_delegate/node_rpc.ml b/src/proto_alpha/lib_delegate/node_rpc.ml index d05bb2432dc4..2bd8ec0dfbf3 100644 --- a/src/proto_alpha/lib_delegate/node_rpc.ml +++ b/src/proto_alpha/lib_delegate/node_rpc.ml @@ -380,7 +380,7 @@ let get_attestable_slots dal_node_rpc_ctxt delegate_id ~attested_level = Tezos_rpc.Context.make_call Tezos_dal_node_services.Services.get_attestable_slots dal_node_rpc_ctxt - (((), Tezos_crypto.Signature.Of_V1.public_key_hash pkh), attested_level) + (((), Tezos_crypto.Signature.Of_V2.public_key_hash pkh), attested_level) () () @@ -407,7 +407,7 @@ let register_dal_profiles dal_node_rpc_ctxt delegates = Tezos_dal_node_services.Operator_profile.make ~attesters: (List.map - (fun pkh -> Tezos_crypto.Signature.Of_V1.public_key_hash pkh) + (fun pkh -> Tezos_crypto.Signature.Of_V2.public_key_hash pkh) delegates) () in diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/dune b/src/proto_alpha/lib_delegate/test/mockup_simulator/dune index 585a8363dd33..8ace2bb902ed 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/dune +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/dune @@ -34,4 +34,4 @@ (rule (targets client_keys.ml) - (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v2"))) diff --git a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune index a9dd124d7e93..32302b2c1f6f 100644 --- a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune +++ b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune @@ -25,4 +25,4 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_injector/dune b/src/proto_alpha/lib_injector/dune index c787cbcc0990..248a7b8efb3c 100644 --- a/src/proto_alpha/lib_injector/dune +++ b/src/proto_alpha/lib_injector/dune @@ -24,11 +24,11 @@ (rule (targets client_keys.ml) - (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v2"))) (rule (targets signature.ml) (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_parameters/dune b/src/proto_alpha/lib_parameters/dune index 1d511b572382..f0c121dca3bc 100644 --- a/src/proto_alpha/lib_parameters/dune +++ b/src/proto_alpha/lib_parameters/dune @@ -21,7 +21,7 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) (executable (name gen) diff --git a/src/proto_alpha/lib_plugin/dune b/src/proto_alpha/lib_plugin/dune index ea6dc08c60a8..42538025632b 100644 --- a/src/proto_alpha/lib_plugin/dune +++ b/src/proto_alpha/lib_plugin/dune @@ -23,7 +23,7 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) (library (name tezos_protocol_plugin_alpha_registerer) diff --git a/src/proto_alpha/lib_plugin/mempool.ml b/src/proto_alpha/lib_plugin/mempool.ml index ec10e413c976..402b0b6c57e2 100644 --- a/src/proto_alpha/lib_plugin/mempool.ml +++ b/src/proto_alpha/lib_plugin/mempool.ml @@ -804,7 +804,7 @@ let sources_from_operation ctxt ({shell = _; protocol_data = Operation_data {contents; _}} : Main.operation) = let open Lwt_syntax in - let map_pkh_env = List.map Tezos_crypto.Signature.Of_V1.public_key_hash in + let map_pkh_env = List.map Tezos_crypto.Signature.Of_V2.public_key_hash in match contents with | Single (Failing_noop _) -> return_nil | Single (Preattestation consensus_content) diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 3ea45f381fc8..dda3070d4ad0 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -224,7 +224,7 @@ module Operation = struct if Constants.aggregate_attestation ctxt then (* attestations signed by BLS keys uses a dedicated serialization encoding *) match (op.protocol_data.contents, key) with - | Single (Attestation _), Bls _ -> bls_mode_unsigned_encoding + | Single (Attestation _), Bls_pop _ -> bls_mode_unsigned_encoding | _ -> unsigned_encoding else unsigned_encoding in diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index e90b67ca03ec..3ce6a4ff9c81 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1433,14 +1433,14 @@ let apply_manager_operation : in let* ctxt = match (public_key, proof) with - | Bls bls_public_key, Some (Bls _ as proof) -> + | Bls_pop bls_public_key, Some (Bls_pop _ as proof) -> let*? ctxt = let gas_cost_for_sig_check = let open Saturation_repr.Syntax in - let size = Bls_aug.Public_key.size bls_public_key in + let size = Bls_pop.Public_key.size bls_public_key in Operation_costs.serialization_cost size + Michelson_v1_gas.Cost_of.Interpreter.check_signature_on_algo - Bls + Bls_pop size in Gas.consume ctxt gas_cost_for_sig_check diff --git a/src/proto_alpha/lib_protocol/contract_delegate_storage.ml b/src/proto_alpha/lib_protocol/contract_delegate_storage.ml index c3d7df0f2db2..5949a4ee2253 100644 --- a/src/proto_alpha/lib_protocol/contract_delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/contract_delegate_storage.ml @@ -45,8 +45,8 @@ let () = let check_not_tz4 : Signature.Public_key_hash.t -> unit tzresult = let open Result_syntax in function - | Bls tz4 -> tzfail (Forbidden_tz4_delegate tz4) - | Ed25519 _ | Secp256k1 _ | P256 _ -> return_unit + | Bls_aug tz4 -> tzfail (Forbidden_tz4_delegate tz4) + | Ed25519 _ | Secp256k1 _ | P256 _ | Bls_pop _ -> return_unit let find = Storage.Contract.Delegate.find diff --git a/src/proto_alpha/lib_protocol/contract_repr.ml b/src/proto_alpha/lib_protocol/contract_repr.ml index 3c304f3d9852..b10aff3fcc48 100644 --- a/src/proto_alpha/lib_protocol/contract_repr.ml +++ b/src/proto_alpha/lib_protocol/contract_repr.ml @@ -56,7 +56,8 @@ let implicit_of_b58data : Base58.data -> Signature.public_key_hash option = | Ed25519.Public_key_hash.Data h -> Some (Signature.Ed25519 h) | Secp256k1.Public_key_hash.Data h -> Some (Signature.Secp256k1 h) | P256.Public_key_hash.Data h -> Some (Signature.P256 h) - | Bls_aug.Public_key_hash.Data h -> Some (Signature.Bls h) + | Bls_aug.Public_key_hash.Data h -> Some (Signature.Bls_aug h) + | Bls_pop.Public_key_hash.Data h -> Some (Signature.Bls_pop h) | _ -> None let originated_of_b58data = function diff --git a/src/proto_alpha/lib_protocol/delegate_consensus_key.ml b/src/proto_alpha/lib_protocol/delegate_consensus_key.ml index 38cb284086bf..675b43aa0d2d 100644 --- a/src/proto_alpha/lib_protocol/delegate_consensus_key.ml +++ b/src/proto_alpha/lib_protocol/delegate_consensus_key.ml @@ -124,8 +124,8 @@ let check_unused ctxt pkh = let check_not_tz4 : Signature.Public_key.t -> unit tzresult = let open Result_syntax in function - | Bls pk -> tzfail (Invalid_consensus_key_update_tz4 pk) - | Ed25519 _ | Secp256k1 _ | P256 _ -> return_unit + | Bls_aug pk -> tzfail (Invalid_consensus_key_update_tz4 pk) + | Ed25519 _ | Secp256k1 _ | P256 _ | Bls_pop _ -> return_unit let set_unused = Storage.Consensus_keys.remove diff --git a/src/proto_alpha/lib_protocol/michelson_v1_gas.ml b/src/proto_alpha/lib_protocol/michelson_v1_gas.ml index 7598a54cee07..9390782e74e4 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_gas.ml +++ b/src/proto_alpha/lib_protocol/michelson_v1_gas.ml @@ -304,28 +304,31 @@ module Cost_of = struct let view = atomic_step_cost cost_N_IView - type algo = Ed25519 | Secp256k1 | P256 | Bls + type algo = Ed25519 | Secp256k1 | P256 | Bls_aug | Bls_pop let algo_of_public_key (pkey : Signature.public_key) = match pkey with | Ed25519 _ -> Ed25519 | Secp256k1 _ -> Secp256k1 | P256 _ -> P256 - | Bls _ -> Bls + | Bls_aug _ -> Bls_aug + | Bls_pop _ -> Bls_pop let algo_of_public_key_hash (pkh : Signature.public_key_hash) = match pkh with | Ed25519 _ -> Ed25519 | Secp256k1 _ -> Secp256k1 | P256 _ -> P256 - | Bls _ -> Bls + | Bls_aug _ -> Bls_aug + | Bls_pop _ -> Bls_pop let check_signature_on_algo algo length = match algo with | Ed25519 -> cost_N_ICheck_signature_ed25519 length | Secp256k1 -> cost_N_ICheck_signature_secp256k1 length | P256 -> cost_N_ICheck_signature_p256 length - | Bls -> cost_N_ICheck_signature_bls length + | Bls_aug -> cost_N_ICheck_signature_bls length + | Bls_pop -> cost_N_ICheck_signature_bls length let check_signature pkey b = check_signature_on_algo (algo_of_public_key pkey) (Bytes.length b) diff --git a/src/proto_alpha/lib_protocol/michelson_v1_gas.mli b/src/proto_alpha/lib_protocol/michelson_v1_gas.mli index 530321c16332..f0650fe01d1d 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_gas.mli +++ b/src/proto_alpha/lib_protocol/michelson_v1_gas.mli @@ -239,7 +239,7 @@ module Cost_of : sig val dip : Gas.cost - type algo = Ed25519 | Secp256k1 | P256 | Bls + type algo = Ed25519 | Secp256k1 | P256 | Bls_aug | Bls_pop val algo_of_public_key : Signature.public_key -> algo diff --git a/src/proto_alpha/lib_protocol/script_typed_ir_size.ml b/src/proto_alpha/lib_protocol/script_typed_ir_size.ml index e3ade406d01d..95ba5df7ca08 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir_size.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir_size.ml @@ -127,7 +127,7 @@ let signature_size (Script_signature.Signature_tag x) = match x with (* By Obj.reachable_words. *) | Ed25519 _ | Secp256k1 _ | P256 _ | Unknown _ -> !!96 - | Bls _ -> !!128 + | Bls_aug _ | Bls_pop _ -> !!128 let key_hash_size (_x : Signature.public_key_hash) = !!64 (* By Obj.reachable_words. *) @@ -139,7 +139,8 @@ let public_key_size (x : public_key) = | Ed25519 _ -> 64 | Secp256k1 _ -> 72 | P256 _ -> 96 - | Bls _ -> 64 + | Bls_aug _ -> 64 + | Bls_pop _ -> 64 let mutez_size = h2w diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index db7ac5b27737..1570780aef4a 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1067,13 +1067,15 @@ module Public_key_hash = struct module Path_Secp256k1 = Path_encoding.Make_hex (Secp256k1.Public_key_hash) module Path_P256 = Path_encoding.Make_hex (P256.Public_key_hash) module Path_Bls_aug = Path_encoding.Make_hex (Bls_aug.Public_key_hash) + module Path_Bls_pop = Path_encoding.Make_hex (Bls_pop.Public_key_hash) let to_path (key : public_key_hash) l = match key with | Ed25519 h -> "ed25519" :: Path_Ed25519.to_path h l | Secp256k1 h -> "secp256k1" :: Path_Secp256k1.to_path h l | P256 h -> "p256" :: Path_P256.to_path h l - | Bls h -> "bls" :: Path_Bls_aug.to_path h l + | Bls_aug h -> "bls" :: Path_Bls_aug.to_path h l + | Bls_pop h -> "bls_pop" :: Path_Bls_pop.to_path h l let of_path : _ -> public_key_hash option = function | "ed25519" :: rest -> ( @@ -1090,7 +1092,11 @@ module Public_key_hash = struct | None -> None) | "bls" :: rest -> ( match Path_Bls_aug.of_path rest with - | Some pkh -> Some (Bls pkh) + | Some pkh -> Some (Bls_aug pkh) + | None -> None) + | "bls_pop" :: rest -> ( + match Path_Bls_pop.of_path rest with + | Some pkh -> Some (Bls_pop pkh) | None -> None) | _ -> None @@ -1098,8 +1104,9 @@ module Public_key_hash = struct let l1 = Path_Ed25519.path_length and l2 = Path_Secp256k1.path_length and l3 = Path_P256.path_length - and l4 = Path_Bls_aug.path_length in - assert (Compare.Int.(l1 = l2 && l2 = l3 && l3 = l4)) ; + and l4 = Path_Bls_aug.path_length + and l5 = Path_Bls_pop.path_length in + assert (Compare.Int.(l1 = l2 && l2 = l3 && l3 = l4 && l4 = l5)) ; l1 + 1 end diff --git a/src/proto_alpha/lib_protocol/test/helpers/account.ml b/src/proto_alpha/lib_protocol/test/helpers/account.ml index c784bada9a14..29a69f894467 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/account.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/account.ml @@ -45,7 +45,8 @@ let random_algo ~rng_state : Signature.algo = | 0 -> Ed25519 | 1 -> Secp256k1 | 2 -> P256 - | 3 -> Bls + | 3 -> Bls_aug + | 4 -> Bls_pop | _ -> assert false let new_account ?(rng_state = Random.State.make_self_init ()) diff --git a/src/proto_alpha/lib_protocol/test/helpers/dune b/src/proto_alpha/lib_protocol/test/helpers/dune index e97e8678e805..6edd765b99ff 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dune +++ b/src/proto_alpha/lib_protocol/test/helpers/dune @@ -43,4 +43,4 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 527b8c92a083..bca6e255eee4 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -142,7 +142,8 @@ let aggregate attestations = op in match (contents, signature) with - | Single (Attestation {consensus_content; _}), Some (Bls bls_sig) -> ( + | Single (Attestation {consensus_content; _}), Some (Bls_pop bls_sig) + -> ( let {slot; _} = consensus_content in match acc with | Some (shell, proposal, slots, signatures) -> @@ -157,14 +158,12 @@ let aggregate attestations = in let open Option_syntax in let* shell, consensus_content, committee, signatures = aggregate_content in - let+ signature = - Bls12_381_signature.MinPk.aggregate_signature_opt signatures - in + let+ signature = Signature.Bls_pop.aggregate_signature_opt signatures in let contents = Single (Attestations_aggregate {consensus_content; committee}) in let protocol_data = - Operation_data {contents; signature = Some (Bls signature)} + Operation_data {contents; signature = Some (Bls_pop signature)} in {shell; protocol_data} @@ -196,7 +195,7 @@ let attestations_aggregate ?committee ?level ?round ?block_payload_hash ?branch @@ List.filter_map (fun attester -> match attester.Plugin.RPC.Validators.consensus_key with - | Bls _ -> Some attester.delegate + | Bls_pop _ -> Some attester.delegate | _ -> None) attesters in diff --git a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml index 0e2f77e32de6..43d4fbf253fb 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml @@ -168,7 +168,14 @@ let random_tz3 = let random_tz4 = let open QCheck2.Gen in let+ str = string_size (pure Signature.Bls_aug.Public_key_hash.size) in - (Bls (Signature.Bls_aug.Public_key_hash.of_string_exn str) : public_key_hash) + (Bls_aug (Signature.Bls_aug.Public_key_hash.of_string_exn str) + : public_key_hash) + +let random_tz5 = + let open QCheck2.Gen in + let+ str = string_size (pure Signature.Bls_pop.Public_key_hash.size) in + (Bls_pop (Signature.Bls_pop.Public_key_hash.of_string_exn str) + : public_key_hash) let random_pkh = let open QCheck2.Gen in @@ -177,7 +184,8 @@ let random_pkh = | Ed25519 -> random_tz1 | Secp256k1 -> random_tz2 | P256 -> random_tz3 - | Bls -> random_tz4 + | Bls_aug -> random_tz4 + | Bls_pop -> random_tz5 let random_pk = let open QCheck2.Gen in @@ -200,9 +208,13 @@ let random_signature = | Some P256 -> let+ str = string_size (pure Signature.P256.size) in (P256 (Signature.P256.of_string_exn str) : Signature.t) - | Some Bls -> + | Some Bls_aug -> + let+ seed = random_seed in + let _, _, sk = Signature.generate_key ~algo:Bls_aug ~seed () in + Signature.sign sk Bytes.empty + | Some Bls_pop -> let+ seed = random_seed in - let _, _, sk = Signature.generate_key ~algo:Bls ~seed () in + let _, _, sk = Signature.generate_key ~algo:Bls_pop ~seed () in Signature.sign sk Bytes.empty let random_signature = @@ -215,6 +227,7 @@ let random_signature = of_secp256k1 Signature.Secp256k1.zero; of_p256 Signature.P256.zero; of_bls Signature.Bls_aug.zero; + of_bls_pop Signature.Bls_pop.zero; Unknown (Bytes.make 64 '\000'); ] () diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_aggregate.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_aggregate.ml index feaa83e51025..e768e30366e2 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_aggregate.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_aggregate.ml @@ -21,7 +21,7 @@ let init_genesis_with_some_bls_accounts ?policy ?dal_enable let*? random_accounts = Account.generate_accounts 3 in let*? bls_accounts = List.init ~when_negative_length:[] 2 (fun _ -> - Account.new_account ~algo:Signature.Bls ()) + Account.new_account ~algo:Signature.Bls_pop ()) in let bootstrap_accounts = Account.make_bootstrap_accounts (random_accounts @ bls_accounts) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml index 4b34ea5ffcd4..ee481b758941 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml @@ -214,7 +214,7 @@ let test_tz4_consensus_key ~allow_tz4_delegate_enable () = Context.init_with_constants1 {constants with allow_tz4_delegate_enable} in let account1_pkh = Context.Contract.pkh contract in - let consensus_account = Account.new_account ~algo:Bls () in + let consensus_account = Account.new_account ~algo:Bls_aug () in let delegate = account1_pkh in let consensus_pk = consensus_account.pk in let consensus_pkh = consensus_account.pkh in @@ -224,7 +224,7 @@ let test_tz4_consensus_key ~allow_tz4_delegate_enable () = let* operation = Op.update_consensus_key (B blk') (Contract.Implicit delegate) consensus_pk in - let tz4_pk = match consensus_pk with Bls pk -> pk | _ -> assert false in + let tz4_pk = match consensus_pk with Bls_aug pk -> pk | _ -> assert false in let* inc = Incremental.begin_construction blk' in if allow_tz4_delegate_enable then let expect_failure = function diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_delegation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_delegation.ml index 823913dfe20c..0ab0c0482231 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_delegation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_delegation.ml @@ -1557,7 +1557,7 @@ let test_bls_account_self_delegate ~allow_tz4_delegate_enable () = Context.init1 ~consensus_threshold_size:0 ~allow_tz4_delegate_enable () in let {Account.pkh = tz4_pkh; pk = tz4_pk; _} = - Account.new_account ~algo:Bls () + Account.new_account ~algo:Bls_aug () in let tz4_contract = Alpha_context.Contract.Implicit tz4_pkh in let* operation = @@ -1573,7 +1573,7 @@ let test_bls_account_self_delegate ~allow_tz4_delegate_enable () = let* b = Block.bake ~operation b in let* operation = Op.delegation (B b) tz4_contract (Some tz4_pkh) in let* inc = Incremental.begin_construction b in - let tz4_pkh = match tz4_pkh with Bls pkh -> pkh | _ -> assert false in + let tz4_pkh = match tz4_pkh with Bls_aug pkh -> pkh | _ -> assert false in if allow_tz4_delegate_enable then let* (_i : Incremental.t) = Incremental.validate_operation inc operation in return_unit diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml index c82f7520c2e8..9e5e7fadd397 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml @@ -665,7 +665,7 @@ let attestations_aggregate_descriptor = let delegate = Option.value ~default:delegate consensus_key_opt in let* signer = Account.find delegate in match (slots_opt, signer.sk) with - | Some (_ :: _), Bls _ -> + | Some (_ :: _), Bls_pop _ -> let* op = Op.raw_attestation ~delegate state.block in return (Some op) | _, _ -> return_none) diff --git a/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml b/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml index ff4731b53c0b..4994da84ddc9 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml @@ -96,7 +96,7 @@ module Test_operation_repr = struct | Error _ -> return_unit let zero_bls = - match Signature.(split_signature (Bls Signature.Bls_aug.zero)) with + match Signature.(split_signature (Bls_aug Signature.Bls_aug.zero)) with | {prefix = None; _} -> assert false | {prefix = Some prefix; suffix} -> let prefix = diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index 9c090d59f387..5c4163d15083 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -2386,26 +2386,27 @@ module Manager = struct let open Result_syntax in if Constants.allow_tz4_delegate_enable vi.ctxt then match (public_key, proof) with - | Bls _bls_public_key, None -> + | Bls_pop _bls_public_key, None -> result_error (Validate_errors.Manager.Update_consensus_key_with_tz4_without_proof {source; public_key}) - | ( Bls _bls_public_key, + | ( Bls_pop _bls_public_key, Some - ((Signature.Ed25519 _ | Signature.Secp256k1 _ | Signature.P256 _) as - proof) ) -> + (( Signature.Ed25519 _ | Signature.Secp256k1 _ | Signature.P256 _ + | Signature.Bls_aug _ ) as proof) ) -> result_error (Validate_errors.Manager.Update_consensus_key_with_incorrect_proof {public_key; proof}) - | Bls bls_public_key, Some (Signature.Bls _ | Signature.Unknown _) -> + | Bls_pop bls_public_key, Some (Signature.Bls_pop _ | Signature.Unknown _) + -> (* Compute the gas cost to encode the consensus public key and check the proof. *) let gas_cost_for_sig_check = let open Saturation_repr.Syntax in - let size = Bls_aug.Public_key.size bls_public_key in + let size = Bls_pop.Public_key.size bls_public_key in Operation_costs.serialization_cost size + Michelson_v1_gas.Cost_of.Interpreter.check_signature_on_algo - Bls + Bls_pop size in let* (_ : Gas.Arith.fp) = @@ -2416,11 +2417,11 @@ module Manager = struct gas_cost_for_sig_check) in return_unit - | (Ed25519 _ | Secp256k1 _ | P256 _), Some _proof -> + | (Ed25519 _ | Secp256k1 _ | P256 _ | Bls_aug _), Some _proof -> result_error (Validate_errors.Manager.Update_consensus_key_with_unused_proof {source; public_key}) - | (Ed25519 _ | Secp256k1 _ | P256 _), None -> return_unit + | (Ed25519 _ | Secp256k1 _ | P256 _ | Bls_aug _), None -> return_unit else let* () = Delegate.Consensus_key.check_not_tz4 public_key in if Option.is_some proof then diff --git a/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index c3ef8ca13b04..6e7071b54b95 100644 --- a/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_alpha/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -332,13 +332,13 @@ module Game = struct let index_of_octez Octez_smart_rollup.Game.{alice; bob} = Sc_rollup.Game.Index.make - (Signature.V1.Of_V_latest.get_public_key_hash_exn alice) - (Signature.V1.Of_V_latest.get_public_key_hash_exn bob) + (Signature.V2.Of_V_latest.get_public_key_hash_exn alice) + (Signature.V2.Of_V_latest.get_public_key_hash_exn bob) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = Octez_smart_rollup.Game.make_index - (Signature.Of_V1.public_key_hash alice) - (Signature.Of_V1.public_key_hash bob) + (Signature.Of_V2.public_key_hash alice) + (Signature.Of_V2.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -438,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other = Signature.V1.Of_V_latest.get_public_key_hash_exn other; + other = Signature.V2.Of_V_latest.get_public_key_hash_exn other; their_commitment = Commitment.of_octez their_commitment; our_commitment = Commitment.of_octez our_commitment; parent_commitment; @@ -449,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other = Signature.Of_V1.public_key_hash other; + other = Signature.Of_V2.public_key_hash other; their_commitment = Commitment.to_octez their_commitment; our_commitment = Commitment.to_octez our_commitment; parent_commitment; diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml index fe5dd0cb5c04..6ffbfe183ed9 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml @@ -219,7 +219,7 @@ let process_included_l1_operation (type kind) ~catching_up | Loser {loser; reason} when Node_context.is_operator node_ctxt - (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> + (Tezos_crypto.Signature.Of_V2.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -233,11 +233,11 @@ let process_included_l1_operation (type kind) ~catching_up let stakers = match operation with | Sc_rollup_refute {opponent; _} -> - [source; Tezos_crypto.Signature.Of_V1.public_key_hash opponent] + [source; Tezos_crypto.Signature.Of_V2.public_key_hash opponent] | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [ - Tezos_crypto.Signature.Of_V1.public_key_hash alice; - Tezos_crypto.Signature.Of_V1.public_key_hash bob; + Tezos_crypto.Signature.Of_V2.public_key_hash alice; + Tezos_crypto.Signature.Of_V2.public_key_hash bob; ] | _ -> assert false in @@ -264,7 +264,7 @@ let process_included_l1_operation (type kind) ~catching_up fail_when Tezos_crypto.Signature.Public_key_hash.( operating_pkh - = Tezos_crypto.Signature.Of_V1.public_key_hash staker) + = Tezos_crypto.Signature.Of_V2.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -309,7 +309,7 @@ let process_included_l1_operation (type kind) ~catching_up else let whitelist_update = List.map - Tezos_crypto.Signature.Of_V1.public_key_hash + Tezos_crypto.Signature.Of_V2.public_key_hash whitelist_update in let*? () = @@ -385,7 +385,7 @@ let process_l1_block_operations ~catching_up node_ctxt (head : Layer1.header) = = let open Lwt_result_syntax in let* () = accu in - let source = Tezos_crypto.Signature.Of_V1.public_key_hash source in + let source = Tezos_crypto.Signature.Of_V2.public_key_hash source in process_l1_operation ~catching_up node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_alpha/lib_sc_rollup_node/dune b/src/proto_alpha/lib_sc_rollup_node/dune index a341906fa2b3..47a88d6dc224 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dune +++ b/src/proto_alpha/lib_sc_rollup_node/dune @@ -79,4 +79,4 @@ (action (write-file %{targets} - " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n include Tezos_crypto.Signature.V1"))) + " module Bls_aug = Tezos_crypto.Signature.Bls_aug\n module Ed25519 = Tezos_crypto.Signature.Ed25519\n module P256 = Tezos_crypto.Signature.P256\n module Secp256k1 = Tezos_crypto.Signature.Secp256k1\n module Bls_pop = Tezos_crypto.Signature.Bls_pop\n include Tezos_crypto.Signature.V2"))) diff --git a/src/proto_alpha/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/layer1_helpers.ml index 3fce20a4ca9d..6aae50684e54 100644 --- a/src/proto_alpha/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/layer1_helpers.ml @@ -248,7 +248,7 @@ let find_whitelist cctxt ?block rollup_address = in return @@ Option.map - (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + (List.map Tezos_crypto.Signature.Of_V2.public_key_hash) whitelist let find_last_whitelist_update cctxt rollup_address = diff --git a/src/proto_alpha/lib_sc_rollup_node/pvm_plugin.ml b/src/proto_alpha/lib_sc_rollup_node/pvm_plugin.ml index a257b8e54882..c82840b2ba18 100644 --- a/src/proto_alpha/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_alpha/lib_sc_rollup_node/pvm_plugin.ml @@ -157,7 +157,7 @@ let outbox_message_summary (output : Sc_rollup.output) = | {message = Whitelist_update pkhs; _} -> Outbox_message.Whitelist_update (Option.map - (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + (List.map Tezos_crypto.Signature.Of_V2.public_key_hash) pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in diff --git a/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml index 8378d7ace894..e56084bdca8a 100644 --- a/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml @@ -412,6 +412,6 @@ let get_ongoing_games cctxt rollup staker = List.map (fun (game, staker1, staker2) -> ( Sc_rollup_proto_types.Game.to_octez game, - Tezos_crypto.Signature.Of_V1.public_key_hash staker1, - Tezos_crypto.Signature.Of_V1.public_key_hash staker2 )) + Tezos_crypto.Signature.Of_V2.public_key_hash staker1, + Tezos_crypto.Signature.Of_V2.public_key_hash staker2 )) games diff --git a/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml index 3a393a0517b8..05ffd2e39309 100644 --- a/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml @@ -104,7 +104,7 @@ let injector_operation_of_manager : let refutation = Sc_rollup_proto_types.Game.refutation_to_octez refutation in - let opponent = Tezos_crypto.Signature.Of_V1.public_key_hash opponent in + let opponent = Tezos_crypto.Signature.Of_V2.public_key_hash opponent in Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in diff --git a/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml b/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml index 0ca3339ea0a6..6acc5ba6df14 100644 --- a/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml +++ b/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml @@ -111,15 +111,17 @@ let random_seed ~rng_state = Char.chr (Random.State.int rng_state 256)) let random_algo ~rng_state : Signature.algo = - match Random.State.int rng_state 3 with + match Random.State.int rng_state 4 with | 0 -> Ed25519 | 1 -> Secp256k1 | 2 -> P256 - | 3 -> Bls + | 3 -> Bls_aug + | 4 -> Bls_pop | _ -> assert false let gen_algo = - QCheck2.Gen.oneofl [Tezos_crypto.Signature.Ed25519; Secp256k1; P256; Bls_aug] + QCheck2.Gen.oneofl + [Tezos_crypto.Signature.Ed25519; Secp256k1; P256; Bls_aug; Bls_pop] let gen_pkh = let open QCheck2.Gen in diff --git a/teztale/bin_teztale_archiver/alpha_machine.real.ml b/teztale/bin_teztale_archiver/alpha_machine.real.ml index 6778f95186df..07f2d4f4b774 100644 --- a/teztale/bin_teztale_archiver/alpha_machine.real.ml +++ b/teztale/bin_teztale_archiver/alpha_machine.real.ml @@ -46,7 +46,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Consensus_ops. { address = - Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + Tezos_crypto.Signature.Of_V2.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -160,7 +160,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in return - ( Tezos_crypto.Signature.Of_V1.public_key_hash + ( Tezos_crypto.Signature.Of_V2.public_key_hash metadata.protocol_data.baker.delegate, cycle_info ) @@ -177,7 +177,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> { - Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + Data.delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate; round = Protocol.Alpha_context.Round.to_int32 round; }) baking_rights @@ -243,7 +243,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate; power = consensus_power; } :: acc @@ -263,7 +263,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate; power = consensus_power; } :: acc @@ -282,7 +282,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let*? round = raw_block_round header.shell in let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Level level) in return - ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + ( ( Tezos_crypto.Signature.Of_V2.public_key_hash metadata.protocol_data.baker.delegate, header.shell.timestamp, round, -- GitLab