From 3e33d28b62807d195dcf951c8867ff1826d30104 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Sat, 1 Mar 2025 10:32:23 +0100 Subject: [PATCH 1/4] Env15: set the signature version to 2 --- devtools/yes_wallet/get_delegates_alpha.ml | 16 +++++++++++++--- manifest/product_octez.ml | 19 +++++++++++++++---- .../environment_V15.ml | 15 ++++++--------- .../environment_V15.mli | 10 +++++----- 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 +- .../lib_client/client_proto_context.ml | 4 ++-- src/proto_alpha/lib_client/dune | 4 ++-- src/proto_alpha/lib_client_commands/dune | 4 ++-- .../lib_dal/dal_plugin_registration.ml | 4 ++-- src/proto_alpha/lib_dal/dune | 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 +- .../lib_protocol/test/helpers/dune | 2 +- .../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 +- .../alpha_machine.real.ml | 12 ++++++------ 30 files changed, 91 insertions(+), 73 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 2872ae64b1c2..c550705db41e 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -6483,7 +6483,8 @@ 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|}); + include Tezos_crypto.Signature.V%d|} + (if N.(number <= 022) then 1 else 2)); ] in let dune_client_keys_version_rule = @@ -6494,7 +6495,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 = @@ -7343,7 +7347,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 <= 022) then 1 else 2)); ]; Dune.targets_rule ["crypto_samplers.ml"] @@ -7351,7 +7359,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 <= 022) then 1 else 2)); ]; ] in diff --git a/src/lib_protocol_environment/environment_V15.ml b/src/lib_protocol_environment/environment_V15.ml index 62db2059bbba..72d699524533 100644 --- a/src/lib_protocol_environment/environment_V15.ml +++ b/src/lib_protocol_environment/environment_V15.ml @@ -83,11 +83,11 @@ module type T = sig and type Bls.Public_key.t = Tezos_crypto.Signature.Bls.Public_key.t and type Bls.t = Tezos_crypto.Signature.Bls.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 @@ -338,7 +338,7 @@ struct module Bls = Tezos_crypto.Signature.Bls module Signature = struct - include Tezos_crypto.Signature.V1 + include Tezos_crypto.Signature.V2 let check ?watermark pk s bytes = (check @@ -1589,9 +1589,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 e1defb4f4d8e..9897cdfe1faa 100644 --- a/src/lib_protocol_environment/environment_V15.mli +++ b/src/lib_protocol_environment/environment_V15.mli @@ -83,11 +83,11 @@ module type T = sig and type Bls.Public_key.t = Tezos_crypto.Signature.Bls.Public_key.t and type Bls.t = Tezos_crypto.Signature.Bls.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_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 1f7fd4dd2cd4..ab4dee128f24 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index bb4c72523518..981c9922988f 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -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 31d6dfa4df85..53f813bacb96 100644 --- a/src/proto_alpha/lib_client/dune +++ b/src/proto_alpha/lib_client/dune @@ -40,11 +40,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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) diff --git a/src/proto_alpha/lib_client_commands/dune b/src/proto_alpha/lib_client_commands/dune index 5f6379ca6229..9314f6b52140 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.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 119813a1b893..1f49359b697d 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 586970cd0535..dda46f6ad2ac 100644 --- a/src/proto_alpha/lib_dal/dune +++ b/src/proto_alpha/lib_dal/dune @@ -41,4 +41,4 @@ (action (write-file %{targets} - " module Bls = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) diff --git a/src/proto_alpha/lib_delegate/dune b/src/proto_alpha/lib_delegate/dune index f8aeaf8fab7f..b821b6c7c203 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.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 1754a62aeb67..1f0fb9f0174b 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) diff --git a/src/proto_alpha/lib_injector/dune b/src/proto_alpha/lib_injector/dune index b25f426e0187..db2b4d0f6287 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) diff --git a/src/proto_alpha/lib_parameters/dune b/src/proto_alpha/lib_parameters/dune index 0bd6fb2f5c7c..c793b35fb71a 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) (executable (name gen) diff --git a/src/proto_alpha/lib_plugin/dune b/src/proto_alpha/lib_plugin/dune index eaba3e58437e..6d34d60cf470 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.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/test/helpers/dune b/src/proto_alpha/lib_protocol/test/helpers/dune index 9a67c96dbb94..d6c7d6035a1f 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.V2"))) 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 556fb5d82662..8eb75419c45f 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 = Tezos_crypto.Signature.Bls\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 = Tezos_crypto.Signature.Bls\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.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/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 From 30a874a542d807fd08f84f8627fc9f15da706b5a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Sun, 2 Mar 2025 17:01:57 +0100 Subject: [PATCH 2/4] lib_crypto: use BLS Pop instead of Aug --- src/lib_crypto/aggregate_signature.ml | 7 ++++--- src/lib_crypto/bls.ml | 14 +++++++++++++- src/lib_crypto/bls.mli | 4 ++++ src/lib_crypto/signature_v1.ml | 6 +++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/lib_crypto/aggregate_signature.ml b/src/lib_crypto/aggregate_signature.ml index ad5ea65917cf..e29e031c012f 100644 --- a/src/lib_crypto/aggregate_signature.ml +++ b/src/lib_crypto/aggregate_signature.ml @@ -461,16 +461,17 @@ let pp ppf t = Format.fprintf ppf "%s" (to_b58check t) let zero = Bls12_381 Bls.zero let sign ?watermark (Secret_key.Bls12_381 sk) bytes = - Bls12_381 (Bls.sign ?watermark sk bytes) + Bls12_381 (Bls.sign_aug ?watermark sk bytes) let check ?watermark pk signature message = match (pk, signature) with | Public_key.Bls12_381 pk, Unknown signature -> Bls.of_bytes_opt signature - |> Option.map (fun signature -> Bls.check ?watermark pk signature message) + |> Option.map (fun signature -> + Bls.check_aug ?watermark pk signature message) |> Option.value ~default:false | Public_key.Bls12_381 pk, Bls12_381 signature -> - Bls.check ?watermark pk signature message + Bls.check_aug ?watermark pk signature message let generate_key ?seed () = let pkh, pk, sk = Bls.generate_key ?seed () in diff --git a/src/lib_crypto/bls.ml b/src/lib_crypto/bls.ml index 8918679b47eb..eecc7872fd7e 100644 --- a/src/lib_crypto/bls.ml +++ b/src/lib_crypto/bls.ml @@ -327,17 +327,29 @@ let zero = "\192\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" let sign ?watermark sk msg = + let msg = + match watermark with None -> msg | Some prefix -> Bytes.cat prefix msg + in + Bls12_381_signature.MinPk.Pop.sign sk msg + +let sign_aug ?watermark sk msg = let msg = match watermark with None -> msg | Some prefix -> Bytes.cat prefix msg in Bls12_381_signature.MinPk.Aug.sign sk msg -let check ?watermark pk signature msg = +let check_aug ?watermark pk signature msg = let msg = match watermark with None -> msg | Some prefix -> Bytes.cat prefix msg in Bls12_381_signature.MinPk.Aug.verify pk msg signature +let check ?watermark pk signature msg = + let msg = + match watermark with None -> msg | Some prefix -> Bytes.cat prefix msg + in + Bls12_381_signature.MinPk.Pop.verify pk msg signature + (* [seed] must be at least of 32 bytes or [Bls12_381_signature.generate_sk] will throw an error. *) let generate_key ?seed () = diff --git a/src/lib_crypto/bls.mli b/src/lib_crypto/bls.mli index 2827c7fd263c..246570c0c255 100644 --- a/src/lib_crypto/bls.mli +++ b/src/lib_crypto/bls.mli @@ -44,3 +44,7 @@ module Primitive : sig val pairing_check : (G1.t * G2.t) list -> bool end + +val sign_aug : ?watermark:watermark -> Bls12_381_signature.sk -> watermark -> t + +val check_aug : ?watermark:watermark -> Public_key.t -> t -> watermark -> bool diff --git a/src/lib_crypto/signature_v1.ml b/src/lib_crypto/signature_v1.ml index a6313b5a6c4c..a0914fe643c5 100644 --- a/src/lib_crypto/signature_v1.ml +++ b/src/lib_crypto/signature_v1.ml @@ -786,7 +786,7 @@ let sign ?watermark secret_key message = | Secret_key.Ed25519 sk -> of_ed25519 (Ed25519.sign ?watermark sk message) | Secp256k1 sk -> of_secp256k1 (Secp256k1.sign ?watermark sk message) | P256 sk -> of_p256 (P256.sign ?watermark sk message) - | Bls sk -> of_bls (Bls.sign ?watermark sk message) + | Bls sk -> of_bls (Bls.sign_aug ?watermark sk message) let check ?watermark public_key signature message = let watermark = Option.map bytes_of_watermark watermark in @@ -805,7 +805,7 @@ let check ?watermark public_key signature message = | None -> false) | Public_key.Bls pk, Unknown signature -> ( match Bls.of_bytes_opt signature with - | Some s -> Bls.check ?watermark pk s message + | Some s -> Bls.check_aug ?watermark pk s message | None -> false) | Public_key.Ed25519 pk, Ed25519 signature -> Ed25519.check ?watermark pk signature message @@ -814,7 +814,7 @@ let check ?watermark public_key signature message = | Public_key.P256 pk, P256 signature -> P256.check ?watermark pk signature message | Public_key.Bls pk, Bls signature -> - Bls.check ?watermark pk signature message + Bls.check_aug ?watermark pk signature message | _ -> false let fake_sign_from_pk pk msg = -- GitLab From d6fcd7b62392ac0ba842c6edca3a30dddc88f65b Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Mar 2025 09:06:50 +0100 Subject: [PATCH 3/4] lib_crypto/test: force the aug usage for bls aggregate test --- src/lib_crypto/test/test_prop_signature.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib_crypto/test/test_prop_signature.ml b/src/lib_crypto/test/test_prop_signature.ml index 1e709784c83f..04444581d6bb 100644 --- a/src/lib_crypto/test/test_prop_signature.ml +++ b/src/lib_crypto/test/test_prop_signature.ml @@ -77,6 +77,10 @@ end module type AGGREGATE_SIGNATURE = sig include Intfs.AGGREGATE_SIGNATURE + val sign_aug : ?watermark:watermark -> Secret_key.t -> bytes -> t + + val check_aug : ?watermark:watermark -> Public_key.t -> t -> bytes -> bool + val watermark_of_bytes : bytes -> watermark end @@ -101,9 +105,9 @@ struct let watermark1 = Option.map X.watermark_of_bytes watermark1 in let watermark2 = Option.map X.watermark_of_bytes watermark2 in let watermark3 = Option.map X.watermark_of_bytes watermark3 in - let signed1 = X.sign ?watermark:watermark1 sk1 msg1 in - let signed2 = X.sign ?watermark:watermark2 sk2 msg2 in - let signed3 = X.sign ?watermark:watermark3 sk3 msg3 in + let signed1 = X.sign_aug ?watermark:watermark1 sk1 msg1 in + let signed2 = X.sign_aug ?watermark:watermark2 sk2 msg2 in + let signed3 = X.sign_aug ?watermark:watermark3 sk3 msg3 in let is_valid_aggregated_sign = X.aggregate_signature_opt [signed1; signed2; signed3] |> function | None -> false @@ -116,9 +120,9 @@ struct ] s in - X.check ?watermark:watermark1 pk1 signed1 msg1 - && X.check ?watermark:watermark2 pk2 signed2 msg2 - && X.check ?watermark:watermark3 pk3 signed3 msg3 + X.check_aug ?watermark:watermark1 pk1 signed1 msg1 + && X.check_aug ?watermark:watermark2 pk2 signed2 msg2 + && X.check_aug ?watermark:watermark3 pk3 signed3 msg3 && is_valid_aggregated_sign let test_prop_sign_check = -- GitLab From 41e42141452ecbca3b0a7b835c5549dbd3f651ca Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Mar 2025 07:44:34 +0100 Subject: [PATCH 4/4] Changes: add entries for the new signature version in env 15 --- CHANGES.rst | 6 ++++++ docs/protocols/alpha.rst | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 00226f0ef4ce..f918b2512ffd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -72,6 +72,12 @@ Proxy Server Protocol Compiler And Environment --------------------------------- +- Environment V15 uses signature V2. This change impacts the way BLS signatures + are handled. In previous environments that used signature V1, the BLS + signatures were expected to be produced with the ``Augmented`` cryptographic + scheme. Starting from V15, they are expected to be produced with the ``Proof + of possession`` cryptographic scheme. (MR :gl:`!17036`) + Codec ----- diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 05ceaee48a6f..d5e7d222b1f7 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -14,6 +14,12 @@ Environment Version This protocol requires an updated protocol environment version (V15) from R version (V14). +- Environment V15 uses signature V2. This change impacts the way BLS signatures + are handled. In previous environments that used signature V1, the BLS + signatures were expected to be produced with the ``Augmented`` cryptographic + scheme. Starting from V15, they are expected to be produced with the ``Proof + of possession`` cryptographic scheme. (MR :gl:`!17036`) + Smart Rollups ------------- -- GitLab