diff --git a/devtools/testnet_experiment_tools/tool_021_PsQuebec.ml b/devtools/testnet_experiment_tools/tool_021_PsQuebec.ml index 0e6d09814dec51a528bb5706a93675af279ac70c..0749e4b5f6f9f2b64b33fe89e3ab1c8543fb17c1 100644 --- a/devtools/testnet_experiment_tools/tool_021_PsQuebec.ml +++ b/devtools/testnet_experiment_tools/tool_021_PsQuebec.ml @@ -163,7 +163,7 @@ let load_client_context (cctxt : ctxt_kind) = in let i = Random.bits () |> Int32.of_int in Bytes.set_int32_be b 0 i ; - let _, _, sk = V_latest.generate_key ~algo ~seed:b () in + let _, _, sk = generate_key ~algo ~seed:b () in sk in let* delegates_l = diff --git a/devtools/testnet_experiment_tools/tool_alpha.ml b/devtools/testnet_experiment_tools/tool_alpha.ml index 55833eaf0edbe46bba646e23ed2cf7da563642ad..3552440fb7aad2c0610a8cc212c105f0db6b9ec7 100644 --- a/devtools/testnet_experiment_tools/tool_alpha.ml +++ b/devtools/testnet_experiment_tools/tool_alpha.ml @@ -162,7 +162,7 @@ let load_client_context (cctxt : ctxt_kind) = in let i = Random.bits () |> Int32.of_int in Bytes.set_int32_be b 0 i ; - let _, _, sk = V_latest.generate_key ~algo ~seed:b () in + let _, _, sk = generate_key ~algo ~seed:b () in sk in let* delegates_l = diff --git a/devtools/testnet_experiment_tools/tool_next.ml b/devtools/testnet_experiment_tools/tool_next.ml index 2bccf621950ac2a6ff8ba23a9d643f547c62cb7b..beeaadefcac0506fdb54ce640d6b785dc506d39b 100644 --- a/devtools/testnet_experiment_tools/tool_next.ml +++ b/devtools/testnet_experiment_tools/tool_next.ml @@ -162,7 +162,7 @@ let load_client_context (cctxt : ctxt_kind) = in let i = Random.bits () |> Int32.of_int in Bytes.set_int32_be b 0 i ; - let _, _, sk = V_latest.generate_key ~algo ~seed:b () in + let _, _, sk = generate_key ~algo ~seed:b () in sk in let* delegates_l = diff --git a/devtools/yes_wallet/get_delegates_021_PsQuebec.ml b/devtools/yes_wallet/get_delegates_021_PsQuebec.ml index 8dc5c3380511bfe3c0ab7d32328851e9fb355732..2126fad986109c244904cae4f5ae71203e7c2a5e 100644 --- a/devtools/yes_wallet/get_delegates_021_PsQuebec.ml +++ b/devtools/yes_wallet/get_delegates_021_PsQuebec.ml @@ -41,8 +41,8 @@ module Get_delegates = struct module Signature = struct include Tezos_crypto.Signature.V1 - module To_latest = Tezos_crypto.Signature.Of_V1 - module Of_latest = Tezos_crypto.Signature.Of_V_latest + module To_latest = Tezos_crypto.Signature.V_latest.Of_V1 + module Of_latest = Tezos_crypto.Signature.V1.Of_V_latest end module Contract = struct diff --git a/devtools/yes_wallet/get_delegates_alpha.ml b/devtools/yes_wallet/get_delegates_alpha.ml index f19a7971ee988e82392503f009c07bb88e350816..e76e68a1b31cc3604dcdab930feabd1a61a615d5 100644 --- a/devtools/yes_wallet/get_delegates_alpha.ml +++ b/devtools/yes_wallet/get_delegates_alpha.ml @@ -41,8 +41,8 @@ module Get_delegates = struct module Signature = struct include Tezos_crypto.Signature.V1 - module To_latest = Tezos_crypto.Signature.Of_V1 - module Of_latest = Tezos_crypto.Signature.Of_V_latest + module To_latest = Tezos_crypto.Signature.V_latest.Of_V1 + module Of_latest = Tezos_crypto.Signature.V1.Of_V_latest end module Contract = struct diff --git a/devtools/yes_wallet/get_delegates_next.ml b/devtools/yes_wallet/get_delegates_next.ml index 99749942cc710748694ad872335ca83a2b7044cd..4fae3bacd1882f3fabce155860960f8cb72114b5 100644 --- a/devtools/yes_wallet/get_delegates_next.ml +++ b/devtools/yes_wallet/get_delegates_next.ml @@ -41,8 +41,8 @@ module Get_delegates = struct module Signature = struct include Tezos_crypto.Signature.V1 - module To_latest = Tezos_crypto.Signature.Of_V1 - module Of_latest = Tezos_crypto.Signature.Of_V_latest + module To_latest = Tezos_crypto.Signature.V_latest.Of_V1 + module Of_latest = Tezos_crypto.Signature.V1.Of_V_latest end module Contract = struct diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index e3bb50774175bc253de718c4beac0c056d44b5a6..c6c2ea7b0cf827f478e222713b68a80480aac716 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -6431,6 +6431,33 @@ let hash = Protocol.hash let {Lib_protocol.main; lifted; embedded} = Lib_protocol.make ~name ~status in + let dune_signatures_version_rule = + Dune.targets_rule + ["signature.ml"] + ~action: + [ + S "write-file"; + S "%{targets}"; + S + (sf + {| module Bls = Tezos_crypto.Signature.Bls + module Ed25519 = Tezos_crypto.Signature.Ed25519 + module P256 = Tezos_crypto.Signature.P256 + module Secp256k1 = Tezos_crypto.Signature.Secp256k1 + include Tezos_crypto.Signature.V1|}); + ] + in + let dune_client_keys_version_rule = + Dune.( + targets_rule + ["client_keys.ml"] + ~action: + [ + S "write-file"; + S "%{targets}"; + S (sf {|include Tezos_client_base.Client_keys_v1|}); + ]) + in let parameters = only_if (N.(number >= 011) && not_overridden) @@ fun () -> public_lib @@ -6444,6 +6471,7 @@ let hash = Protocol.hash main |> open_; ] ~linkall:true + ~dune:(if N.(number >= 016) then [dune_signatures_version_rule] else []) in let _parameters_exe = opt_map parameters @@ fun parameters -> @@ -6521,6 +6549,7 @@ let hash = Protocol.hash ] ~all_modules_except:["Plugin_registerer"] ~bisect_ppx:(if N.(number >= 008) then Yes else No) + ~dune:(if N.(number >= 016) then [dune_signatures_version_rule] else []) in let plugin_registerer = opt_map plugin @@ fun plugin -> @@ -6583,6 +6612,10 @@ let hash = Protocol.hash Some ["-cclib"; "-lblst"; "-cclib"; "-loctez_rustzcash_deps"] else None) ~linkall:true + ~dune: + (if N.(number >= 016) then + [dune_client_keys_version_rule; dune_signatures_version_rule] + else []) in let test_helpers = only_if active @@ fun () -> @@ -6613,6 +6646,7 @@ let hash = Protocol.hash octez_crypto_dal |> if_ N.(number >= 016) |> open_; octez_sc_rollup |> if_some |> if_ N.(number >= 018) |> open_; ] + ~dune:[dune_signatures_version_rule] in let _plugin_tests = opt_map (both plugin test_helpers) @@ fun (plugin, test_helpers) -> @@ -6706,6 +6740,10 @@ let hash = Protocol.hash ~bisect_ppx:(if N.(number >= 008) then Yes else No) ~linkall:true ~all_modules_except:["alpha_commands_registration"] + ~dune: + (if N.(number >= 016) then + [dune_signatures_version_rule; dune_client_keys_version_rule] + else []) in let client_sapling = only_if (N.(number >= 011) && not_overridden) @@ fun () -> @@ -6807,6 +6845,7 @@ let hash = Protocol.hash (if N.(number <= 011) then ["Delegate_commands"; "Delegate_commands_registration"] else ["Baking_commands"; "Baking_commands_registration"]) + ~dune:[dune_signatures_version_rule; dune_client_keys_version_rule] in let tenderbrute = only_if active @@ fun () -> @@ -6826,6 +6865,7 @@ let hash = Protocol.hash client |> if_some |> open_; ] ~bisect_ppx:No + ~dune:[dune_signatures_version_rule] in let _tenderbrute_exe = only_if (active && N.(number >= 013)) @@ fun () -> @@ -6876,6 +6916,7 @@ let hash = Protocol.hash tezt_core_lib |> open_; ] ~bisect_ppx:No + ~dune:[dune_client_keys_version_rule] in tezt ["test_scenario"] @@ -7030,6 +7071,7 @@ let hash = Protocol.hash ~inline_tests_link_flags: ["-cclib"; "-lblst"; "-cclib"; "-loctez_rustzcash_deps"] ~linkall:true + ~dune:[dune_signatures_version_rule] in let _dal_tests = only_if (active && N.(number >= 016)) @@ fun () -> @@ -7068,6 +7110,7 @@ let hash = Protocol.hash plugin |> if_some |> open_; ] ~linkall:true + ~dune:[dune_client_keys_version_rule; dune_signatures_version_rule] in let octez_sc_rollup_layer2 = only_if N.(number >= 016) @@ fun () -> @@ -7147,6 +7190,7 @@ let hash = Protocol.hash octez_version_value; ] ~conflicts:[Conflicts.checkseum] + ~dune:[dune_signatures_version_rule] in let _octez_sc_rollup_node_test = only_if (active && N.(number >= 016)) @@ fun () -> @@ -7232,6 +7276,25 @@ let hash = Protocol.hash ~linkall:true ~private_modules:["kernel"; "rules"; "state_space"] ~bisect_ppx:(if N.(number <= 012) then Yes else No) + ~dune: + [ + Dune.targets_rule + ["crypto_samplers.mli"] + ~action: + [ + S "write-file"; + S "%{targets}"; + S "include module type of Tezos_benchmark.Crypto_samplers.V1"; + ]; + Dune.targets_rule + ["crypto_samplers.ml"] + ~action: + [ + S "write-file"; + S "%{targets}"; + S "include Tezos_benchmark.Crypto_samplers.V1"; + ]; + ] in let _benchmark_tests = opt_map (both benchmark test_helpers) @@ fun (benchmark, test_helpers) -> @@ -7307,6 +7370,7 @@ let hash = Protocol.hash octez_protocol_environment; ] ~linkall:true + ~dune:[dune_signatures_version_rule] in let _ = if active then diff --git a/src/lib_benchmark/crypto_samplers.ml b/src/lib_benchmark/crypto_samplers.ml index 305e41b93ce0e793cb3a027fe1f163c5f9d67d45..d1d209ddb64d47655a3b880b2f67343f315f73fc 100644 --- a/src/lib_benchmark/crypto_samplers.ml +++ b/src/lib_benchmark/crypto_samplers.ml @@ -142,6 +142,17 @@ module V1 = struct Make_p_finite_key_pool (Tezos_crypto.Signature.V1) end +module V2 = struct + module type Finite_key_pool_S = + P_Finite_key_pool_S + with type public_key_hash := Tezos_crypto.Signature.V2.Public_key_hash.t + and type public_key := Tezos_crypto.Signature.V2.Public_key.t + and type secret_key := Tezos_crypto.Signature.V2.Secret_key.t + + module Make_finite_key_pool = + Make_p_finite_key_pool (Tezos_crypto.Signature.V2) +end + module V_latest = struct module type Finite_key_pool_S = P_Finite_key_pool_S diff --git a/src/lib_benchmark/crypto_samplers.mli b/src/lib_benchmark/crypto_samplers.mli index ce0910455f5d1b6c6e7c4d17175beae8650841ef..2fbbf8848cf179ba0a5fa201e58d482765896c7a 100644 --- a/src/lib_benchmark/crypto_samplers.mli +++ b/src/lib_benchmark/crypto_samplers.mli @@ -87,6 +87,19 @@ module V1 : sig Finite_key_pool_S end +module V2 : sig + module type Finite_key_pool_S = + P_Finite_key_pool_S + with type public_key_hash := Tezos_crypto.Signature.V2.Public_key_hash.t + and type public_key := Tezos_crypto.Signature.V2.Public_key.t + and type secret_key := Tezos_crypto.Signature.V2.Secret_key.t + + (** Create a finite key pool. *) + module Make_finite_key_pool + (Arg : Param_S with type algo := Tezos_crypto.Signature.V2.algo) : + Finite_key_pool_S +end + module V_latest : sig module type Finite_key_pool_S = P_Finite_key_pool_S diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index 01b8adea0dd3760dc3c30a15f64bedffdf6fdc59..bb8213e143aa5c2507266b71d973f95218a806bc 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -908,6 +908,41 @@ module V1 = Make (struct let generate_key = generate_key ?algo:None + module Adapter = struct + let public_key_hash : + Tezos_crypto.Signature.Public_key_hash.t -> Public_key_hash.t tzresult = + let open Result_syntax in + function + | Bls k -> return (Bls k : Public_key_hash.t) + | Ed25519 k -> return (Ed25519 k : Public_key_hash.t) + | Secp256k1 k -> return (Secp256k1 k : Public_key_hash.t) + | P256 k -> return (P256 k : Public_key_hash.t) + + let public_key : + Tezos_crypto.Signature.Public_key.t -> Public_key.t tzresult = + let open Result_syntax in + function + | Bls k -> return (Bls k : Public_key.t) + | Ed25519 k -> return (Ed25519 k : Public_key.t) + | Secp256k1 k -> return (Secp256k1 k : Public_key.t) + | P256 k -> return (P256 k : Public_key.t) + + let signature : Tezos_crypto.Signature.t -> t tzresult = + let open Result_syntax in + function + | Bls k -> return (Bls k : t) + | Ed25519 k -> return (Ed25519 k : t) + | Secp256k1 k -> return (Secp256k1 k : t) + | P256 k -> return (P256 k : t) + | Unknown k -> return (Unknown k : t) + end +end) + +module V2 = Make (struct + include Tezos_crypto.Signature.V2 + + let generate_key = generate_key ?algo:None + module Adapter = struct let identity x = Ok x diff --git a/src/lib_client_base/client_keys.mli b/src/lib_client_base/client_keys.mli index f16b65f46308310210a4152bef07cfdb42bc7af1..cf9cdb76bb80c9a9e1332cf7dd82911d80a02d3d 100644 --- a/src/lib_client_base/client_keys.mli +++ b/src/lib_client_base/client_keys.mli @@ -288,6 +288,14 @@ module V1 : and type watermark := Tezos_crypto.Signature.V1.watermark and type signature := Tezos_crypto.Signature.V1.t +module V2 : + S + with type public_key_hash := Tezos_crypto.Signature.V2.Public_key_hash.t + and type public_key := Tezos_crypto.Signature.V2.Public_key.t + and type secret_key := Tezos_crypto.Signature.V2.Secret_key.t + and type watermark := Tezos_crypto.Signature.V2.watermark + and type signature := Tezos_crypto.Signature.V2.t + module V_latest : S with type public_key_hash := diff --git a/src/lib_client_base/client_keys_v2.ml b/src/lib_client_base/client_keys_v2.ml new file mode 100644 index 0000000000000000000000000000000000000000..7b1c872c50eb7dbfc361573112834c33a366ca8b --- /dev/null +++ b/src/lib_client_base/client_keys_v2.ml @@ -0,0 +1,11 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* SPDX-FileCopyrightText: 2025 Nomadic Labs *) +(* *) +(*****************************************************************************) + +(** Module to use keys over {!Tezos_crypto.Signature.V2} *) + +include Client_keys +include Client_keys.V2 diff --git a/src/lib_crypto/signature.ml b/src/lib_crypto/signature.ml index 03b05a8c4663c08cf7d59ed6dd78d6a92541d93c..ccac7d958a2648fc0fe7f8c859d0c706804e4f73 100644 --- a/src/lib_crypto/signature.ml +++ b/src/lib_crypto/signature.ml @@ -52,9 +52,24 @@ module type CONV_OPT = sig val secret_key : V_from.Secret_key.t -> V_to.Secret_key.t option val signature : V_from.t -> V_to.t option + + val get_public_key : + V_from.Public_key.t -> V_to.Public_key.t Error_monad.tzresult + + val get_public_key_exn : V_from.Public_key.t -> V_to.Public_key.t + + val get_public_key_hash : + V_from.Public_key_hash.t -> V_to.Public_key_hash.t Error_monad.tzresult + + val get_public_key_hash_exn : + V_from.Public_key_hash.t -> V_to.Public_key_hash.t + + val get_signature : V_from.t -> V_to.t Error_monad.tzresult + + val get_signature_exn : V_from.t -> V_to.t end -module V_latest = Signature_v1 +module V_latest = Signature_v2 module V0 = struct include Signature_v0 @@ -87,6 +102,54 @@ module V0 = struct | V_latest.P256 k -> Some (P256 k) | V_latest.Unknown k -> Some (Unknown k) | V_latest.Bls _ -> None + + let get_public_key pk = + match public_key pk with + | Some pk -> Ok pk + | None -> + Error_monad.error_with + "Conversion of public key from latest signature version to V0 \ + impossible." + + let get_public_key_exn pk = + match public_key pk with + | Some pk -> pk + | None -> + Stdlib.failwith + "Conversion of public key hash from latest signature version to V0 \ + impossible." + + let get_public_key_hash pkh = + match public_key_hash pkh with + | Some pkh -> Ok pkh + | None -> + Error_monad.error_with + "Conversion of public key hash from latest signature version to V0 \ + impossible." + + let get_public_key_hash_exn pkh = + match public_key_hash pkh with + | Some pkh -> pkh + | None -> + Stdlib.failwith + "Conversion of public key hash from latest signature version to V0 \ + impossible." + + let get_signature s = + match signature s with + | Some s -> Ok s + | None -> + Error_monad.error_with + "Conversion of signature from latest signature version to V0 \ + impossible." + + let get_signature_exn s = + match signature s with + | Some s -> s + | None -> + Stdlib.failwith + "Conversion of signature from latest signature version to V0 \ + impossible." end end @@ -95,6 +158,88 @@ module V1 = struct module Of_V_latest : CONV_OPT with module V_from := V_latest and module V_to := Signature_v1 = + struct + let public_key_hash : V_latest.Public_key_hash.t -> Public_key_hash.t option + = function + | V_latest.Ed25519 k -> Some (Ed25519 k) + | V_latest.Secp256k1 k -> Some (Secp256k1 k) + | V_latest.P256 k -> Some (P256 k) + | V_latest.Bls k -> Some (Bls k) + + let public_key : V_latest.Public_key.t -> Public_key.t option = function + | V_latest.Ed25519 k -> Some (Ed25519 k) + | V_latest.Secp256k1 k -> Some (Secp256k1 k) + | V_latest.P256 k -> Some (P256 k) + | V_latest.Bls k -> Some (Bls k) + + let secret_key : V_latest.Secret_key.t -> Secret_key.t option = function + | V_latest.Ed25519 k -> Some (Ed25519 k) + | V_latest.Secp256k1 k -> Some (Secp256k1 k) + | V_latest.P256 k -> Some (P256 k) + | V_latest.Bls k -> Some (Bls k) + + let signature : V_latest.t -> t option = function + | V_latest.Ed25519 k -> Some (Ed25519 k) + | V_latest.Secp256k1 k -> Some (Secp256k1 k) + | V_latest.P256 k -> Some (P256 k) + | V_latest.Unknown k -> Some (Unknown k) + | V_latest.Bls k -> Some (Bls k) + + let get_public_key pk = + match public_key pk with + | Some pk -> Ok pk + | None -> + Error_monad.error_with + "Conversion of public key from latest signature version to V1 \ + impossible." + + let get_public_key_exn pk = + match public_key pk with + | Some pk -> pk + | None -> + Stdlib.failwith + "Conversion of public key hash from latest signature version to V1 \ + impossible." + + let get_public_key_hash pkh = + match public_key_hash pkh with + | Some pkh -> Ok pkh + | None -> + Error_monad.error_with + "Conversion of public key hash from latest signature version to V1 \ + impossible." + + let get_public_key_hash_exn pkh = + match public_key_hash pkh with + | Some pkh -> pkh + | None -> + Stdlib.failwith + "Conversion of public key hash from latest signature version to V1 \ + impossible." + + let get_signature s = + match signature s with + | Some s -> Ok s + | None -> + Error_monad.error_with + "Conversion of signature from latest signature version to V1 \ + impossible." + + let get_signature_exn s = + match signature s with + | Some s -> s + | None -> + Stdlib.failwith + "Conversion of signature from latest signature version to V1 \ + impossible." + end +end + +module V2 = struct + include Signature_v2 + + module Of_V_latest : + CONV_OPT with module V_from := V_latest and module V_to := Signature_v2 = struct let public_key_hash = Option.some @@ -103,13 +248,61 @@ module V1 = struct let secret_key = Option.some let signature = Option.some + + let get_public_key pk = + match public_key pk with + | Some pk -> Ok pk + | None -> + Error_monad.error_with + "Conversion of public key from latest signature version to V2 \ + impossible." + + let get_public_key_exn pk = + match public_key pk with + | Some pk -> pk + | None -> + Stdlib.failwith + "Conversion of public key hash from latest signature version to V2 \ + impossible." + + let get_public_key_hash pkh = + match public_key_hash pkh with + | Some pkh -> Ok pkh + | None -> + Error_monad.error_with + "Conversion of public key hash from latest signature version to V2 \ + impossible." + + let get_public_key_hash_exn pkh = + match public_key_hash pkh with + | Some pkh -> pkh + | None -> + Stdlib.failwith + "Conversion of public key hash from latest signature version to V2 \ + impossible." + + let get_signature s = + match signature s with + | Some s -> Ok s + | None -> + Error_monad.error_with + "Conversion of signature from latest signature version to V2 \ + impossible." + + let get_signature_exn s = + match signature s with + | Some s -> s + | None -> + Stdlib.failwith + "Conversion of signature from latest signature version to V2 \ + impossible." end end include V_latest -module Of_V_latest = V1.Of_V_latest +module Of_V_latest = V2.Of_V_latest -module Of_V1 : CONV with module V_from := V1 and module V_to := V1 = struct +module Of_V2 : CONV with module V_from := V2 and module V_to := V2 = struct let public_key_hash = Fun.id let public_key = Fun.id diff --git a/src/lib_crypto/signature.mli b/src/lib_crypto/signature.mli index 01a26a7546c25e5a03f2f9116cdf087077a7b49a..e7faf48a6f95dfa874e02c78dd61a7ff9802359c 100644 --- a/src/lib_crypto/signature.mli +++ b/src/lib_crypto/signature.mli @@ -57,11 +57,26 @@ module type CONV_OPT = sig val secret_key : V_from.Secret_key.t -> V_to.Secret_key.t option val signature : V_from.t -> V_to.t option + + val get_public_key : + V_from.Public_key.t -> V_to.Public_key.t Error_monad.tzresult + + val get_public_key_exn : V_from.Public_key.t -> V_to.Public_key.t + + val get_public_key_hash : + V_from.Public_key_hash.t -> V_to.Public_key_hash.t Error_monad.tzresult + + val get_public_key_hash_exn : + V_from.Public_key_hash.t -> V_to.Public_key_hash.t + + val get_signature : V_from.t -> V_to.t Error_monad.tzresult + + val get_signature_exn : V_from.t -> V_to.t end (** The module [V_latest] is to be used by the shell and points to the latest available version of signatures. *) -module V_latest : module type of Signature_v1 +module V_latest : module type of Signature_v2 (** [V0] supports Ed25519, Secp256k1, and P256. *) module V0 : sig @@ -72,7 +87,7 @@ module V0 : sig CONV_OPT with module V_from := V_latest and module V_to := Signature_v0 end -(** [V1] supports Ed25519, Secp256k1, P256, and BLS. *) +(** [V1] supports Ed25519, Secp256k1, P256, and BLS (aug). *) module V1 : sig include module type of Signature_v1 @@ -81,12 +96,21 @@ module V1 : sig CONV_OPT with module V_from := V_latest and module V_to := Signature_v1 end +(** [V2] supports Ed25519, Secp256k1, P256, and BLS (aug). *) +module V2 : sig + include module type of Signature_v2 + + (** Converting from signatures of {!V_latest} to {!V2}. *) + module Of_V_latest : + CONV_OPT with module V_from := V_latest and module V_to := Signature_v2 +end + include module type of V_latest (** Converting from signatures of {!V_latest} to {!V_latest}. This module implements conversions which are the identity, so total, but we keep the signature as {!CONV_OPT} for compatibility with {!V0.Of_V_latest} and - {!V1.Of_V_latest} and to ease snapshotting. *) + {!V1.Of_V_latest} and to ease snapshotting. TODO ADAPT THIS WITH V2*) module Of_V_latest : CONV_OPT with module V_from := V_latest and module V_to := V_latest @@ -95,3 +119,6 @@ module Of_V0 : CONV with module V_from := V0 and module V_to := V_latest (** Converting from signatures of {!V1} to {!V_latest}. *) module Of_V1 : CONV with module V_from := V1 and module V_to := V_latest + +(** Converting from signatures of {!V2} to {!V_latest}. *) +module Of_V2 : CONV with module V_from := V2 and module V_to := V_latest diff --git a/src/lib_crypto/signature_v2.ml b/src/lib_crypto/signature_v2.ml new file mode 100644 index 0000000000000000000000000000000000000000..4375503a33329c782fc4c797638fb3873a737ee4 --- /dev/null +++ b/src/lib_crypto/signature_v2.ml @@ -0,0 +1,1043 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* SPDX-FileCopyrightText: 2025 Nomadic Labs *) +(* *) +(*****************************************************************************) + +open Error_monad + +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 + +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 + +type secret_key = + | Ed25519 of Ed25519.Secret_key.t + | Secp256k1 of Secp256k1.Secret_key.t + | P256 of P256.Secret_key.t + | Bls of Bls.Secret_key.t + +type watermark = Signature_v0.watermark = + | Block_header of Chain_id.t + | Endorsement of Chain_id.t + | Generic_operation + | Custom of Bytes.t + +module Public_key_hash = struct + type t = 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 + + let name = "Signature.Public_key_hash" + + let title = "A Ed25519, Secp256k1, P256, or BLS public key hash" + + type Base58.data += Data of t (* unused *) + + let b58check_encoding = + (* unused *) + Base58.register_encoding + ~prefix:"\255\255" + ~length:2 + ~to_raw:(fun _ -> assert false) + ~of_raw:(fun _ -> assert false) + ~wrap:(fun x -> Data x) + + let raw_encoding = + let open Data_encoding in + def "public_key_hash" ~description:title + @@ union + [ + case + (Tag 0) + Ed25519.Public_key_hash.encoding + ~title:"Ed25519" + (function Ed25519 x -> Some x | _ -> None) + (function x -> Ed25519 x); + case + (Tag 1) + Secp256k1.Public_key_hash.encoding + ~title:"Secp256k1" + (function Secp256k1 x -> Some x | _ -> None) + (function x -> Secp256k1 x); + case + (Tag 2) + ~title:"P256" + P256.Public_key_hash.encoding + (function P256 x -> Some x | _ -> None) + (function x -> P256 x); + case + (Tag 3) + ~title:"Bls" + Bls.Public_key_hash.encoding + (function Bls x -> Some x | _ -> None) + (function x -> Bls x); + ] + + let to_bytes s = Data_encoding.Binary.to_bytes_exn raw_encoding s + + let of_bytes_opt s = Data_encoding.Binary.of_bytes_opt raw_encoding s + + let to_string s = Bytes.to_string (to_bytes s) + + let of_string_opt s = of_bytes_opt (Bytes.of_string s) + + let size = 1 + Ed25519.size + + let zero = Ed25519 Ed25519.Public_key_hash.zero + + include Helpers.MakeRaw (struct + type nonrec t = t + + let name = name + + let of_bytes_opt = of_bytes_opt + + let of_string_opt = of_string_opt + + let to_string = to_string + end) + + let of_b58check_opt s = + match Base58.decode s with + | Some (Ed25519.Public_key_hash.Data pkh) -> Some (Ed25519 pkh) + | Some (Secp256k1.Public_key_hash.Data pkh) -> Some (Secp256k1 pkh) + | Some (P256.Public_key_hash.Data pkh) -> Some (P256 pkh) + | Some (Bls.Public_key_hash.Data pkh) -> Some (Bls pkh) + | _ -> None + + let of_b58check_exn s = + match of_b58check_opt s with + | Some x -> x + | None -> Format.kasprintf Stdlib.failwith "Unexpected data (%s)" name + + let of_b58check s = + match of_b58check_opt s with + | Some x -> Ok x + | None -> + error_with "Failed to read a b58check_encoding data (%s): %S" name s + + let to_b58check = function + | Ed25519 pkh -> Ed25519.Public_key_hash.to_b58check pkh + | Secp256k1 pkh -> Secp256k1.Public_key_hash.to_b58check pkh + | P256 pkh -> P256.Public_key_hash.to_b58check pkh + | Bls pkh -> Bls.Public_key_hash.to_b58check pkh + + let to_short_b58check = function + | Ed25519 pkh -> Ed25519.Public_key_hash.to_short_b58check pkh + | Secp256k1 pkh -> Secp256k1.Public_key_hash.to_short_b58check pkh + | P256 pkh -> P256.Public_key_hash.to_short_b58check pkh + | Bls pkh -> Bls.Public_key_hash.to_short_b58check pkh + + let to_path key l = + match key with + | Ed25519 h -> "ed25519" :: Ed25519.Public_key_hash.to_path h l + | Secp256k1 h -> "secp256k1" :: Secp256k1.Public_key_hash.to_path h l + | P256 h -> "p256" :: P256.Public_key_hash.to_path h l + | Bls h -> "bls" :: Bls.Public_key_hash.to_path h l + + let of_path = function + | "ed25519" :: q -> ( + match Ed25519.Public_key_hash.of_path q with + | Some pkh -> Some (Ed25519 pkh) + | None -> None) + | "secp256k1" :: q -> ( + match Secp256k1.Public_key_hash.of_path q with + | Some pkh -> Some (Secp256k1 pkh) + | None -> None) + | "p256" :: q -> ( + match P256.Public_key_hash.of_path q with + | Some pkh -> Some (P256 pkh) + | None -> None) + | "bls" :: q -> ( + match Bls.Public_key_hash.of_path q with + | Some pkh -> Some (Bls pkh) + | None -> None) + | _ -> assert false + + (* FIXME classification des erreurs *) + + let of_path_exn = function + | "ed25519" :: q -> Ed25519 (Ed25519.Public_key_hash.of_path_exn q) + | "secp256k1" :: q -> Secp256k1 (Secp256k1.Public_key_hash.of_path_exn q) + | "p256" :: q -> P256 (P256.Public_key_hash.of_path_exn q) + | "bls" :: q -> Bls (Bls.Public_key_hash.of_path_exn q) + | _ -> assert false + + (* FIXME classification des erreurs *) + + let path_length = + let l1 = Ed25519.Public_key_hash.path_length + and l2 = Secp256k1.Public_key_hash.path_length + and l3 = P256.Public_key_hash.path_length + and l4 = Bls.Public_key_hash.path_length in + assert (Compare.Int.(l1 = l2)) ; + assert (Compare.Int.(l1 = l3)) ; + assert (Compare.Int.(l1 = l4)) ; + 1 + l1 + + let prefix_path _ = assert false (* unused *) + + let seeded_hash = Stdlib.Hashtbl.seeded_hash + + let hash = Stdlib.Hashtbl.hash + + include Compare.Make (struct + type nonrec t = t + + let compare a b = + match (a, b) with + | Ed25519 x, Ed25519 y -> Ed25519.Public_key_hash.compare x y + | Secp256k1 x, Secp256k1 y -> Secp256k1.Public_key_hash.compare x y + | P256 x, P256 y -> P256.Public_key_hash.compare x y + | Bls x, Bls y -> Bls.Public_key_hash.compare x y + | _ -> Stdlib.compare a b + end) + + include Helpers.MakeEncoder (struct + type nonrec t = t + + let name = name + + let title = title + + let raw_encoding = raw_encoding + + let of_b58check = of_b58check + + let of_b58check_opt = of_b58check_opt + + let of_b58check_exn = of_b58check_exn + + let to_b58check = to_b58check + + let to_short_b58check = to_short_b58check + end) + + include Helpers.MakeIterator (struct + type nonrec t = t + + let hash = hash + + let seeded_hash = seeded_hash + + let compare = compare + + let equal = equal + + let encoding = encoding + end) + + let rpc_arg = + Tezos_rpc.Arg.like + rpc_arg + ~descr:"A Secp256k1 of a Ed25519 public key hash (Base58Check-encoded)" + "pkh" + + module Logging = struct + let tag = Tag.def ~doc:title name pp + end +end + +module Public_key = struct + type t = 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 + + let name = "Signature.Public_key" + + let title = "A Ed25519, Secp256k1, or P256 public key" + + let hash pk = + match pk with + | Ed25519 pk -> Public_key_hash.Ed25519 (Ed25519.Public_key.hash pk) + | Secp256k1 pk -> Public_key_hash.Secp256k1 (Secp256k1.Public_key.hash pk) + | P256 pk -> Public_key_hash.P256 (P256.Public_key.hash pk) + | Bls pk -> Public_key_hash.Bls (Bls.Public_key.hash pk) + + include Compare.Make (struct + type nonrec t = t + + let compare a b = + match (a, b) with + | Ed25519 x, Ed25519 y -> Ed25519.Public_key.compare x y + | Secp256k1 x, Secp256k1 y -> Secp256k1.Public_key.compare x y + | P256 x, P256 y -> P256.Public_key.compare x y + | Bls x, Bls y -> Bls.Public_key.compare x y + | Ed25519 _, (Secp256k1 _ | P256 _ | Bls _) -> -1 + | Secp256k1 _, (P256 _ | Bls _) -> -1 + | P256 _, Bls _ -> -1 + | Bls _, (P256 _ | Secp256k1 _ | Ed25519 _) -> 1 + | P256 _, (Secp256k1 _ | Ed25519 _) -> 1 + | Secp256k1 _, Ed25519 _ -> 1 + end) + + type Base58.data += Data of t (* unused *) + + let b58check_encoding = + (* unused *) + Base58.register_encoding + ~prefix:"\255\255" + ~length:2 + ~to_raw:(fun _ -> assert false) + ~of_raw:(fun _ -> assert false) + ~wrap:(fun x -> Data x) + + let of_b58check_opt s = + match Base58.decode s with + | Some (Ed25519.Public_key.Data public_key) -> Some (Ed25519 public_key) + | Some (Secp256k1.Public_key.Data public_key) -> Some (Secp256k1 public_key) + | Some (P256.Public_key.Data public_key) -> Some (P256 public_key) + | Some (Bls.Public_key.Data public_key) -> Some (Bls public_key) + | _ -> None + + let of_b58check_exn s = + match of_b58check_opt s with + | Some x -> x + | None -> Format.kasprintf Stdlib.failwith "Unexpected data (%s)" name + + let of_b58check s = + match of_b58check_opt s with + | Some x -> Ok x + | None -> + error_with "Failed to read a b58check_encoding data (%s): %S" name s + + let to_b58check = function + | Ed25519 pk -> Ed25519.Public_key.to_b58check pk + | Secp256k1 pk -> Secp256k1.Public_key.to_b58check pk + | P256 pk -> P256.Public_key.to_b58check pk + | Bls pk -> Bls.Public_key.to_b58check pk + + let to_short_b58check = function + | Ed25519 pk -> Ed25519.Public_key.to_short_b58check pk + | Secp256k1 pk -> Secp256k1.Public_key.to_short_b58check pk + | P256 pk -> P256.Public_key.to_short_b58check pk + | Bls pk -> Bls.Public_key.to_short_b58check pk + + let of_bytes_without_validation b = + let tag = Bytes.(get_int8 b 0) in + let b = Bytes.(sub b 1 (length b - 1)) in + match tag with + | 0 -> + Option.bind + (Ed25519.Public_key.of_bytes_without_validation b) + (fun pk -> Some (Ed25519 pk)) + | 1 -> + Option.bind + (Secp256k1.Public_key.of_bytes_without_validation b) + (fun pk -> Some (Secp256k1 pk)) + | 2 -> + Option.bind (P256.Public_key.of_bytes_without_validation b) (fun pk -> + Some (P256 pk)) + | 3 -> + Option.bind (Bls.Public_key.of_bytes_without_validation b) (fun pk -> + Some (Bls pk)) + | _ -> None + + include Helpers.MakeEncoder (struct + type nonrec t = t + + let name = name + + let title = title + + let raw_encoding = + let open Data_encoding in + def "public_key" ~description:title + @@ union + [ + case + (Tag 0) + Ed25519.Public_key.encoding + ~title:"Ed25519" + (function Ed25519 x -> Some x | _ -> None) + (function x -> Ed25519 x); + case + (Tag 1) + Secp256k1.Public_key.encoding + ~title:"Secp256k1" + (function Secp256k1 x -> Some x | _ -> None) + (function x -> Secp256k1 x); + case + ~title:"P256" + (Tag 2) + P256.Public_key.encoding + (function P256 x -> Some x | _ -> None) + (function x -> P256 x); + case + ~title:"Bls" + (Tag 3) + Bls.Public_key.encoding + (function Bls x -> Some x | _ -> None) + (function x -> Bls x); + ] + + let of_b58check = of_b58check + + let of_b58check_opt = of_b58check_opt + + let of_b58check_exn = of_b58check_exn + + let to_b58check = to_b58check + + let to_short_b58check = to_short_b58check + end) + + let size pk = Data_encoding.Binary.length encoding pk + + let pp ppf t = Format.fprintf ppf "%s" (to_b58check t) +end + +module Secret_key = struct + type t = secret_key = + | Ed25519 of Ed25519.Secret_key.t + | Secp256k1 of Secp256k1.Secret_key.t + | P256 of P256.Secret_key.t + | Bls of Bls.Secret_key.t + + let name = "Signature.Secret_key" + + let title = "A Ed25519, Secp256k1 or P256 secret key" + + let to_public_key = function + | Ed25519 sk -> Public_key.Ed25519 (Ed25519.Secret_key.to_public_key sk) + | Secp256k1 sk -> + Public_key.Secp256k1 (Secp256k1.Secret_key.to_public_key sk) + | P256 sk -> Public_key.P256 (P256.Secret_key.to_public_key sk) + | Bls sk -> Public_key.Bls (Bls.Secret_key.to_public_key sk) + + include Compare.Make (struct + type nonrec t = t + + let compare a b = + match (a, b) with + | Ed25519 x, Ed25519 y -> Ed25519.Secret_key.compare x y + | Secp256k1 x, Secp256k1 y -> Secp256k1.Secret_key.compare x y + | P256 x, P256 y -> P256.Secret_key.compare x y + | Bls x, Bls y -> Bls.Secret_key.compare x y + | _ -> Stdlib.compare a b + end) + + type Base58.data += Data of t (* unused *) + + let b58check_encoding = + (* unused *) + Base58.register_encoding + ~prefix:"\255\255" + ~length:2 + ~to_raw:(fun _ -> assert false) + ~of_raw:(fun _ -> assert false) + ~wrap:(fun x -> Data x) + + let of_b58check_opt b = + match Base58.decode b with + | Some (Ed25519.Secret_key.Data sk) -> Some (Ed25519 sk) + | Some (Secp256k1.Secret_key.Data sk) -> Some (Secp256k1 sk) + | Some (P256.Secret_key.Data sk) -> Some (P256 sk) + | Some (Bls.Secret_key.Data sk) -> Some (Bls sk) + | _ -> None + + let of_b58check_exn s = + match of_b58check_opt s with + | Some x -> x + | None -> Format.kasprintf Stdlib.failwith "Unexpected data (%s)" name + + let of_b58check s = + match of_b58check_opt s with + | Some x -> Ok x + | None -> + error_with "Failed to read a b58check_encoding data (%s): %S" name s + + let to_b58check = function + | Ed25519 sk -> Ed25519.Secret_key.to_b58check sk + | Secp256k1 sk -> Secp256k1.Secret_key.to_b58check sk + | P256 sk -> P256.Secret_key.to_b58check sk + | Bls sk -> Bls.Secret_key.to_b58check sk + + let to_short_b58check = function + | Ed25519 sk -> Ed25519.Secret_key.to_short_b58check sk + | Secp256k1 sk -> Secp256k1.Secret_key.to_short_b58check sk + | P256 sk -> P256.Secret_key.to_short_b58check sk + | Bls sk -> Bls.Secret_key.to_short_b58check sk + + include Helpers.MakeEncoder (struct + type nonrec t = t + + let name = name + + let title = title + + let raw_encoding = + let open Data_encoding in + def "secret_key" ~description:title + @@ union + [ + case + (Tag 0) + Ed25519.Secret_key.encoding + ~title:"Ed25519" + (function Ed25519 x -> Some x | _ -> None) + (function x -> Ed25519 x); + case + (Tag 1) + Secp256k1.Secret_key.encoding + ~title:"Secp256k1" + (function Secp256k1 x -> Some x | _ -> None) + (function x -> Secp256k1 x); + case + (Tag 2) + ~title:"P256" + P256.Secret_key.encoding + (function P256 x -> Some x | _ -> None) + (function x -> P256 x); + case + (Tag 3) + ~title:"Bls" + Bls.Secret_key.encoding + (function Bls x -> Some x | _ -> None) + (function x -> Bls x); + ] + + let of_b58check = of_b58check + + let of_b58check_opt = of_b58check_opt + + let of_b58check_exn = of_b58check_exn + + let to_b58check = to_b58check + + let to_short_b58check = to_short_b58check + end) + + let pp ppf t = Format.fprintf ppf "%s" (to_b58check t) +end + +type signature = + | Ed25519 of Ed25519.t + | Secp256k1 of Secp256k1.t + | P256 of P256.t + | Bls of Bls.t + | Unknown of Bytes.t + +type prefix = Bls_prefix of Bytes.t + +type splitted = {prefix : prefix option; suffix : Bytes.t} + +type t = signature + +let name = "Signature.V1" + +let title = "A Ed25519, Secp256k1, P256 or BLS signature" + +let to_bytes = function + | Ed25519 b -> Ed25519.to_bytes b + | Secp256k1 b -> Secp256k1.to_bytes b + | P256 b -> P256.to_bytes b + | Bls b -> Bls.to_bytes b + | Unknown b -> b + +let of_bytes_opt s = + let len = Bytes.length s in + if len = Bls.size then Option.map (fun b -> Bls b) (Bls.of_bytes_opt s) + else if len = Ed25519.size then Some (Unknown s) + else None + +let () = + assert (Ed25519.size = 64) ; + assert (Secp256k1.size = 64) ; + assert (P256.size = 64) ; + assert (Bls.size = 96) + +type Base58.data += Data_unknown of Bytes.t + +let unknown_b58check_encoding = + Base58.register_encoding + ~prefix:Base58.Prefix.generic_signature + ~length:Ed25519.size + ~to_raw:Bytes.to_string + ~of_raw:(fun s -> Some (Bytes.of_string s)) + ~wrap:(fun x -> Data_unknown x) + +let () = Base58.check_encoded_prefix unknown_b58check_encoding "sig" 96 + +type Base58.data += Data of t (* unused *) + +let b58check_encoding = + (* unused *) + Base58.register_encoding + ~prefix:"\255\255" + ~length:2 + ~to_raw:(fun _ -> assert false) + ~of_raw:(fun _ -> assert false) + ~wrap:(fun x -> Data x) + +include Compare.Make (struct + type nonrec t = t + + let compare a b = + let a = to_bytes a and b = to_bytes b in + Bytes.compare a b +end) + +let of_b58check_opt s = + if TzString.has_prefix ~prefix:Ed25519.b58check_encoding.encoded_prefix s then + Option.map (fun x -> Ed25519 x) (Ed25519.of_b58check_opt s) + else if + TzString.has_prefix ~prefix:Secp256k1.b58check_encoding.encoded_prefix s + then Option.map (fun x -> Secp256k1 x) (Secp256k1.of_b58check_opt s) + else if TzString.has_prefix ~prefix:P256.b58check_encoding.encoded_prefix s + then Option.map (fun x -> P256 x) (P256.of_b58check_opt s) + else if TzString.has_prefix ~prefix:Bls.b58check_encoding.encoded_prefix s + then Option.map (fun x -> Bls x) (Bls.of_b58check_opt s) + else + Option.map + (fun x -> Unknown x) + (Base58.simple_decode unknown_b58check_encoding s) + +let of_b58check_exn s = + match of_b58check_opt s with + | Some x -> x + | None -> Format.kasprintf Stdlib.failwith "Unexpected data (%s)" name + +let of_b58check s = + match of_b58check_opt s with + | Some x -> Ok x + | None -> error_with "Failed to read a b58check_encoding data (%s): %S" name s + +let to_b58check = function + | Ed25519 b -> Ed25519.to_b58check b + | Secp256k1 b -> Secp256k1.to_b58check b + | P256 b -> P256.to_b58check b + | Bls b -> Bls.to_b58check b + | Unknown b -> Base58.simple_encode unknown_b58check_encoding b + +let to_short_b58check = function + | Ed25519 b -> Ed25519.to_short_b58check b + | Secp256k1 b -> Secp256k1.to_short_b58check b + | P256 b -> P256.to_short_b58check b + | Bls b -> Bls.to_short_b58check b + | Unknown b -> Base58.simple_encode unknown_b58check_encoding b + +let raw_encoding = + conv + to_bytes + (fun b -> + match of_bytes_opt b with + | None -> + Format.kasprintf + Stdlib.failwith + "Not a valid signature: %a" + Hex.pp + (Hex.of_bytes b) + | Some s -> s) + Variable.bytes + +include Helpers.MakeEncoder (struct + type nonrec t = t + + let name = name + + let title = title + + let raw_encoding = raw_encoding + + let of_b58check = of_b58check + + let of_b58check_opt = of_b58check_opt + + let of_b58check_exn = of_b58check_exn + + let to_b58check = to_b58check + + let to_short_b58check = to_short_b58check +end) + +let to_bytes s = Data_encoding.Binary.to_bytes_exn raw_encoding s + +let of_bytes_opt s = Data_encoding.Binary.of_bytes_opt raw_encoding s + +let to_string s = Bytes.to_string (to_bytes s) + +let of_string_opt s = of_bytes_opt (Bytes.of_string s) + +include Helpers.MakeRaw (struct + type nonrec t = t + + let name = name + + let of_bytes_opt = of_bytes_opt + + let of_string_opt = of_string_opt + + let to_string = to_string +end) + +let size t = Data_encoding.Binary.length encoding t + +let pp ppf t = Format.fprintf ppf "%s" (to_b58check t) + +let of_ed25519 s = Ed25519 s + +let of_secp256k1 s = Secp256k1 s + +let of_p256 s = P256 s + +let of_bls s = Bls s + +let zero = of_ed25519 Ed25519.zero + +(* NOTE: At the moment, only BLS signatures can be encoded with a tag. We impose + this restriction so that there is only one valid binary representation for a + same signature (modulo malleability). + + We reserve the tags 0, 1, 2 and 255 for tags of the other signatures if we + decide to unify signature representation one day.*) +let prefix_encoding = + let open Data_encoding in + def + "bls_signature_prefix" + ~description:"The prefix of a BLS signature, i.e. the first 32 bytes." + @@ union + [ + case + (Tag 3) + ~title:"Bls_prefix" + (Fixed.bytes (Bls.size - Ed25519.size)) + (function Bls_prefix x -> Some x) + (function x -> Bls_prefix x); + ] + +let split_signature = function + | (Ed25519 _ | Secp256k1 _ | P256 _) as s -> + {prefix = None; suffix = to_bytes s} + | Bls s -> + let s = Bls.to_bytes s in + let prefix = Bytes.sub s 0 32 in + let suffix = Bytes.sub s 32 64 in + {prefix = Some (Bls_prefix prefix); suffix} + | Unknown s -> + assert (Compare.Int.(Bytes.length s = 64)) ; + {prefix = None; suffix = s} + +let of_splitted {prefix; suffix} = + let open Option_syntax in + match prefix with + | None -> of_bytes_opt suffix + | Some (Bls_prefix prefix) -> + let+ s = Bls.of_bytes_opt (Bytes.cat prefix suffix) in + Bls s + +let bytes_of_watermark = function + | Block_header chain_id -> + Bytes.cat (Bytes.of_string "\x01") (Chain_id.to_bytes chain_id) + | Endorsement chain_id -> + Bytes.cat (Bytes.of_string "\x02") (Chain_id.to_bytes chain_id) + | Generic_operation -> Bytes.of_string "\x03" + | Custom bytes -> bytes + +let pp_watermark ppf = + let open Format in + function + | Block_header chain_id -> fprintf ppf "Block-header: %a" Chain_id.pp chain_id + | Endorsement chain_id -> fprintf ppf "Endorsement: %a" Chain_id.pp chain_id + | Generic_operation -> pp_print_string ppf "Generic-operation" + | Custom bytes -> + let hexed = Hex.of_bytes bytes |> Hex.show in + fprintf + ppf + "Custom: 0x%s" + (try String.sub hexed 0 10 ^ "..." with Invalid_argument _ -> hexed) + +let sign ?watermark secret_key message = + let watermark = Option.map bytes_of_watermark watermark in + match secret_key with + | 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) + +let check ?watermark public_key signature message = + let watermark = Option.map bytes_of_watermark watermark in + match (public_key, signature) with + | Public_key.Ed25519 pk, Unknown signature -> ( + match Ed25519.of_bytes_opt signature with + | Some s -> Ed25519.check ?watermark pk s message + | None -> false) + | Public_key.Secp256k1 pk, Unknown signature -> ( + match Secp256k1.of_bytes_opt signature with + | Some s -> Secp256k1.check ?watermark pk s message + | None -> false) + | Public_key.P256 pk, Unknown signature -> ( + match P256.of_bytes_opt signature with + | Some s -> P256.check ?watermark pk s message + | None -> false) + | Public_key.Bls pk, Unknown signature -> ( + match Bls.of_bytes_opt signature with + | Some s -> Bls.check ?watermark pk s message + | None -> false) + | Public_key.Ed25519 pk, Ed25519 signature -> + Ed25519.check ?watermark pk signature message + | Public_key.Secp256k1 pk, Secp256k1 signature -> + Secp256k1.check ?watermark pk 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 + | _ -> false + +let fake_sign_from_pk pk msg = + let pk_bytes = Data_encoding.Binary.to_bytes_exn Public_key.encoding pk in + let size = Ed25519.size in + let msg = Blake2B.to_bytes @@ Blake2B.hash_bytes [msg] in + let half = size / 2 in + let tmp = Bytes.init size (fun _ -> '0') in + let all_or_half buf = Stdlib.min (Bytes.length buf) half in + Bytes.blit pk_bytes 0 tmp 0 (all_or_half pk_bytes) ; + Bytes.blit msg 0 tmp half (all_or_half msg) ; + of_bytes_exn tmp + +type algo = Ed25519 | Secp256k1 | P256 | Bls + +let fake_sign ?watermark:_ secret_key msg = + let pk = Secret_key.to_public_key secret_key in + fake_sign_from_pk pk msg + +let hardcoded_sk algo : secret_key = + match algo with + | Ed25519 -> + Secret_key.of_b58check_exn + "edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh" + | Secp256k1 -> + Secret_key.of_b58check_exn + "spsk2XJu4wuYsHeuDaCktD3ECnnpn574ceSWHEJVvXTt7JP6ztySCL" + | P256 -> + Secret_key.of_b58check_exn + "p2sk2k6YAkNJ8CySZCS3vGA5Ht6Lj6LXG3yb8UrHvMKZy7Ab8JUtWh" + | Bls -> + Secret_key.of_b58check_exn + "BLsk1hfuv6V8JJRaLDBJgPTRGLKusTZnTmWGrvSKYzUaMuzvPLmeGG" + +let hardcoded_pk = + (* precompute signatures *) + let ed, secp, p, bls = + ( Secret_key.to_public_key (hardcoded_sk Ed25519), + Secret_key.to_public_key (hardcoded_sk Secp256k1), + Secret_key.to_public_key (hardcoded_sk P256), + Secret_key.to_public_key (hardcoded_sk Bls) ) + in + function Ed25519 -> ed | Secp256k1 -> secp | P256 -> p | Bls -> bls + +let hardcoded_msg = Bytes.of_string "Cheers" + +let hardcoded_sig = + (* precompute signatures *) + let ed, secp, p, bls = + ( sign (hardcoded_sk Ed25519) hardcoded_msg, + sign (hardcoded_sk Secp256k1) hardcoded_msg, + sign (hardcoded_sk P256) hardcoded_msg, + sign (hardcoded_sk Bls) hardcoded_msg ) + in + function Ed25519 -> ed | Secp256k1 -> secp | P256 -> p | Bls -> bls + +let algo_of_pk (pk : Public_key.t) = + match pk with + | Ed25519 _ -> Ed25519 + | Secp256k1 _ -> Secp256k1 + | P256 _ -> P256 + | Bls _ -> Bls + +let fast_fake_sign ?watermark:_ sk _msg = + let pk = Secret_key.to_public_key sk in + hardcoded_sig (algo_of_pk pk) + +let check_harcoded_signature pk = + let algo = algo_of_pk pk in + check (hardcoded_pk algo) (hardcoded_sig algo) hardcoded_msg + +(* The following cache is a hack to work around a quadratic algorithm + in Tezos Mainnet protocols up to Edo. *) + +module type ENDORSEMENT_CACHE_MAKER = functor (H : Stdlib.Hashtbl.HashedType) -> + Aches.Vache.MAP with type key = H.t + +let make_endorsement_cache : (module ENDORSEMENT_CACHE_MAKER) = + match Sys.getenv_opt "TEZOS_DISABLE_ENDORSEMENT_SIGNATURE_CACHE" with + | Some _ -> (module Aches.Vache.EmptyMap) + | None -> + (module Aches.Vache.Map (Aches.Vache.FIFO_Sloppy) (Aches.Vache.Strong)) + +module Endorsement_cache = + (val make_endorsement_cache) + (struct + type nonrec t = t + + let equal = equal + + let hash = Hashtbl.hash + end) + +let endorsement_cache = Endorsement_cache.create 300 + +let check ?watermark public_key signature message = + match watermark with + | Some (Endorsement _) -> ( + (* signature check cache only applies to endorsements *) + match Endorsement_cache.find_opt endorsement_cache signature with + | Some (key, msg) -> + (* we rely on this property : signature_1 = signature_2 => key_1 = key_2 /\ message_1 = message_2 *) + Public_key.equal public_key key && Bytes.equal msg message + | None -> + let res = check ?watermark public_key signature message in + if res then + Endorsement_cache.replace + endorsement_cache + signature + (public_key, message) ; + res) + | _ -> check ?watermark public_key signature message + +let fake_check ?watermark:_ pk _signature msg = + (* computing the fake signature do hash the message, + this operation is linear in the size of the message *) + ignore (fake_sign_from_pk pk msg) ; + (* checking a valid, harcoded signature, to do at least once the crypto maths *) + let _ = check_harcoded_signature pk in + true + +(* Fast checking does not simulate computation and directly returns true*) +let fast_fake_check ?watermark:_ _pk _signature _msg = true + +let sign = + match Helpers.yes_crypto_kind with + | Fast -> fast_fake_sign + | Yes -> fake_sign + | No -> sign + +let check = + match Helpers.yes_crypto_kind with + | Fast -> fast_fake_check + | Yes -> fake_check + | No -> check + +let append ?watermark sk msg = Bytes.cat msg (to_bytes (sign ?watermark sk msg)) + +let concat msg signature = Bytes.cat msg (to_bytes signature) + +let algos = [Ed25519; Secp256k1; P256; Bls] + +let fake_generate_key (pkh, pk, _) = + let sk_of_pk (pk : public_key) : secret_key = + let pk_b = Data_encoding.Binary.to_bytes_exn Public_key.encoding pk in + let sk_b = Bytes.sub pk_b 0 33 in + let sk = Data_encoding.Binary.of_bytes_exn Secret_key.encoding sk_b in + sk + in + let fake_sk = sk_of_pk pk in + (pkh, pk, fake_sk) + +let generate_key ?(algo = Ed25519) ?seed () = + match algo with + | Ed25519 -> + let pkh, pk, sk = Ed25519.generate_key ?seed () in + (Public_key_hash.Ed25519 pkh, Public_key.Ed25519 pk, Secret_key.Ed25519 sk) + | Secp256k1 -> + let pkh, pk, sk = Secp256k1.generate_key ?seed () in + ( Public_key_hash.Secp256k1 pkh, + Public_key.Secp256k1 pk, + Secret_key.Secp256k1 sk ) + | P256 -> + let pkh, pk, sk = P256.generate_key ?seed () in + (Public_key_hash.P256 pkh, Public_key.P256 pk, Secret_key.P256 sk) + | Bls -> + let pkh, pk, sk = Bls.generate_key ?seed () in + (Public_key_hash.Bls pkh, Public_key.Bls pk, Secret_key.Bls sk) + +let fake_generate_key ?(algo = Ed25519) ?seed () = + let true_keys = generate_key ~algo ?seed () in + fake_generate_key true_keys + +let generate_key = + match Helpers.yes_crypto_kind with + | Fast | Yes -> + (* We keep the original keys generation to stay as close as possible of the + initial performance. *) + fake_generate_key + | No -> generate_key + +let deterministic_nonce sk msg = + match sk with + | Secret_key.Ed25519 sk -> Ed25519.deterministic_nonce sk msg + | Secret_key.Secp256k1 sk -> Secp256k1.deterministic_nonce sk msg + | Secret_key.P256 sk -> P256.deterministic_nonce sk msg + | Secret_key.Bls sk -> Bls.deterministic_nonce sk msg + +let deterministic_nonce_hash sk msg = + match sk with + | Secret_key.Ed25519 sk -> Ed25519.deterministic_nonce_hash sk msg + | Secret_key.Secp256k1 sk -> Secp256k1.deterministic_nonce_hash sk msg + | Secret_key.P256 sk -> P256.deterministic_nonce_hash sk msg + | Secret_key.Bls sk -> Bls.deterministic_nonce_hash sk msg + +module Of_V0 = struct + let public_key_hash : Signature_v0.Public_key_hash.t -> Public_key_hash.t = + function + | Signature_v0.Ed25519 k -> Ed25519 k + | Signature_v0.Secp256k1 k -> Secp256k1 k + | Signature_v0.P256 k -> P256 k + + let public_key : Signature_v0.Public_key.t -> Public_key.t = function + | Signature_v0.Ed25519 k -> Ed25519 k + | Signature_v0.Secp256k1 k -> Secp256k1 k + | Signature_v0.P256 k -> P256 k + + let secret_key : Signature_v0.Secret_key.t -> Secret_key.t = function + | Signature_v0.Ed25519 k -> Ed25519 k + | Signature_v0.Secp256k1 k -> Secp256k1 k + | Signature_v0.P256 k -> P256 k + + let signature : Signature_v0.t -> t = function + | Signature_v0.Ed25519 k -> Ed25519 k + | Signature_v0.Secp256k1 k -> Secp256k1 k + | Signature_v0.P256 k -> P256 k + | Signature_v0.Unknown k -> Unknown k +end + +module Of_V1 = struct + let public_key_hash : Signature_v1.Public_key_hash.t -> Public_key_hash.t = + function + | Signature_v1.Ed25519 k -> Ed25519 k + | Signature_v1.Secp256k1 k -> Secp256k1 k + | Signature_v1.P256 k -> P256 k + | Signature_v1.Bls k -> Bls k + + let public_key : Signature_v1.Public_key.t -> Public_key.t = function + | Signature_v1.Ed25519 k -> Ed25519 k + | Signature_v1.Secp256k1 k -> Secp256k1 k + | Signature_v1.P256 k -> P256 k + | Signature_v1.Bls k -> Bls k + + let secret_key : Signature_v1.Secret_key.t -> Secret_key.t = function + | Signature_v1.Ed25519 k -> Ed25519 k + | Signature_v1.Secp256k1 k -> Secp256k1 k + | Signature_v1.P256 k -> P256 k + | Signature_v1.Bls k -> Bls k + + let signature : Signature_v1.t -> t = function + | Signature_v1.Ed25519 k -> Ed25519 k + | Signature_v1.Secp256k1 k -> Secp256k1 k + | Signature_v1.P256 k -> P256 k + | Signature_v1.Unknown k -> Unknown k + | Signature_v1.Bls k -> Bls k +end diff --git a/src/lib_crypto/signature_v2.mli b/src/lib_crypto/signature_v2.mli new file mode 100644 index 0000000000000000000000000000000000000000..cc9217248cdaa70af1b3a7f75ec66352ecae3c2a --- /dev/null +++ b/src/lib_crypto/signature_v2.mli @@ -0,0 +1,133 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* SPDX-FileCopyrightText: 2025 Nomadic Labs *) +(* *) +(*****************************************************************************) + +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 + +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 + +type secret_key = + | Ed25519 of Ed25519.Secret_key.t + | Secp256k1 of Secp256k1.Secret_key.t + | P256 of P256.Secret_key.t + | Bls of Bls.Secret_key.t + +type watermark = Signature_v0.watermark = + | Block_header of Chain_id.t + | Endorsement of Chain_id.t + | Generic_operation + | Custom of Bytes.t + +val bytes_of_watermark : watermark -> Bytes.t + +val pp_watermark : Format.formatter -> watermark -> unit + +type signature = + | Ed25519 of Ed25519.t + | Secp256k1 of Secp256k1.t + | P256 of P256.t + | Bls of Bls.t + | Unknown of Bytes.t + +(** A signature prefix holds data only for signature that are more than 64 bytes + long. *) +type prefix = Bls_prefix of Bytes.t + +include + S.SPLIT_SIGNATURE + with type Public_key_hash.t = public_key_hash + and type Public_key.t = public_key + and type Secret_key.t = secret_key + and type watermark := watermark + and type prefix := prefix + and type t = signature + +(** [append sk buf] is the concatenation of [buf] and the + serialization of the signature of [buf] signed by [sk]. *) +val append : ?watermark:watermark -> secret_key -> Bytes.t -> Bytes.t + +(** [concat buf t] is the concatenation of [buf] and the serialization + of [t]. *) +val concat : Bytes.t -> t -> Bytes.t + +include S.RAW_DATA with type t := t + +(** The size of the signature in bytes. Can be [64] for Ed25519, Secp256k1 and + P256 signatures or [96] for BLS signatures. *) +val size : t -> int + +(** [of_secp256k1 s] returns a wrapped version of the Secp256k1 signature [s] in + {!t}. *) +val of_secp256k1 : Secp256k1.t -> t + +(** [of_ed25519 s] returns a wrapped version of the Ed25519 signature [s] in + {!t}. *) +val of_ed25519 : Ed25519.t -> t + +(** [of_p256 s] returns a wrapped version of the P256 signature [s] in {!t}. *) +val of_p256 : P256.t -> t + +(** [of_bls s] returns a wrapped version of the BLS signature [s] in {!t}. *) +val of_bls : Bls.t -> t + +(** The type of signing algorithms. *) +type algo = Ed25519 | Secp256k1 | P256 | Bls + +(** The list of signing algorithm supported, i.e. all constructors of type + {!algo}. *) +val algos : algo list + +(** [generate_key ~algo ~seed ()] generates a key pair for the signing algorithm + [algo] from the random seed [seed]. *) +val generate_key : + ?algo:algo -> + ?seed:Bytes.t -> + unit -> + public_key_hash * public_key * secret_key + +(** This module provides conversion functions for values (of keys and + signatures) of the module {!Signature_V0}. Note that these functions are + total because [Signature_v1] supports more signature kinds than + {!Signature_v0}. *) +module Of_V0 : sig + (** Convert a public key hash from V0 to V1. *) + val public_key_hash : Signature_v0.Public_key_hash.t -> Public_key_hash.t + + (** Convert a public key from V0 to V1. *) + val public_key : Signature_v0.Public_key.t -> Public_key.t + + (** Convert a secret key from V0 to V1. *) + val secret_key : Signature_v0.Secret_key.t -> Secret_key.t + + (** Convert a signature from V0 to V1. *) + val signature : Signature_v0.t -> t +end + +(** This module provides conversion functions for values (of keys and + signatures) of the module {!Signature_V1}. Note that these functions are + total because [Signature_v1] supports more signature kinds than + {!Signature_v0}. *) +module Of_V1 : sig + (** Convert a public key hash from V1 to V2. *) + val public_key_hash : Signature_v1.Public_key_hash.t -> Public_key_hash.t + + (** Convert a public key from V1 to V2. *) + val public_key : Signature_v1.Public_key.t -> Public_key.t + + (** Convert a secret key from V1 to V2. *) + val secret_key : Signature_v1.Secret_key.t -> Secret_key.t + + (** Convert a signature from V1 to V2. *) + val signature : Signature_v1.t -> t +end diff --git a/src/lib_protocol_environment/environment_V14.ml b/src/lib_protocol_environment/environment_V14.ml index 2641ed79ab8542eaa7f976abf24c8347e6ff5958..6ac9746abda461f3b7c2c09f88f24f437318669e 100644 --- a/src/lib_protocol_environment/environment_V14.ml +++ b/src/lib_protocol_environment/environment_V14.ml @@ -1589,6 +1589,9 @@ 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.ml b/src/lib_protocol_environment/environment_V15.ml index 427e81e1d99c4c6f26b01fdbe6b3092fe589ae8f..51e7db2003e16e6c854e9589aa7a0ac46a26f7ad 100644 --- a/src/lib_protocol_environment/environment_V15.ml +++ b/src/lib_protocol_environment/environment_V15.ml @@ -1589,6 +1589,9 @@ 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_wasm_debugger/messages.ml b/src/lib_wasm_debugger/messages.ml index 6c944837a1542d6270d896b3cab6a13c95ff619b..23cfc807ae1be7ff01c1a535d85dd3ac02d88b59 100644 --- a/src/lib_wasm_debugger/messages.ml +++ b/src/lib_wasm_debugger/messages.ml @@ -72,9 +72,15 @@ let input_encoding default_sender default_source default_destination : | `Inbox_message Sc_rollup.Inbox_message.( Internal (Transfer {payload; sender; source; destination})) -> + let source = + Tezos_crypto.Signature.Of_V1.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 + in `Inbox_message (Internal (Transfer {payload; sender; source; destination}))); case diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_args.ml b/src/proto_016_PtMumbai/lib_client/client_proto_args.ml index 335748a7c091aa8f7c5ed9733c80d5512c82b782..43e10e604c1522411625a379264d493bfed8ed0d 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_args.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_args.ml @@ -564,7 +564,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Tezos_crypto.Signature.of_b58check_opt s with + match Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_args.mli b/src/proto_016_PtMumbai/lib_client/client_proto_args.mli index 92ac95ab54b43a73fa520f8f0c3486ae3dcbd135..5de70c7fc18754ac93ba5cdd763f24c94421a316 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_args.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_args.mli @@ -60,8 +60,7 @@ val entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg val default_entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg -val delegate_arg : - (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -126,7 +125,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_context.ml b/src/proto_016_PtMumbai/lib_client/client_proto_context.ml index 1f6ce39e72a9adbb234067833f51138c5b1681dd..371beb4bb259d52957ec5c207611a262efdd33f5 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_context.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_context.ml @@ -28,7 +28,6 @@ open Alpha_context open Protocol_client_context open Tezos_micheline open Client_proto_contracts -open Client_keys let get_balance (rpc : #rpc_context) ~chain ~block contract = Alpha_services.Contract.balance rpc (chain, block) contract @@ -275,7 +274,7 @@ let list_contract_labels cctxt ~chain ~block = (fun h -> (match (h : Contract.t) with | Implicit m -> ( - Public_key_hash.rev_find cctxt m >>=? function + Client_keys.Public_key_hash.rev_find cctxt m >>=? function | None -> return "" | Some nm -> ( Raw_contract_alias.find_opt cctxt nm >>=? function @@ -324,7 +323,7 @@ let build_update_consensus_key ?fee ?gas_limit ?storage_limit consensus_pk = let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter ?consensus_pk src_pk = - let source = Tezos_crypto.Signature.Public_key.hash src_pk in + let source = Signature.Public_key.hash src_pk in let delegate_op = build_delegate_operation ?fee (Some source) in match consensus_pk with | None -> ( @@ -385,7 +384,7 @@ let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run let update_consensus_key cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ~consensus_pk ~manager_sk ~fee_parameter src_pk = - let source = Tezos_crypto.Signature.Public_key.hash src_pk in + let source = Signature.Public_key.hash src_pk in let operation = build_update_consensus_key ?fee consensus_pk in let operation = Annotated_manager_operation.Single_manager operation in Injection.inject_manager_operation @@ -715,14 +714,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Tezos_crypto.Signature.Secret_key.t = + let sk : Signature.Secret_key.t = Ed25519 (Data_encoding.Binary.of_bytes_exn Tezos_crypto.Signature.Ed25519.Secret_key.encoding sk) in - let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in - let pkh = Tezos_crypto.Signature.Public_key.hash pk in + let pk = Signature.Secret_key.to_public_key sk in + let pkh = Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -762,11 +761,11 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp pkh Tezos_crypto.Signature.Ed25519.Public_key_hash.pp key.pkh) diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_context.mli b/src/proto_016_PtMumbai/lib_client/client_proto_context.mli index 893f1863dcbcea753568fdd927f7d3e5a5e18a9f..f0edc7b8d7788143d63ea4e16083f50d911f21b6 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_context.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_context.mli @@ -81,8 +81,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -151,7 +151,7 @@ val get_frozen_deposits_limit : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> - Tezos_crypto.Signature.Public_key_hash.t -> + Signature.Public_key_hash.t -> Tez.t option tzresult Lwt.t (** Calls {!Injection.prepare_manager_operation} @@ -191,10 +191,10 @@ val update_consensus_key : ?verbose_signing:bool -> ?simulation:bool -> ?fee:Tez.tez -> - consensus_pk:Tezos_crypto.Signature.public_key -> + consensus_pk:Signature.public_key -> manager_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> - Tezos_crypto.Signature.public_key -> + Signature.public_key -> Kind.update_consensus_key Kind.manager Injection.result tzresult Lwt.t val drain_delegate : @@ -206,9 +206,9 @@ val drain_delegate : ?verbose_signing:bool -> ?simulation:bool -> consensus_sk:Client_keys.sk_uri -> - consensus_pkh:Tezos_crypto.Signature.public_key_hash -> - ?destination:Tezos_crypto.Signature.public_key_hash -> - delegate:Tezos_crypto.Signature.public_key_hash -> + consensus_pkh:Signature.public_key_hash -> + ?destination:Signature.public_key_hash -> + delegate:Signature.public_key_hash -> unit -> Kind.drain_delegate Injection.result tzresult Lwt.t @@ -254,7 +254,7 @@ val increase_paid_storage : Kind.increase_paid_storage Kind.manager Injection.result tzresult Lwt.t (** Same as {!set_delegate} but the [~source] argument of {!Injection.inject_manager_operation} - is {!Tezos_crypto.Signature.Public_key.hash} [src_pk]. *) + is {!Signature.Public_key.hash} [src_pk]. *) val register_as_delegate : #Protocol_client_context.full -> chain:Shell_services.chain -> @@ -592,8 +592,8 @@ val originate_tx_rollup : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> @@ -616,8 +616,8 @@ val submit_tx_rollup_batch : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> content:string -> @@ -641,8 +641,8 @@ val submit_tx_rollup_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -669,8 +669,8 @@ val submit_tx_rollup_finalize_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> @@ -694,8 +694,8 @@ val submit_tx_rollup_remove_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> @@ -718,8 +718,8 @@ val submit_tx_rollup_rejection : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -752,8 +752,8 @@ val submit_tx_rollup_return_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> @@ -776,8 +776,8 @@ val tx_rollup_dispatch_tickets : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -805,8 +805,8 @@ val transfer_ticket : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> contents:string -> @@ -963,8 +963,8 @@ val sc_rollup_recover_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Tezos_crypto.Signature.public_key_hash -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.public_key_hash -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> sc_rollup:Sc_rollup.t -> diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_fa12.mli b/src/proto_016_PtMumbai/lib_client/client_proto_fa12.mli index 8dccc6bbca640796d6f2abb3e064b803b6a512ab..56c3f4d609b47d2b532ec40857d82f5c408ebc08 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_fa12.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_fa12.mli @@ -155,7 +155,7 @@ val run_view_action : ?source:Contract.t -> contract:Contract_hash.t -> action:action -> - ?payer:Tezos_crypto.Signature.public_key_hash -> + ?payer:public_key_hash -> ?gas:Gas.Arith.integral -> unparsing_mode:Script_ir_unparser.unparsing_mode -> unit -> diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_multisig.ml b/src/proto_016_PtMumbai/lib_client/client_proto_multisig.ml index 891572c2e10e7a67c66dbf2f39faa75cb7d478b2..108233e7b2ab905c7c7814ecafe7092d4076480f 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_multisig.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_multisig.ml @@ -136,12 +136,8 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf - ppf - "Invalid signature %s." - (Tezos_crypto.Signature.to_b58check s)) - Data_encoding.( - obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) + Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) + Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -588,12 +584,11 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc - (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = +let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Tezos_crypto.Signature.Public_key_hash.encoding + Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) @@ -604,12 +599,10 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) Data_encoding.(tup2 Contract.encoding Entrypoint.value_encoding) (address, entrypoint)) -let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = +let optimized_key ~loc (key : Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn - Tezos_crypto.Signature.Public_key.encoding - key) + (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) (** * Actions *) @@ -714,7 +707,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Tezos_crypto.Signature.Public_key.encoding + Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -790,7 +783,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Tezos_crypto.Signature.Public_key_hash.encoding + Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -817,7 +810,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Tezos_crypto.Signature.Public_key.encoding + Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -827,7 +820,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Tezos_crypto.Signature.Public_key.t list +type key_list = Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -854,8 +847,7 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return - @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str + return @@ Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -867,7 +859,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in + let key_str = Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -888,10 +880,7 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return - @@ some - ~loc - (String (loc, Tezos_crypto.Signature.to_b58check signature))) + return @@ some ~loc (String (loc, Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc ~generic action >>=? fun expr -> @@ -1056,7 +1045,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Tezos_crypto.Signature.check key signature bytes then ( + if Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_multisig.mli b/src/proto_016_PtMumbai/lib_client/client_proto_multisig.mli index cb82be9493a1a4a692b8dadf450ca2d774e07e38..5ebfd1448d0fe6c47ff0f8fc30c943acc51e2c5a 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_multisig.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> action:multisig_action -> - signatures:Tezos_crypto.Signature.t list -> + signatures:Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -139,7 +139,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> bytes:Bytes.t -> - signatures:Tezos_crypto.Signature.t list -> + signatures:Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_programs.ml b/src/proto_016_PtMumbai/lib_client/client_proto_programs.ml index a7edc7314f9871344a28b85f0e0f750126d47ed4..111c6e44331957fb0a0f14a3ea63e48de49002f9 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_programs.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_programs.ml @@ -126,7 +126,7 @@ type simulation_params = { now : Script_timestamp.t option; level : Script_int.n Script_int.num option; source : Contract.t option; - payer : Tezos_crypto.Signature.public_key_hash option; + payer : Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_programs.mli b/src/proto_016_PtMumbai/lib_client/client_proto_programs.mli index 3b6d1380ce13c7079f60461cfcc95048d59b5ad8..8aaaa139b6e919c3bedd24d561cbd417777effe2 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_programs.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_programs.mli @@ -39,7 +39,7 @@ type simulation_params = { now : Script_timestamp.t option; level : Script_int.n Script_int.num option; source : Contract.t option; - payer : Tezos_crypto.Signature.public_key_hash option; + payer : Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_utils.ml b/src/proto_016_PtMumbai/lib_client/client_proto_utils.ml index 9f67616f2e9da183a2fa3839b0c6bfd750a2e4ce..78f9efe737129b9c623347b0a6f2d27da12e50f6 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_utils.ml +++ b/src/proto_016_PtMumbai/lib_client/client_proto_utils.ml @@ -40,11 +40,7 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign - cctxt - ~watermark:Tezos_crypto.Signature.Generic_operation - src_sk - bytes + Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -53,7 +49,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Tezos_crypto.Signature.Generic_operation + ~watermark:Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_016_PtMumbai/lib_client/client_proto_utils.mli b/src/proto_016_PtMumbai/lib_client/client_proto_utils.mli index 3c06f0108ea85c46b2af7b685991fd5b36961059..c535e4b24ecb9e4eb1eb02cb16b454b9f6647112 100644 --- a/src/proto_016_PtMumbai/lib_client/client_proto_utils.mli +++ b/src/proto_016_PtMumbai/lib_client/client_proto_utils.mli @@ -28,7 +28,7 @@ val sign_message : src_sk:Client_keys.sk_uri -> block:Block_hash.t -> message:string -> - Tezos_crypto.Signature.t tzresult Lwt.t + Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> @@ -36,5 +36,5 @@ val check_message : key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Tezos_crypto.Signature.t -> + signature:Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_016_PtMumbai/lib_client/dune b/src/proto_016_PtMumbai/lib_client/dune index 4d5f401a58bbf9ec07577993e0758363b3ce9031..5ae1fe251a59143b6d97576727d3808df5ace3af 100644 --- a/src/proto_016_PtMumbai/lib_client/dune +++ b/src/proto_016_PtMumbai/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_016_PtMumbai -open Tezos_protocol_016_PtMumbai_parameters -open Tezos_smart_rollup_016_PtMumbai)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_016_PtMumbai/lib_client/injection.ml b/src/proto_016_PtMumbai/lib_client/injection.ml index 55033fd726b5dacf1e4cf12d888742e3bdc8c2df..5f7f769a2b89c39f43bd4d3a52dcbd83b3944944 100644 --- a/src/proto_016_PtMumbai/lib_client/injection.ml +++ b/src/proto_016_PtMumbai/lib_client/injection.ml @@ -1223,10 +1223,10 @@ let pending_applied_operations_of_source (cctxt : #full) chain src : (fun acc (_oph, {protocol_data = Operation_data {contents; _}; _}) -> match contents with | Single (Manager_operation {source; _} as _op) - when Tezos_crypto.Signature.Public_key_hash.equal source src -> + when Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | Cons (Manager_operation {source; _}, _rest) as _op - when Tezos_crypto.Signature.Public_key_hash.equal source src -> + when Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | _ -> acc) [] @@ -1349,14 +1349,14 @@ let replace_operation (type kind) (cctxt : #full) chain source cctxt#error "Cannot replace! No applied manager operation found for %a in \ mempool@." - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source >>= fun () -> exit 1 | _ :: _ :: _ as l -> cctxt#error "More than one applied manager operation found for %a in mempool. \ Found %d operations. Are you sure the node is in precheck mode?@." - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source (List.length l) >>= fun () -> exit 1 diff --git a/src/proto_016_PtMumbai/lib_client/injection.mli b/src/proto_016_PtMumbai/lib_client/injection.mli index 18d87a3c0ba72190f5cde6f07513865b0897bd37..d66775157c80a34c0ea1bc2469c28e4d062a5ef5 100644 --- a/src/proto_016_PtMumbai/lib_client/injection.mli +++ b/src/proto_016_PtMumbai/lib_client/injection.mli @@ -103,8 +103,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Tezos_crypto.Signature.Public_key_hash.t -> - src_pk:Tezos_crypto.Signature.public_key -> + source:Signature.Public_key_hash.t -> + src_pk:Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> diff --git a/src/proto_016_PtMumbai/lib_client/managed_contract.ml b/src/proto_016_PtMumbai/lib_client/managed_contract.ml index 3edbaae334159dc0f533115188b17f4067da403f..5d406c1276484f09886e9aa0085023eb0b6364cd 100644 --- a/src/proto_016_PtMumbai/lib_client/managed_contract.ml +++ b/src/proto_016_PtMumbai/lib_client/managed_contract.ml @@ -51,7 +51,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Tezos_crypto.Signature.Public_key_hash.encoding + Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -62,7 +62,7 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported for \ \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value with + match Signature.Public_key_hash.of_b58check_opt value with | Some k -> return k | None -> cctxt#error @@ -89,9 +89,7 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = - Tezos_crypto.Signature.Public_key_hash.to_hex delegate - in + let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -106,7 +104,7 @@ let entrypoint_remove_delegate = Entrypoint.remove_delegate let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Tezos_crypto.Signature.public_key_hash option) = + (delegate : Signature.public_key_hash option) = let entrypoint = entrypoint_do in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -141,7 +139,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Tezos_crypto.Signature.Public_key_hash.to_hex delegate + Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -162,7 +160,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Tezos_crypto.Signature.public_key_hash option) = + (delegate : Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -192,9 +190,7 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = - Tezos_crypto.Signature.Public_key_hash.to_hex destination - in + let (`Hex destination) = Signature.Public_key_hash.to_hex destination in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_016_PtMumbai/lib_client/managed_contract.mli b/src/proto_016_PtMumbai/lib_client/managed_contract.mli index b459230ae8b390e5c949fb3c022e005d04e40d85..92f241b68c76c736117ed4fe9032c3c467efa6b4 100644 --- a/src/proto_016_PtMumbai/lib_client/managed_contract.mli +++ b/src/proto_016_PtMumbai/lib_client/managed_contract.mli @@ -37,7 +37,7 @@ val check_smart_contract : #full -> 'a option -> ('a -> 'b Lwt.t) -> 'b Lwt.t The storage has to be of type `pair key_hash 'a`. *) val get_contract_manager : - #full -> Contract_hash.t -> public_key_hash tzresult Lwt.t + #full -> Contract_hash.t -> Signature.public_key_hash tzresult Lwt.t (** Builds a delegation operation ready for injection *) val build_delegate_operation : diff --git a/src/proto_016_PtMumbai/lib_client/mockup.ml b/src/proto_016_PtMumbai/lib_client/mockup.ml index 68fe34f0dbff21fa93cdfae1f8a0b3f4b220b9a9..bf750d2822bd6ef49084e1f74b2e6e59d66cbd54 100644 --- a/src/proto_016_PtMumbai/lib_client/mockup.ml +++ b/src/proto_016_PtMumbai/lib_client/mockup.ml @@ -97,9 +97,9 @@ module Parsed_account = struct (req "amount" Tez.encoding)) let to_bootstrap_account repr = - Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> - Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in + Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> + Client_keys.public_key pk_uri >>=? fun public_key -> + let public_key_hash = Signature.Public_key.hash public_key in return Parameters. { @@ -165,11 +165,11 @@ module Bootstrap_account = struct (fun (public_key_hash, public_key, amount, delegate_to, consensus_key) -> {public_key_hash; public_key; amount; delegate_to; consensus_key}) (obj5 - (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) - (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) + (req "public_key_hash" Signature.Public_key_hash.encoding) + (opt "public_key" Signature.Public_key.encoding) (req "amount" Tez.encoding) - (opt "delegate_to" Tezos_crypto.Signature.Public_key_hash.encoding) - (opt "consensus_key" Tezos_crypto.Signature.Public_key.encoding)) + (opt "delegate_to" Signature.Public_key_hash.encoding) + (opt "consensus_key" Signature.Public_key.encoding)) end module Bootstrap_contract = struct @@ -180,7 +180,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (opt "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "delegate" Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -498,7 +498,7 @@ let mem_init : [Block_hash.to_bytes hash; Operation_list_hash.(to_bytes @@ compute [])] in let open Protocol.Alpha_context.Block_header in - let _, _, sk = Tezos_crypto.Signature.generate_key () in + let _, _, sk = Signature.generate_key () in let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -518,7 +518,7 @@ let mem_init : (shell_header, contents) in let signature = - Tezos_crypto.Signature.sign + Signature.sign ~watermark: Protocol.Alpha_context.Block_header.( to_watermark (Block_header chain_id)) diff --git a/src/proto_016_PtMumbai/lib_client/operation_result.ml b/src/proto_016_PtMumbai/lib_client/operation_result.ml index 5d64fa5459374d2d8fbc0a858d1129b42f3f31b4..a0957e326d9ad4f8b62797cb47efb4880548f9c5 100644 --- a/src/proto_016_PtMumbai/lib_client/operation_result.ml +++ b/src/proto_016_PtMumbai/lib_client/operation_result.ml @@ -96,13 +96,13 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = Format.fprintf ppf "@,Delegate: %a" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp delegate) | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Destination.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Signature.Public_key_hash.pp ppf delegate) | Event {ty; tag; payload} -> Format.fprintf ppf @@ -169,7 +169,7 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "@,Delegate: %a" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp delegate) | Reveal key -> Format.fprintf @@ -177,13 +177,13 @@ let pp_manager_operation_content (type kind) source ppf "Revelation of manager public key:@,Contract: %a@,Key: %a" Contract.pp source - Tezos_crypto.Signature.Public_key.pp + Signature.Public_key.pp key | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Signature.Public_key_hash.pp ppf delegate) | Register_global_constant {value} -> Format.fprintf ppf @@ -213,8 +213,8 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "Update_consensus_key:@,Public key hash: %a" - Tezos_crypto.Signature.Public_key_hash.pp - (Tezos_crypto.Signature.Public_key.hash pk) + Signature.Public_key_hash.pp + (Signature.Public_key.hash pk) | Tx_rollup_origination -> Format.fprintf ppf @@ -389,7 +389,7 @@ let pp_manager_operation_content (type kind) source ppf "Smart rollup bond retrieval:@,Address: %a@,Staker: %a" Sc_rollup.Address.pp sc_rollup - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp staker | Dal_publish_slot_header slot_header -> Format.fprintf @@ -410,12 +410,9 @@ let pp_balance_updates ppf balance_updates = (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if - Tezos_crypto.Signature.Public_key_hash.equal - baker - Tezos_crypto.Signature.Public_key_hash.zero - then Format.fprintf ppf "the baker who will include this operation" - else Tezos_crypto.Signature.Public_key_hash.pp ppf baker + if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero then + Format.fprintf ppf "the baker who will include this operation" + else Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -970,11 +967,7 @@ let pp_manager_operation_result ppf Manager_operation_result {balance_updates; operation_result; internal_operation_results} ) = Format.fprintf ppf "@[Manager signed operations:" ; - Format.fprintf - ppf - "@,From: %a" - Tezos_crypto.Signature.Public_key_hash.pp - source ; + Format.fprintf ppf "@,From: %a" Signature.Public_key_hash.pp source ; Format.fprintf ppf "@,Fee to the baker: %s%a" tez_sym Tez.pp fee ; Format.fprintf ppf "@,Expected counter: %a" Manager_counter.pp counter ; Format.fprintf ppf "@,Gas limit: %a" Gas.Arith.pp_integral gas_limit ; @@ -1069,7 +1062,7 @@ let pp_contents_and_result : Format.fprintf ppf "@[Slot attestation:@,Delegate: %a@]" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp delegate | ( Double_endorsement_evidence {op1; op2}, Double_endorsement_evidence_result bus ) -> @@ -1116,7 +1109,7 @@ let pp_contents_and_result : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source period (Format.pp_print_list Protocol_hash.pp) @@ -1125,7 +1118,7 @@ let pp_contents_and_result : Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source period Protocol_hash.pp @@ -1141,11 +1134,11 @@ let pp_contents_and_result : Consensus key hash: %a@,\ Delegate: %a@,\ Destination: %a%s%a@]" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp consensus_key - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp delegate - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp destination (if allocated_destination_contract then " (allocated)" else "") pp_balance_updates diff --git a/src/proto_016_PtMumbai/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_016_PtMumbai/lib_client_commands/client_proto_fa12_commands.ml index 154313a4040f2b85496244868b352b352cb8ca0e..a9a782fafded9314bf7c072de359b6fd5f2f7d30 100644 --- a/src/proto_016_PtMumbai/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_016_PtMumbai/lib_client_commands/client_proto_fa12_commands.ml @@ -109,8 +109,7 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = - Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero +let dummy_callback = Contract.Implicit Signature.Public_key_hash.zero let get_contract_caller_keys cctxt (caller : Contract.t) = let open Lwt_result_syntax in diff --git a/src/proto_016_PtMumbai/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_016_PtMumbai/lib_client_commands/client_proto_multisig_commands.ml index f0bac893e082d9bc006455df4b4e958be56df7f8..805ba43b2e2a9366cd0db2bae41ab020899c097f 100644 --- a/src/proto_016_PtMumbai/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_016_PtMumbai/lib_client_commands/client_proto_multisig_commands.ml @@ -128,7 +128,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Tezos_crypto.Signature.Public_key.pp)) + Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) @@ -336,7 +336,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Tezos_crypto.Signature.pp signature ; + Format.printf "%a@." Signature.pp signature ; return_unit); command ~group @@ -370,7 +370,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Tezos_crypto.Signature.pp signature ; + Format.printf "%a@." Signature.pp signature ; return_unit); command ~group @@ -402,7 +402,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Tezos_crypto.Signature.pp signature ; + Format.printf "%a@." Signature.pp signature ; return_unit); command ~group @@ -427,7 +427,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Tezos_crypto.Signature.pp signature ; + Format.printf "%a@." Signature.pp signature ; return_unit); command ~group @@ -467,7 +467,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Tezos_crypto.Signature.pp signature ; + Format.printf "%a@." Signature.pp signature ; return_unit); command ~group diff --git a/src/proto_016_PtMumbai/lib_client_commands/client_proto_programs_commands.ml b/src/proto_016_PtMumbai/lib_client_commands/client_proto_programs_commands.ml index 310eea8f9dc96c312efa541132a2babb71e19d38..87db7021d2096b61962e1b225f07cc820be98b60 100644 --- a/src/proto_016_PtMumbai/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_016_PtMumbai/lib_client_commands/client_proto_programs_commands.ml @@ -136,7 +136,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Tezos_crypto.Signature.of_b58check_opt s with + match Signature.of_b58check_opt s with | Some s -> Lwt_result_syntax.return s | None -> failwith "Not given a valid signature") in @@ -779,9 +779,7 @@ let commands () = (fun () bytes sk cctxt -> let open Lwt_result_syntax in let* signature = Client_keys.sign cctxt sk bytes in - let*! () = - cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature - in + let*! () = cctxt#message "Signature: %a" Signature.pp signature in return_unit); command ~group diff --git a/src/proto_016_PtMumbai/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_016_PtMumbai/lib_client_commands/client_proto_stresstest_commands.ml index 9c0b9e58f05ac3a66b098740d6e60d1d255e97fd..bc90d4d4e411a500d6dc86d6369fe865ebe5d8bf 100644 --- a/src/proto_016_PtMumbai/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_016_PtMumbai/lib_client_commands/client_proto_stresstest_commands.ml @@ -64,14 +64,14 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Tezos_crypto.Signature.secret_key; + sk : Signature.secret_key; } type source_with_uri = { pkh : public_key_hash; pk : public_key; pk_uri : Client_keys.pk_uri; - sk : Tezos_crypto.Signature.secret_key; + sk : Signature.secret_key; sk_uri : Client_keys.sk_uri; } @@ -85,7 +85,7 @@ type source_origin = {source : source; origin : origin} (** Destination of a call: either an implicit contract or an originated one with all the necessary data (entrypoint and the argument). *) type destination = - | Implicit of Tezos_crypto.Signature.Public_key_hash.t + | Implicit of Signature.Public_key_hash.t | Originated of Smart_contracts.invocation_parameters type transfer = { @@ -104,7 +104,7 @@ type state = { mutable pool : source_origin list; mutable pool_size : int; mutable shuffled_pool : source list; - mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable revealed : Signature.Public_key_hash.Set.t; mutable last_block : Block_hash.t; mutable last_level : int; mutable target_block : Block_hash.t; @@ -161,9 +161,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) - (req "pk" Tezos_crypto.Signature.Public_key.encoding) - (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) + (req "pkh" Signature.Public_key_hash.encoding) + (req "pk" Signature.Public_key.encoding) + (req "sk" Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -175,7 +175,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -241,14 +241,14 @@ let normalize_source cctxt = let open Lwt_syntax in let sk_of_sk_uri sk_uri = match - Tezos_crypto.Signature.Secret_key.of_b58check + Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk | Error _ -> let+ r = Tezos_signer_backends.Encrypted.decrypt cctxt sk_uri in let sk = Option.of_result r in - Option.bind sk Tezos_crypto.Signature.Of_V_latest.secret_key + Option.bind sk Signature.Of_V_latest.secret_key in let key_from_alias alias = let warning msg alias = @@ -283,9 +283,7 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - let* () = - cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh - in + let* () = cctxt#warning msg Signature.Public_key_hash.pp pkh in return_none in let* key = @@ -300,7 +298,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp pkh alias in @@ -365,7 +363,7 @@ let random_seed rng = let generate_fresh_source state = let seed = random_seed state.rng_state in - let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in + let pkh, pk, sk = Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in state.pool <- fresh :: state.pool ; state.pool_size <- state.pool_size + 1 ; @@ -456,7 +454,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block log Debug (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp src.pkh) in (* Sampled source has zero balance: the transfer that created that @@ -502,11 +500,7 @@ let inject_contents (cctxt : Protocol_client_context.full) branch sk contents = ({branch}, Contents_list contents) in let signature = - Some - (Tezos_crypto.Signature.sign - ~watermark:Tezos_crypto.Signature.Generic_operation - sk - bytes) + Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -559,19 +553,14 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state Alpha_services.Contract.counter cctxt (`Main, `Head 0) transfer.src.pkh in let* already_revealed = - if - Tezos_crypto.Signature.Public_key_hash.Set.mem - transfer.src.pkh - state.revealed - then return true + if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then + return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Tezos_crypto.Signature.Public_key_hash.Set.add - transfer.src.pkh - state.revealed ; + Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; let* pk_opt = Alpha_services.Contract.manager_key cctxt @@ -605,7 +594,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp transfer.src.pkh Manager_counter.pp reveal_counter @@ -631,7 +620,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting transfer from %a (counter=%a) to %a" - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp transfer.src.pkh Manager_counter.pp transf_counter @@ -1189,9 +1178,7 @@ let generate_random_transactions = let sources = List.sort_uniq (fun src1 src2 -> - Tezos_crypto.Signature.Secret_key.compare - src1.source.sk - src2.source.sk) + Signature.Secret_key.compare src1.source.sk src2.source.sk) sources in let rng_state = Random.State.make [|parameters.seed|] in @@ -1222,7 +1209,7 @@ let generate_random_transactions = List.shuffle ~rng:rng_state (List.map (fun src_org -> src_org.source) sources); - revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; + revealed = Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.level; target_block = current_target_block; @@ -1507,14 +1494,14 @@ let load_wallet cctxt ~source_pkh = | [] -> return acc | (alias, pkh, _, _) :: tl when List.exists (String.equal alias) to_ban - || Tezos_crypto.Signature.Public_key_hash.equal pkh source_pkh -> + || Signature.Public_key_hash.equal pkh source_pkh -> aux acc tl | (_, pkh, pk, sk_uri) :: tl -> let* pk_uri = Client_keys.neuterize sk_uri in let payload = Uri.path (sk_uri : Tezos_signer_backends.Unencrypted.sk_uri :> Uri.t) in - let sk = Tezos_crypto.Signature.Secret_key.of_b58check_exn payload in + let sk = Signature.Secret_key.of_b58check_exn payload in aux ({pkh; pk; pk_uri; sk; sk_uri} :: acc) tl in aux [] keys @@ -1527,7 +1514,7 @@ let source_key_arg = "Source key public key hash from which the tokens will be transferred to \ start the funding." (parameter (fun _ s -> - let r = Tezos_crypto.Signature.Public_key_hash.of_b58check s in + let r = Signature.Public_key_hash.of_b58check s in match r with | Ok pkh -> Lwt_result_syntax.return pkh | Error e -> @@ -1812,7 +1799,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command cctxt#message "Starting funding from %a with parameters:@.- batch_size %d@.- \ batches_per_block %d@.- initial_amount %a@." - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source_pkh batch_size batches_per_block @@ -1879,7 +1866,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command source_balance Tez.pp req_balance - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source_pkh else let*! () = @@ -1888,7 +1875,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command "Transfering %a tz from %a (out of %a)@." Tez.pp req_balance - Tezos_crypto.Signature.Public_key_hash.pp + Signature.Public_key_hash.pp source_pkh Tez.pp source_balance) diff --git a/src/proto_016_PtMumbai/lib_client_commands/client_proto_utils_commands.ml b/src/proto_016_PtMumbai/lib_client_commands/client_proto_utils_commands.ml index 837defaed6008e252c9d722e18a8058fb9b07e59..0c210d59cfb60d1aa514cbdf47c13d9042ac07cd 100644 --- a/src/proto_016_PtMumbai/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_016_PtMumbai/lib_client_commands/client_proto_utils_commands.ml @@ -95,9 +95,7 @@ let commands () = () in let* signature = sign_message cctxt ~src_sk ~block ~message in - let*! () = - cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature - in + let*! () = cctxt#message "Signature: %a" Signature.pp signature in return_unit); command ~group @@ -177,8 +175,6 @@ let commands () = sk unsigned_header in - let*! () = - cctxt#message "%a" Hex.pp (Tezos_crypto.Signature.to_hex s) - in + let*! () = cctxt#message "%a" Hex.pp (Signature.to_hex s) in return_unit); ] diff --git a/src/proto_016_PtMumbai/lib_client_commands/dune b/src/proto_016_PtMumbai/lib_client_commands/dune index 9929baf24940eeb1fe78b872b03ce41f272fe745..2eb84a3959c70f8e70fe5678564f6834ffb134d3 100644 --- a/src/proto_016_PtMumbai/lib_client_commands/dune +++ b/src/proto_016_PtMumbai/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_016_PtMumbai) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_016_PtMumbai_commands_registration) (public_name octez-protocol-016-PtMumbai-libs.client.commands-registration) diff --git a/src/proto_016_PtMumbai/lib_client_sapling/client_sapling_commands.ml b/src/proto_016_PtMumbai/lib_client_sapling/client_sapling_commands.ml index 40b7267112ae9ce89ea774c642fc8df3ce6bac52..b40b3d9576be5527c2654dbb7f0c35f586167aa7 100644 --- a/src/proto_016_PtMumbai/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_016_PtMumbai/lib_client_sapling/client_sapling_commands.ml @@ -70,9 +70,7 @@ let bound_data_of_public_key_hash cctxt dst = let open Tezos_micheline in let open Protocol.Michelson_v1_primitives in let pkh_bytes = - Data_encoding.Binary.to_bytes_exn - Tezos_crypto.Signature.Public_key_hash.encoding - dst + Data_encoding.Binary.to_bytes_exn Signature.Public_key_hash.encoding dst in let micheline_bytes = Micheline.(Bytes (0, pkh_bytes) |> strip_locations) in let micheline_pkh_type = diff --git a/src/proto_016_PtMumbai/lib_parameters/default_parameters.ml b/src/proto_016_PtMumbai/lib_parameters/default_parameters.ml index ced9867d4202a97372cb42fef3e70be11a985b59..53eb6a107ee14d9d76f560f96c2e55f75d5228f8 100644 --- a/src/proto_016_PtMumbai/lib_parameters/default_parameters.ml +++ b/src/proto_016_PtMumbai/lib_parameters/default_parameters.ml @@ -416,8 +416,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let compute_accounts = List.map (fun s -> - let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in - let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in + let public_key = Signature.Public_key.of_b58check_exn s in + let public_key_hash = Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_016_PtMumbai/lib_parameters/default_parameters.mli b/src/proto_016_PtMumbai/lib_parameters/default_parameters.mli index f930bc38fd87d9098a4fb08164c0be69758be90f..eff7da67497223993fdcca88bfbf31ac7066a7a4 100644 --- a/src/proto_016_PtMumbai/lib_parameters/default_parameters.mli +++ b/src/proto_016_PtMumbai/lib_parameters/default_parameters.mli @@ -35,11 +35,11 @@ val constants_test : Constants.Parametric.t val test_commitments : Commitment.t list lazy_t val make_bootstrap_account : - Tezos_crypto.Signature.public_key_hash - * Tezos_crypto.Signature.public_key + Signature.public_key_hash + * Signature.public_key * Tez.t - * Tezos_crypto.Signature.public_key_hash option - * Tezos_crypto.Signature.public_key option -> + * Signature.public_key_hash option + * Signature.public_key option -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_016_PtMumbai/lib_parameters/dune b/src/proto_016_PtMumbai/lib_parameters/dune index b43f931191a35812d46daf813b31945e5ff76f30..82dcf16996a014be4269f092a9a8960336e1b1f4 100644 --- a/src/proto_016_PtMumbai/lib_parameters/dune +++ b/src/proto_016_PtMumbai/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_016_PtMumbai) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_016_PtMumbai/lib_plugin/RPC.ml b/src/proto_016_PtMumbai/lib_plugin/RPC.ml index 93e852d1383e186d52cc25ce2ef9445106093622..74eb7259f26542f1964ed200945771a260c4243d 100644 --- a/src/proto_016_PtMumbai/lib_plugin/RPC.ml +++ b/src/proto_016_PtMumbai/lib_plugin/RPC.ml @@ -940,7 +940,7 @@ module Scripts = struct type run_code_config = { balance : Tez.t; self : Contract_hash.t; - payer : Tezos_crypto.Signature.public_key_hash; + payer : Signature.public_key_hash; source : Contract.t; } @@ -970,9 +970,8 @@ module Scripts = struct let source_and_payer ~src_opt ~pay_opt ~default_src = match (src_opt, pay_opt) with | None, None -> - ( Contract.Originated default_src, - Tezos_crypto.Signature.Public_key_hash.zero ) - | Some c, None -> (c, Tezos_crypto.Signature.Public_key_hash.zero) + (Contract.Originated default_src, Signature.Public_key_hash.zero) + | Some c, None -> (c, Signature.Public_key_hash.zero) | None, Some c -> (Contract.Implicit c, c) | Some src, Some pay -> (src, pay) in @@ -3073,10 +3072,10 @@ module Baking_rights = struct {level; delegate; consensus_key; round; timestamp}) (obj5 (req "level" Raw_level.encoding) - (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "delegate" Signature.Public_key_hash.encoding) (req "round" Round.encoding) (opt "estimated_time" Timestamp.encoding) - (req "consensus_key" Tezos_crypto.Signature.Public_key_hash.encoding)) + (req "consensus_key" Signature.Public_key_hash.encoding)) let default_max_round = 64 @@ -3088,8 +3087,8 @@ module Baking_rights = struct type baking_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Tezos_crypto.Signature.Public_key_hash.t list; - consensus_keys : Tezos_crypto.Signature.Public_key_hash.t list; + delegates : Signature.Public_key_hash.t list; + consensus_keys : Signature.Public_key_hash.t list; max_round : int option; all : bool; } @@ -3179,16 +3178,12 @@ module Baking_rights = struct @@ List.fold_left (fun (acc, previous) r -> if - Tezos_crypto.Signature.Public_key_hash.Set.exists - (Tezos_crypto.Signature.Public_key_hash.equal r.delegate) + Signature.Public_key_hash.Set.exists + (Signature.Public_key_hash.equal r.delegate) previous then (acc, previous) - else - ( r :: acc, - Tezos_crypto.Signature.Public_key_hash.Set.add - r.delegate - previous )) - ([], Tezos_crypto.Signature.Public_key_hash.Set.empty) + else (r :: acc, Signature.Public_key_hash.Set.add r.delegate previous)) + ([], Signature.Public_key_hash.Set.empty) rights let register () = @@ -3224,7 +3219,7 @@ module Baking_rights = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) + (Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights @@ -3235,7 +3230,7 @@ module Baking_rights = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Tezos_crypto.Signature.Public_key_hash.equal p.consensus_key) + (Signature.Public_key_hash.equal p.consensus_key) delegates in List.filter is_requested rights @@ -3254,8 +3249,8 @@ end module Endorsing_rights = struct type delegate_rights = { - delegate : Tezos_crypto.Signature.Public_key_hash.t; - consensus_key : Tezos_crypto.Signature.Public_key_hash.t; + delegate : Signature.Public_key_hash.t; + consensus_key : Signature.Public_key_hash.t; first_slot : Slot.t; endorsing_power : int; } @@ -3274,10 +3269,10 @@ module Endorsing_rights = struct (fun (delegate, first_slot, endorsing_power, consensus_key) -> {delegate; first_slot; endorsing_power; consensus_key}) (obj4 - (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "delegate" Signature.Public_key_hash.encoding) (req "first_slot" Slot.encoding) (req "endorsing_power" uint16) - (req "consensus_key" Tezos_crypto.Signature.Public_key_hash.encoding)) + (req "consensus_key" Signature.Public_key_hash.encoding)) let encoding = let open Data_encoding in @@ -3299,8 +3294,8 @@ module Endorsing_rights = struct type endorsing_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Tezos_crypto.Signature.Public_key_hash.t list; - consensus_keys : Tezos_crypto.Signature.Public_key_hash.t list; + delegates : Signature.Public_key_hash.t list; + consensus_keys : Signature.Public_key_hash.t list; } let endorsing_rights_query = @@ -3388,10 +3383,10 @@ module Endorsing_rights = struct | _, _ -> let is_requested p = List.exists - (Tezos_crypto.Signature.Public_key_hash.equal p.consensus_key) + (Signature.Public_key_hash.equal p.consensus_key) q.consensus_keys || List.exists - (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) + (Signature.Public_key_hash.equal p.delegate) q.delegates in List.filter_map @@ -3419,8 +3414,8 @@ end module Validators = struct type t = { level : Raw_level.t; - delegate : Tezos_crypto.Signature.Public_key_hash.t; - consensus_key : Tezos_crypto.Signature.public_key_hash; + delegate : Signature.Public_key_hash.t; + consensus_key : Signature.public_key_hash; slots : Slot.t list; } @@ -3433,9 +3428,9 @@ module Validators = struct {level; delegate; consensus_key; slots}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "delegate" Signature.Public_key_hash.encoding) (req "slots" (list Slot.encoding)) - (req "consensus_key" Tezos_crypto.Signature.Public_key_hash.encoding)) + (req "consensus_key" Signature.Public_key_hash.encoding)) module S = struct open Data_encoding @@ -3444,8 +3439,8 @@ module Validators = struct type validators_query = { levels : Raw_level.t list; - delegates : Tezos_crypto.Signature.Public_key_hash.t list; - consensus_keys : Tezos_crypto.Signature.Public_key_hash.t list; + delegates : Signature.Public_key_hash.t list; + consensus_keys : Signature.Public_key_hash.t list; } let validators_query = @@ -3500,7 +3495,7 @@ module Validators = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) + (Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights @@ -3511,7 +3506,7 @@ module Validators = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Tezos_crypto.Signature.Public_key_hash.equal p.consensus_key) + (Signature.Public_key_hash.equal p.consensus_key) delegates in List.filter is_requested rights diff --git a/src/proto_016_PtMumbai/lib_plugin/dune b/src/proto_016_PtMumbai/lib_plugin/dune index 697a74f3b7b8575978998957bd84cb1a585bb8b3..827678002475f0acbb27ba5d3021e08aa0c1a610 100644 --- a/src/proto_016_PtMumbai/lib_plugin/dune +++ b/src/proto_016_PtMumbai/lib_plugin/dune @@ -19,6 +19,13 @@ (documentation (package octez-protocol-016-PtMumbai-libs)) +(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"))) + (library (name tezos_protocol_plugin_016_PtMumbai_registerer) (public_name octez-protocol-016-PtMumbai-libs.plugin-registerer) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index ae786aad04fa1a4f52e6b06291eafbe3d9a31883..b93fc9d5f5ff7301898cd98d033ed4fbc1f2c571 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -359,10 +359,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash alice) + (Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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 = Commitment_hash.of_octez parent_commitment; @@ -456,7 +460,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Tezos_crypto.Signature.Of_V1.public_key_hash other; their_commitment = Commitment.to_octez their_commitment; our_commitment = Commitment.to_octez our_commitment; parent_commitment = Commitment_hash.to_octez parent_commitment; diff --git a/src/proto_017_PtNairob/lib_client/client_proto_context.ml b/src/proto_017_PtNairob/lib_client/client_proto_context.ml index aacce59cb12ea54edc64f8bc00a74a35431f3aeb..e2b49fd04a2cb5b98d7ec3dab594f9bf99214770 100644 --- a/src/proto_017_PtNairob/lib_client/client_proto_context.ml +++ b/src/proto_017_PtNairob/lib_client/client_proto_context.ml @@ -28,7 +28,6 @@ open Alpha_context open Protocol_client_context open Tezos_micheline open Client_proto_contracts -open Client_keys let get_balance (rpc : #rpc_context) ~chain ~block contract = Alpha_services.Contract.balance rpc (chain, block) contract @@ -278,7 +277,7 @@ let list_contract_labels cctxt ~chain ~block = (fun h -> (match (h : Contract.t) with | Implicit m -> ( - Public_key_hash.rev_find cctxt m >>=? function + Client_keys.Public_key_hash.rev_find cctxt m >>=? function | None -> return "" | Some nm -> ( Raw_contract_alias.find_opt cctxt nm >>=? function @@ -776,8 +775,8 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run Signature.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> - let pk = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk in + let pk = Tezos_crypto.Signature.Of_V1.public_key pk in + let sk = Tezos_crypto.Signature.Of_V1.secret_key sk in Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> (if encrypted then Tezos_signer_backends.Encrypted.prompt_twice_and_encrypt cctxt sk diff --git a/src/proto_017_PtNairob/lib_client/dune b/src/proto_017_PtNairob/lib_client/dune index 10f40f5333bfc5038bd552d54cabb1569aef075b..8151f63434a5b72b98ad3d47c2a10f6a99ea49e3 100644 --- a/src/proto_017_PtNairob/lib_client/dune +++ b/src/proto_017_PtNairob/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_017_PtNairob -open Tezos_protocol_017_PtNairob_parameters -open Tezos_smart_rollup_017_PtNairob)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_017_PtNairob/lib_client/mockup.ml b/src/proto_017_PtNairob/lib_client/mockup.ml index 9f7fe4af6034edff65b36445bd5c77cf301e4621..71b514d4f44ae9e5cb0d961c904417920c5f409b 100644 --- a/src/proto_017_PtNairob/lib_client/mockup.ml +++ b/src/proto_017_PtNairob/lib_client/mockup.ml @@ -97,8 +97,8 @@ module Parsed_account = struct (req "amount" Tez.encoding)) let to_bootstrap_account repr = - Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> - Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> + Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> + Client_keys.public_key pk_uri >>=? fun public_key -> let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_017_PtNairob/lib_client_commands/dune b/src/proto_017_PtNairob/lib_client_commands/dune index 37d2b9df602b37ac0d1455862519472dafd791e1..ad8ebfc541ee0401e04ddad99dfe4f8fc0f83a58 100644 --- a/src/proto_017_PtNairob/lib_client_commands/dune +++ b/src/proto_017_PtNairob/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_017_PtNairob) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_017_PtNairob_commands_registration) (public_name octez-protocol-017-PtNairob-libs.client.commands-registration) diff --git a/src/proto_017_PtNairob/lib_parameters/dune b/src/proto_017_PtNairob/lib_parameters/dune index 79653c75c3e499de9f52fea8e131496c2b7dee01..084f13d2bce536f3c7e123af8527f7a9f2cf129e 100644 --- a/src/proto_017_PtNairob/lib_parameters/dune +++ b/src/proto_017_PtNairob/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_017_PtNairob) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_017_PtNairob/lib_plugin/dune b/src/proto_017_PtNairob/lib_plugin/dune index feb3b8c63d26e4e739af9a32d773fa1e2693d8ca..f385fd162cb2c14bd79fbc614b8c9ad48bec4e23 100644 --- a/src/proto_017_PtNairob/lib_plugin/dune +++ b/src/proto_017_PtNairob/lib_plugin/dune @@ -19,6 +19,13 @@ (documentation (package octez-protocol-017-PtNairob-libs)) +(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"))) + (library (name tezos_protocol_plugin_017_PtNairob_registerer) (public_name octez-protocol-017-PtNairob-libs.plugin-registerer) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_017_PtNairob/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index e9c942bb236a9bfc5f65ab0966a494653788a81a..62fed566cd5986ea4d0f3e7d94ae1ac2eb39c083 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -361,10 +361,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash alice) + (Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -464,7 +468,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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 = Commitment_hash.of_octez parent_commitment; @@ -475,7 +479,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Tezos_crypto.Signature.Of_V1.public_key_hash other; their_commitment = Commitment.to_octez their_commitment; our_commitment = Commitment.to_octez our_commitment; parent_commitment = Commitment_hash.to_octez parent_commitment; diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_helpers.ml index ae7c7a096d7d09322be8a1534f7b3d13e36f04e8..978dca06cba759ca28eb140146468a2caff5c541 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_helpers.ml @@ -112,6 +112,9 @@ let maybe_recover_bond node_ctxt = match operating_pkh with | None -> return_unit | Some (Single operating_pkh) -> ( + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in let* staked_on_commitment = RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) @@ -214,7 +217,10 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -227,8 +233,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -252,7 +263,9 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | _, _ -> @@ -323,6 +336,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 process_l1_operation node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/dune b/src/proto_017_PtNairob/lib_sc_rollup_node/dune index 56df22649dafbeea5d8719645813fe3b56a1d92f..f12335716415da88eef2705bb3fa2b752bdd7bb4 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/dune +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/dune @@ -71,3 +71,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/layer1_helpers.ml index befcf4983b6c589fd85621b05c3e847abf04235c..cf87e038cf28c382d78b5e6092f1b49957647e04 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -238,7 +239,7 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist _cctxt ?block:_ _rollup_address : - Signature.public_key_hash trace option tzresult Lwt.t = + Tezos_crypto.Signature.public_key_hash trace option tzresult Lwt.t = return None let find_last_whitelist_update _cctxt _rollup_address = return_none @@ -260,6 +261,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Contract_services.balance cctxt (cctxt#chain, block) (Implicit pkh) in diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml index 11e0c3abc94e280b40281341b35c3ee3f992aac2..94fd0862fe389195f6730b41e00e327efef7aba7 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml @@ -303,6 +303,8 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -314,13 +316,15 @@ let timeout_reached node_ctxt ~self ~opponent = let open Sc_rollup.Game in match game_result with | Some (Loser {loser; _}) -> - let is_it_me = Signature.Public_key_hash.(self = loser) in + let is_it_me = Environment.Signature.Public_key_hash.(self = loser) in not is_it_me | _ -> false let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -334,6 +338,7 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt @@ -346,6 +351,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -355,5 +361,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) games diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_injector.ml index 7c29b325d0430a5bd5ff7009f70e0ba28bd69798..e3ec4112f7ce6fcd104dfbe03d75bfdc537af469 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_injector.ml @@ -50,6 +50,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -57,6 +58,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -89,6 +91,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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -259,7 +262,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -297,6 +300,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -480,6 +485,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Alpha_services.Contract.balance cctxt diff --git a/src/proto_018_Proxford/lib_client/client_proto_context.ml b/src/proto_018_Proxford/lib_client/client_proto_context.ml index 38dd59f19f6a695e676d2df43c9bf834adc1ef35..48aa9e3bd4707aae92ea5817cc11e924060ff3ed 100644 --- a/src/proto_018_Proxford/lib_client/client_proto_context.ml +++ b/src/proto_018_Proxford/lib_client/client_proto_context.ml @@ -29,7 +29,6 @@ open Alpha_context open Protocol_client_context open Tezos_micheline open Client_proto_contracts -open Client_keys let get_balance (rpc : #rpc_context) ~chain ~block contract = Alpha_services.Contract.balance rpc (chain, block) contract @@ -292,7 +291,7 @@ let list_contract_labels cctxt ~chain ~block = let* nm = match (h : Contract.t) with | Implicit m -> ( - let* nm_opt = Public_key_hash.rev_find cctxt m in + let* nm_opt = Client_keys.Public_key_hash.rev_find cctxt m in match nm_opt with | None -> return "" | Some nm -> ( @@ -812,8 +811,8 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run Signature.Ed25519.Public_key_hash.pp key.pkh) in - let pk = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk 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_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then diff --git a/src/proto_018_Proxford/lib_client/dune b/src/proto_018_Proxford/lib_client/dune index 4c43da1ffcad57805e810aab78ed80d8f569665c..d1c056a7b12a13c9a416068e32adff71a3195bac 100644 --- a/src/proto_018_Proxford/lib_client/dune +++ b/src/proto_018_Proxford/lib_client/dune @@ -39,3 +39,14 @@ -open Tezos_protocol_plugin_018_Proxford -open Tezos_protocol_018_Proxford_parameters -open Tezos_smart_rollup_018_Proxford)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_018_Proxford/lib_client/mockup.ml b/src/proto_018_Proxford/lib_client/mockup.ml index d9b140c6c6fc90c6252f093b14133e1fe48c65b0..a0b83ea939cd91a1f068b279cdfa541538966847 100644 --- a/src/proto_018_Proxford/lib_client/mockup.ml +++ b/src/proto_018_Proxford/lib_client/mockup.ml @@ -101,8 +101,8 @@ module Parsed_account = struct let to_bootstrap_account repr = let open Lwt_result_syntax in - let* pk_uri = Tezos_client_base.Client_keys.neuterize repr.sk_uri in - let* public_key = Tezos_client_base.Client_keys.public_key pk_uri in + let* pk_uri = Client_keys.neuterize repr.sk_uri in + let* public_key = Client_keys.public_key pk_uri in let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_018_Proxford/lib_client_commands/dune b/src/proto_018_Proxford/lib_client_commands/dune index 46e40828ab13c38f73c2961347817ee24dd42722..9897cb663f3e438d054baa6411f1ad3f3e459bed 100644 --- a/src/proto_018_Proxford/lib_client_commands/dune +++ b/src/proto_018_Proxford/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_018_Proxford) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_018_Proxford_commands_registration) (public_name octez-protocol-018-Proxford-libs.client.commands-registration) diff --git a/src/proto_018_Proxford/lib_parameters/dune b/src/proto_018_Proxford/lib_parameters/dune index c744259d91ca24461dc64b6da1ea43ffcec66b39..4d645024d982e0c3668f9a9aab56bef664e30d8b 100644 --- a/src/proto_018_Proxford/lib_parameters/dune +++ b/src/proto_018_Proxford/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_018_Proxford) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_018_Proxford/lib_plugin/dune b/src/proto_018_Proxford/lib_plugin/dune index 94eb290ea03b4ebeae0afecac759087ca154051c..63d7d4e6f0db4a2977e0d58ef7780d6b1f075246 100644 --- a/src/proto_018_Proxford/lib_plugin/dune +++ b/src/proto_018_Proxford/lib_plugin/dune @@ -19,6 +19,13 @@ (documentation (package octez-protocol-018-Proxford-libs)) +(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"))) + (library (name tezos_protocol_plugin_018_Proxford_registerer) (public_name octez-protocol-018-Proxford-libs.plugin-registerer) diff --git a/src/proto_018_Proxford/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_018_Proxford/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index 384f7c4ab64b0d91065c061cf63abc3bca7dd7e7..4e08f0790fa638d0a4509895f54947fe2c773a73 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -331,10 +331,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash alice) + (Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -434,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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; @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Tezos_crypto.Signature.Of_V1.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_018_Proxford/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_018_Proxford/lib_sc_rollup_node/daemon_helpers.ml index b48493b230ed7e174cdf7893b9c6345c4a6f431b..44f9d5bf57899c719ff5466e3ff8399888927df7 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/daemon_helpers.ml @@ -138,6 +138,9 @@ let maybe_recover_bond node_ctxt = match operating_pkh with | None -> return_unit | Some (Single operating_pkh) -> ( + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in let* staked_on_commitment = RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) @@ -239,7 +242,10 @@ let process_included_l1_operation (type kind) ~catching_up | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -252,8 +258,13 @@ let process_included_l1_operation (type kind) ~catching_up | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -277,7 +288,9 @@ let process_included_l1_operation (type kind) ~catching_up match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -320,6 +333,11 @@ let process_included_l1_operation (type kind) ~catching_up (* No need to check whitelist updates for historical data. *) then return_unit else + let whitelist_update = + List.map + Tezos_crypto.Signature.Of_V1.public_key_hash + whitelist_update + in let*? () = Node_context.check_op_in_whitelist_or_bailout_mode node_ctxt @@ -393,6 +411,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 process_l1_operation ~catching_up node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/dune b/src/proto_018_Proxford/lib_sc_rollup_node/dune index 7a73e0540009887bd9116a21fc3ebc1925b925c9..66bbc57edddd56a8a6cf3d0e3645e1a7733e35e7 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/dune +++ b/src/proto_018_Proxford/lib_sc_rollup_node/dune @@ -71,3 +71,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_018_Proxford/lib_sc_rollup_node/layer1_helpers.ml index e22943fc4503e931db0d21ba13184d48492f49c1..69fbaad853c199687c33f164ee8b115c8675574f 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -237,11 +238,18 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist cctxt ?block rollup_address = + let open Lwt_result_syntax in let block = match block with Some b -> `Hash (b, 0) | None -> `Head 0 in - Plugin.RPC.Sc_rollup.whitelist - (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) - (cctxt#chain, block) - rollup_address + let* whitelist = + Plugin.RPC.Sc_rollup.whitelist + (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) + (cctxt#chain, block) + rollup_address + in + return + @@ Option.map + (List.map Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash) + whitelist let find_last_whitelist_update cctxt rollup_address = let open Lwt_result_syntax in @@ -275,6 +283,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Contract_services.balance cctxt (cctxt#chain, block) (Implicit pkh) in diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/pvm_plugin.ml b/src/proto_018_Proxford/lib_sc_rollup_node/pvm_plugin.ml index 3f277c9185c05b9b4af610057a1001b152aa2ed6..15b639f3170df07342989f5a6c52c48b4d107685 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/pvm_plugin.ml @@ -150,7 +150,10 @@ let outbox_message_summary (output : Sc_rollup.output) = let summary = match output with | {message = Whitelist_update pkhs; _} -> - Outbox_message.Whitelist_update pkhs + Outbox_message.Whitelist_update + (Option.map + (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in Transaction_batch transactions diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml index a2d0162bffa30028f743d4e4665b2a07a2cf0c8d..46f3062ba168632c57c1592a6163dc2eab50c4be 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml @@ -329,6 +329,8 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -347,6 +349,9 @@ let timeout_reached node_ctxt ~self ~opponent = let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -360,6 +365,8 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in + let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt (cctxt#chain, `Head 0) rollup staker in @@ -368,6 +375,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -377,5 +385,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) games diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_injector.ml index 270f6db65a278c66eaec080a2e08808569d25065..9b20c3dbca6d02ce4d909cf3651ef0fa48b32aab 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_injector.ml @@ -47,6 +47,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -54,6 +55,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -85,6 +87,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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -259,7 +262,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -297,6 +300,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -484,6 +489,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Alpha_services.Contract.balance cctxt diff --git a/src/proto_019_PtParisB/lib_client/client_proto_context.ml b/src/proto_019_PtParisB/lib_client/client_proto_context.ml index 9a071294f15257dc72e26b60bdaa0f0936a18f14..d1e534db735c9e2e993f33eec8b64c6b965e8114 100644 --- a/src/proto_019_PtParisB/lib_client/client_proto_context.ml +++ b/src/proto_019_PtParisB/lib_client/client_proto_context.ml @@ -29,7 +29,6 @@ open Alpha_context open Protocol_client_context open Tezos_micheline open Client_proto_contracts -open Client_keys let get_balance (rpc : #rpc_context) ~chain ~block contract = Alpha_services.Contract.balance rpc (chain, block) contract @@ -292,7 +291,7 @@ let list_contract_labels cctxt ~chain ~block = let* nm = match (h : Contract.t) with | Implicit m -> ( - let* nm_opt = Public_key_hash.rev_find cctxt m in + let* nm_opt = Client_keys.Public_key_hash.rev_find cctxt m in match nm_opt with | None -> return "" | Some nm -> ( @@ -813,8 +812,8 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run Signature.Ed25519.Public_key_hash.pp key.pkh) in - let pk = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk 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_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then diff --git a/src/proto_019_PtParisB/lib_client/dune b/src/proto_019_PtParisB/lib_client/dune index 42cc4f14ed70a7c8606916ca5d0cb61ffc1f3da8..d7ae5a34a628031c6d77bb8c8e13edd427934626 100644 --- a/src/proto_019_PtParisB/lib_client/dune +++ b/src/proto_019_PtParisB/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_019_PtParisB -open Tezos_protocol_019_PtParisB_parameters -open Tezos_smart_rollup_019_PtParisB)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_019_PtParisB/lib_client/mockup.ml b/src/proto_019_PtParisB/lib_client/mockup.ml index d9b140c6c6fc90c6252f093b14133e1fe48c65b0..a0b83ea939cd91a1f068b279cdfa541538966847 100644 --- a/src/proto_019_PtParisB/lib_client/mockup.ml +++ b/src/proto_019_PtParisB/lib_client/mockup.ml @@ -101,8 +101,8 @@ module Parsed_account = struct let to_bootstrap_account repr = let open Lwt_result_syntax in - let* pk_uri = Tezos_client_base.Client_keys.neuterize repr.sk_uri in - let* public_key = Tezos_client_base.Client_keys.public_key pk_uri in + let* pk_uri = Client_keys.neuterize repr.sk_uri in + let* public_key = Client_keys.public_key pk_uri in let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_019_PtParisB/lib_client_commands/client_proto_context_commands.ml b/src/proto_019_PtParisB/lib_client_commands/client_proto_context_commands.ml index 52e8ca1f3552444a96b4f69b513a3f4aa690ee7b..f0cd573f46ea256473ea1186fa964ea7bf6ae85a 100644 --- a/src/proto_019_PtParisB/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_019_PtParisB/lib_client_commands/client_proto_context_commands.ml @@ -846,9 +846,7 @@ let commands_ro () = ~desc:"Get the frozen deposits limit of a delegate." no_options (prefixes ["get"; "deposits"; "limit"; "for"] - @@ Client_keys.Public_key_hash.source_param - ~name:"src" - ~desc:"source delegate" + @@ Public_key_hash.source_param ~name:"src" ~desc:"source delegate" @@ stop) (fun () delegate (cctxt : Protocol_client_context.full) -> let open Lwt_result_syntax in diff --git a/src/proto_019_PtParisB/lib_client_commands/dune b/src/proto_019_PtParisB/lib_client_commands/dune index ed33aaddf65c0c96fdb3ed07467508d24b542d4d..a87368b989d401515ffe8ba3463a2e9cea5fbf77 100644 --- a/src/proto_019_PtParisB/lib_client_commands/dune +++ b/src/proto_019_PtParisB/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_019_PtParisB) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_019_PtParisB_commands_registration) (public_name octez-protocol-019-PtParisB-libs.client.commands-registration) diff --git a/src/proto_019_PtParisB/lib_parameters/dune b/src/proto_019_PtParisB/lib_parameters/dune index 546667b6d904c77891a9d958d243573ce84df75c..16ee09d2ecb79454cdd32bdb8111dab739c8f39f 100644 --- a/src/proto_019_PtParisB/lib_parameters/dune +++ b/src/proto_019_PtParisB/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_019_PtParisB) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_019_PtParisB/lib_plugin/dune b/src/proto_019_PtParisB/lib_plugin/dune index f9f974d571fbb546c1d9f804bb7f75edec57ac01..379c5deee4d81cddead5e1b67836fb04e0993ed2 100644 --- a/src/proto_019_PtParisB/lib_plugin/dune +++ b/src/proto_019_PtParisB/lib_plugin/dune @@ -18,6 +18,13 @@ (documentation (package octez-protocol-019-PtParisB-libs)) +(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"))) + (library (name tezos_protocol_plugin_019_PtParisB_registerer) (public_name octez-protocol-019-PtParisB-libs.plugin-registerer) diff --git a/src/proto_019_PtParisB/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_019_PtParisB/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index 691e55a6ecc22a3113d2360a726c9bcf64bfb51d..bbe78eb63568feedd33d03c8892e05887f0f4010 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_019_PtParisB/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -331,10 +331,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Signature.V_latest.Of_V1.public_key_hash alice) + (Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -434,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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; @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Signature.Of_V1.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_019_PtParisB/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_019_PtParisB/lib_sc_rollup_node/daemon_helpers.ml index b0c37467a82a6ad374851478fb257eb58cfc3eb5..26d70bb463e265407866b31bbaacca95bfb2f27c 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_019_PtParisB/lib_sc_rollup_node/daemon_helpers.ml @@ -112,6 +112,9 @@ let maybe_recover_bond node_ctxt = match operating_pkh with | None -> return_unit | Some (Single operating_pkh) -> ( + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in let* staked_on_commitment = RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) @@ -213,7 +216,10 @@ let process_included_l1_operation (type kind) ~catching_up | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -226,8 +232,13 @@ let process_included_l1_operation (type kind) ~catching_up | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -251,7 +262,9 @@ let process_included_l1_operation (type kind) ~catching_up match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -294,6 +307,11 @@ let process_included_l1_operation (type kind) ~catching_up (* No need to check whitelist updates for historical data. *) then return_unit else + let whitelist_update = + List.map + Tezos_crypto.Signature.Of_V1.public_key_hash + whitelist_update + in let*? () = Node_context.check_op_in_whitelist_or_bailout_mode node_ctxt @@ -367,6 +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 process_l1_operation ~catching_up node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_019_PtParisB/lib_sc_rollup_node/dune b/src/proto_019_PtParisB/lib_sc_rollup_node/dune index d55baaf5b1055043ff33a55db9ff0aacd5fcae01..126a9107284105dc34d7ed45ef9900b51bc4a0b8 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_node/dune +++ b/src/proto_019_PtParisB/lib_sc_rollup_node/dune @@ -70,3 +70,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) diff --git a/src/proto_019_PtParisB/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_019_PtParisB/lib_sc_rollup_node/layer1_helpers.ml index e22943fc4503e931db0d21ba13184d48492f49c1..69fbaad853c199687c33f164ee8b115c8675574f 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_019_PtParisB/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -237,11 +238,18 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist cctxt ?block rollup_address = + let open Lwt_result_syntax in let block = match block with Some b -> `Hash (b, 0) | None -> `Head 0 in - Plugin.RPC.Sc_rollup.whitelist - (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) - (cctxt#chain, block) - rollup_address + let* whitelist = + Plugin.RPC.Sc_rollup.whitelist + (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) + (cctxt#chain, block) + rollup_address + in + return + @@ Option.map + (List.map Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash) + whitelist let find_last_whitelist_update cctxt rollup_address = let open Lwt_result_syntax in @@ -275,6 +283,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Contract_services.balance cctxt (cctxt#chain, block) (Implicit pkh) in diff --git a/src/proto_019_PtParisB/lib_sc_rollup_node/pvm_plugin.ml b/src/proto_019_PtParisB/lib_sc_rollup_node/pvm_plugin.ml index 8d0a4fd39c0210dc6733c96cbb8968a748355068..ebf34f1de5929518871e3c58b3a3c9f62678148d 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_019_PtParisB/lib_sc_rollup_node/pvm_plugin.ml @@ -155,7 +155,10 @@ let outbox_message_summary (output : Sc_rollup.output) = let summary = match output with | {message = Whitelist_update pkhs; _} -> - Outbox_message.Whitelist_update pkhs + Outbox_message.Whitelist_update + (Option.map + (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in Transaction_batch transactions diff --git a/src/proto_019_PtParisB/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_019_PtParisB/lib_sc_rollup_node/refutation_game_helpers.ml index 53211c554a80f64ddec5dee8a77705de5bfb0ec2..364f4cf4786db5209d38f2ccd343aa2073c47fc9 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_019_PtParisB/lib_sc_rollup_node/refutation_game_helpers.ml @@ -350,6 +350,9 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -368,6 +371,9 @@ let timeout_reached node_ctxt ~self ~opponent = let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -381,6 +387,8 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in + let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt (cctxt#chain, `Head 0) rollup staker in @@ -389,6 +397,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -398,5 +407,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) games diff --git a/src/proto_019_PtParisB/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_019_PtParisB/lib_sc_rollup_node/sc_rollup_injector.ml index 707060162d8a608195c564c70b67644c47175431..d108ced97550a4b74b942c27554ddcb7a0a6c9a3 100644 --- a/src/proto_019_PtParisB/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_019_PtParisB/lib_sc_rollup_node/sc_rollup_injector.ml @@ -47,6 +47,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -54,6 +55,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -102,6 +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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -282,7 +285,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -320,6 +323,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -503,6 +508,8 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in + let+ balance = Protocol.Alpha_services.Contract.balance cctxt diff --git a/src/proto_020_PsParisC/lib_client/client_proto_context.ml b/src/proto_020_PsParisC/lib_client/client_proto_context.ml index 9a071294f15257dc72e26b60bdaa0f0936a18f14..b83e2a8bee5a8ba20e7e8d257c93e150161e6475 100644 --- a/src/proto_020_PsParisC/lib_client/client_proto_context.ml +++ b/src/proto_020_PsParisC/lib_client/client_proto_context.ml @@ -813,8 +813,8 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run Signature.Ed25519.Public_key_hash.pp key.pkh) in - let pk = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk 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_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then diff --git a/src/proto_020_PsParisC/lib_client/dune b/src/proto_020_PsParisC/lib_client/dune index a38af0a026ab145012316d7263c680039d30ddb5..880f420f3f471c87d1c98e344553e2a363850d33 100644 --- a/src/proto_020_PsParisC/lib_client/dune +++ b/src/proto_020_PsParisC/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_020_PsParisC -open Tezos_protocol_020_PsParisC_parameters -open Tezos_smart_rollup_020_PsParisC)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_020_PsParisC/lib_client/mockup.ml b/src/proto_020_PsParisC/lib_client/mockup.ml index d9b140c6c6fc90c6252f093b14133e1fe48c65b0..a0b83ea939cd91a1f068b279cdfa541538966847 100644 --- a/src/proto_020_PsParisC/lib_client/mockup.ml +++ b/src/proto_020_PsParisC/lib_client/mockup.ml @@ -101,8 +101,8 @@ module Parsed_account = struct let to_bootstrap_account repr = let open Lwt_result_syntax in - let* pk_uri = Tezos_client_base.Client_keys.neuterize repr.sk_uri in - let* public_key = Tezos_client_base.Client_keys.public_key pk_uri in + let* pk_uri = Client_keys.neuterize repr.sk_uri in + let* public_key = Client_keys.public_key pk_uri in let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_020_PsParisC/lib_client_commands/dune b/src/proto_020_PsParisC/lib_client_commands/dune index 5a66524c3be13c12c1bd37b36d3e41bf6a4e9112..8fda293b9f418c7d21967af3245e5e1ff773dff3 100644 --- a/src/proto_020_PsParisC/lib_client_commands/dune +++ b/src/proto_020_PsParisC/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_020_PsParisC) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_020_PsParisC_commands_registration) (public_name octez-protocol-020-PsParisC-libs.client.commands-registration) diff --git a/src/proto_020_PsParisC/lib_parameters/dune b/src/proto_020_PsParisC/lib_parameters/dune index 6f286ddcfc212166a6ad39e41623c002e1402b8e..944c599acf9cdccabdc26a05455223424aec009e 100644 --- a/src/proto_020_PsParisC/lib_parameters/dune +++ b/src/proto_020_PsParisC/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_020_PsParisC) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_020_PsParisC/lib_plugin/dune b/src/proto_020_PsParisC/lib_plugin/dune index 3adf033c524f2694be18ae3201f795e831290078..4111fad4ab52fba9074068a3cb646f964444add3 100644 --- a/src/proto_020_PsParisC/lib_plugin/dune +++ b/src/proto_020_PsParisC/lib_plugin/dune @@ -18,6 +18,13 @@ (documentation (package octez-protocol-020-PsParisC-libs)) +(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"))) + (library (name tezos_protocol_plugin_020_PsParisC_registerer) (public_name octez-protocol-020-PsParisC-libs.plugin-registerer) diff --git a/src/proto_020_PsParisC/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_020_PsParisC/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index 691e55a6ecc22a3113d2360a726c9bcf64bfb51d..bbe78eb63568feedd33d03c8892e05887f0f4010 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_020_PsParisC/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -331,10 +331,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Signature.V_latest.Of_V1.public_key_hash alice) + (Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -434,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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; @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Signature.Of_V1.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_020_PsParisC/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_020_PsParisC/lib_sc_rollup_node/daemon_helpers.ml index b0c37467a82a6ad374851478fb257eb58cfc3eb5..26d70bb463e265407866b31bbaacca95bfb2f27c 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_020_PsParisC/lib_sc_rollup_node/daemon_helpers.ml @@ -112,6 +112,9 @@ let maybe_recover_bond node_ctxt = match operating_pkh with | None -> return_unit | Some (Single operating_pkh) -> ( + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in let* staked_on_commitment = RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) @@ -213,7 +216,10 @@ let process_included_l1_operation (type kind) ~catching_up | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -226,8 +232,13 @@ let process_included_l1_operation (type kind) ~catching_up | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -251,7 +262,9 @@ let process_included_l1_operation (type kind) ~catching_up match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -294,6 +307,11 @@ let process_included_l1_operation (type kind) ~catching_up (* No need to check whitelist updates for historical data. *) then return_unit else + let whitelist_update = + List.map + Tezos_crypto.Signature.Of_V1.public_key_hash + whitelist_update + in let*? () = Node_context.check_op_in_whitelist_or_bailout_mode node_ctxt @@ -367,6 +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 process_l1_operation ~catching_up node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_020_PsParisC/lib_sc_rollup_node/dune b/src/proto_020_PsParisC/lib_sc_rollup_node/dune index 483bd42a7bd876cb9eaab6c1242e8ab4435e203b..6ab5832a816f210c27c4ff8c0d8b112dc816ab89 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_node/dune +++ b/src/proto_020_PsParisC/lib_sc_rollup_node/dune @@ -70,3 +70,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) diff --git a/src/proto_020_PsParisC/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_020_PsParisC/lib_sc_rollup_node/layer1_helpers.ml index e22943fc4503e931db0d21ba13184d48492f49c1..be34d0530273bc66c97dab912cd06445987e1846 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_020_PsParisC/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -237,11 +238,18 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist cctxt ?block rollup_address = + let open Lwt_result_syntax in let block = match block with Some b -> `Hash (b, 0) | None -> `Head 0 in - Plugin.RPC.Sc_rollup.whitelist - (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) - (cctxt#chain, block) - rollup_address + let* whitelist = + Plugin.RPC.Sc_rollup.whitelist + (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) + (cctxt#chain, block) + rollup_address + in + return + @@ Option.map + (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + whitelist let find_last_whitelist_update cctxt rollup_address = let open Lwt_result_syntax in @@ -275,6 +283,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Contract_services.balance cctxt (cctxt#chain, block) (Implicit pkh) in diff --git a/src/proto_020_PsParisC/lib_sc_rollup_node/pvm_plugin.ml b/src/proto_020_PsParisC/lib_sc_rollup_node/pvm_plugin.ml index 8d0a4fd39c0210dc6733c96cbb8968a748355068..ebf34f1de5929518871e3c58b3a3c9f62678148d 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_020_PsParisC/lib_sc_rollup_node/pvm_plugin.ml @@ -155,7 +155,10 @@ let outbox_message_summary (output : Sc_rollup.output) = let summary = match output with | {message = Whitelist_update pkhs; _} -> - Outbox_message.Whitelist_update pkhs + Outbox_message.Whitelist_update + (Option.map + (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in Transaction_batch transactions diff --git a/src/proto_020_PsParisC/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_020_PsParisC/lib_sc_rollup_node/refutation_game_helpers.ml index 53211c554a80f64ddec5dee8a77705de5bfb0ec2..28308b40e2b7b8bc48be48833400d6b9a2b77de5 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_020_PsParisC/lib_sc_rollup_node/refutation_game_helpers.ml @@ -350,6 +350,8 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -368,6 +370,8 @@ let timeout_reached node_ctxt ~self ~opponent = let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -381,6 +385,7 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt (cctxt#chain, `Head 0) rollup staker in @@ -389,6 +394,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -398,5 +404,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) games diff --git a/src/proto_020_PsParisC/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_020_PsParisC/lib_sc_rollup_node/sc_rollup_injector.ml index cb48470e1c64a55ffa18f4f3811a0229b170df79..24f6cb015bbaf6d3c4cd6f237e387a0db4b3a15a 100644 --- a/src/proto_020_PsParisC/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_020_PsParisC/lib_sc_rollup_node/sc_rollup_injector.ml @@ -47,6 +47,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -54,6 +55,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -102,6 +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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -282,7 +285,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -320,6 +323,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -503,6 +508,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Protocol.Alpha_services.Contract.balance cctxt diff --git a/src/proto_021_PsQuebec/lib_benchmark/dune b/src/proto_021_PsQuebec/lib_benchmark/dune index a1ee30f958c38246f2d39661858c5298e3ee8747..16063dab53634efa9ffcfb525bed7215bc53a5e0 100644 --- a/src/proto_021_PsQuebec/lib_benchmark/dune +++ b/src/proto_021_PsQuebec/lib_benchmark/dune @@ -31,3 +31,14 @@ -open Tezos_protocol_021_PsQuebec -open Tezos_021_PsQuebec_test_helpers) (private_modules kernel rules state_space)) + +(rule + (targets crypto_samplers.mli) + (action + (write-file + %{targets} + "include module type of Tezos_benchmark.Crypto_samplers.V1"))) + +(rule + (targets crypto_samplers.ml) + (action (write-file %{targets} "include Tezos_benchmark.Crypto_samplers.V1"))) diff --git a/src/proto_021_PsQuebec/lib_benchmark/michelson_samplers.ml b/src/proto_021_PsQuebec/lib_benchmark/michelson_samplers.ml index a872dc08ca635d4353ec7d75fda68edd99908cd2..469df205b7201d9c596142888726d11641afd606 100644 --- a/src/proto_021_PsQuebec/lib_benchmark/michelson_samplers.ml +++ b/src/proto_021_PsQuebec/lib_benchmark/michelson_samplers.ml @@ -604,7 +604,9 @@ module Make Data_encoding.Binary.of_string_exn Script_chain_id.encoding string let signature rng_state = - Script_signature.make (Michelson_base.signature rng_state) + Script_signature.make + (Tezos_crypto.Signature.V1.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 = let open Script_typed_ir in @@ -618,8 +620,8 @@ module Make | String_t -> Michelson_base.string | Bytes_t -> Michelson_base.bytes | Mutez_t -> Michelson_base.tez - | Key_hash_t -> Crypto_samplers.pkh - | Key_t -> Crypto_samplers.pk + | Key_hash_t -> fun pkh -> Crypto_samplers.pkh pkh + | Key_t -> fun pk -> Crypto_samplers.pk pk | Timestamp_t -> Michelson_base.timestamp | Bool_t -> Base_samplers.uniform_bool | Address_t -> address diff --git a/src/proto_021_PsQuebec/lib_benchmarks_proto/dune b/src/proto_021_PsQuebec/lib_benchmarks_proto/dune index 0a97dbe348530b5aca3d817dc32062b0fcc49a9d..d8ea8515999d2672e2240b0b4e3ec554227d8266 100644 --- a/src/proto_021_PsQuebec/lib_benchmarks_proto/dune +++ b/src/proto_021_PsQuebec/lib_benchmarks_proto/dune @@ -42,3 +42,10 @@ -open Tezos_021_PsQuebec_test_helpers -open Tezos_client_021_PsQuebec -open Tezos_protocol_plugin_021_PsQuebec)) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_client/client_proto_context.ml b/src/proto_021_PsQuebec/lib_client/client_proto_context.ml index 1d3f63ee6480db96554e13fc71ad4a27ad4bb70a..ed36f6ab00c2c3c5a267f68d7b091e379c586126 100644 --- a/src/proto_021_PsQuebec/lib_client/client_proto_context.ml +++ b/src/proto_021_PsQuebec/lib_client/client_proto_context.ml @@ -814,8 +814,8 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run Signature.Ed25519.Public_key_hash.pp key.pkh) in - let pk = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk 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_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then diff --git a/src/proto_021_PsQuebec/lib_client/dune b/src/proto_021_PsQuebec/lib_client/dune index 6f7c8d0f1c1753c49839f916b3259aaf330bd92b..761ef6a9a5e0eb67d7861033738761bdacd8b4b2 100644 --- a/src/proto_021_PsQuebec/lib_client/dune +++ b/src/proto_021_PsQuebec/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_021_PsQuebec -open Tezos_protocol_021_PsQuebec_parameters -open Tezos_smart_rollup_021_PsQuebec)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_client/mockup.ml b/src/proto_021_PsQuebec/lib_client/mockup.ml index d9b140c6c6fc90c6252f093b14133e1fe48c65b0..a0b83ea939cd91a1f068b279cdfa541538966847 100644 --- a/src/proto_021_PsQuebec/lib_client/mockup.ml +++ b/src/proto_021_PsQuebec/lib_client/mockup.ml @@ -101,8 +101,8 @@ module Parsed_account = struct let to_bootstrap_account repr = let open Lwt_result_syntax in - let* pk_uri = Tezos_client_base.Client_keys.neuterize repr.sk_uri in - let* public_key = Tezos_client_base.Client_keys.public_key pk_uri in + let* pk_uri = Client_keys.neuterize repr.sk_uri in + let* public_key = Client_keys.public_key pk_uri in let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_021_PsQuebec/lib_client_commands/dune b/src/proto_021_PsQuebec/lib_client_commands/dune index e08e14fd6d940c4f706154569c3e895929f32153..516dbb13792ae62515ccca791e0dced22e31200f 100644 --- a/src/proto_021_PsQuebec/lib_client_commands/dune +++ b/src/proto_021_PsQuebec/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_021_PsQuebec) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_021_PsQuebec_commands_registration) (public_name octez-protocol-021-PsQuebec-libs.client.commands-registration) diff --git a/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml b/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml index 00fe7bcfed3425e21c0ca8dc66d4313e26ec50ae..a6c81852ed776945d6533b043d3c59b5c8108685 100644 --- a/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml +++ b/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml @@ -163,9 +163,13 @@ module Plugin = struct | Receipt (Operation_metadata operation_metadata) -> ( match operation_metadata.contents with | Single_result (Attestation_result result) -> + let delegate = + Tezos_crypto.Signature.Of_V1.public_key_hash + result.delegate + in Some ( tb_slot, - Some result.delegate, + Some delegate, packed_operation, dal_attestation ) | _ -> @@ -187,8 +191,9 @@ module Plugin = struct in List.fold_left (fun acc ({delegate; indexes} : Plugin.RPC.Dal.S.shards_assignment) -> - Signature.Public_key_hash.Map.add delegate indexes acc) - Signature.Public_key_hash.Map.empty + let delegate = Tezos_crypto.Signature.Of_V1.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 let dal_attestation (block : block_info) = @@ -206,6 +211,7 @@ module Plugin = struct let is_delegate ctxt ~pkh = let open Lwt_result_syntax in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in (* We just want to know whether is a delegate. We call 'context/delegates//deactivated' just because it should be cheaper diff --git a/src/proto_021_PsQuebec/lib_dal/dune b/src/proto_021_PsQuebec/lib_dal/dune index 2bc3c492d48d88d66b35e32dcb9ce6b9a8309e6a..e274b93973413ea5e6d5928cf8b8c62dcfe6636a 100644 --- a/src/proto_021_PsQuebec/lib_dal/dune +++ b/src/proto_021_PsQuebec/lib_dal/dune @@ -36,3 +36,10 @@ -open Tezos_embedded_protocol_021_PsQuebec -open Tezos_layer2_utils_021_PsQuebec -open Tezos_protocol_021_PsQuebec)) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml b/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml index be73d489d5ddf1ee5dadee2f4128cd1a85628975..5ac7a664c1159e4f98f3984e5c7be65b31cef883 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml @@ -1003,7 +1003,8 @@ let register_dal_profiles cctxt dal_node_rpc_ctxt delegates = let attesters = Tezos_dal_node_services.Operator_profile.attesters operator_profile in - if Signature.Public_key_hash.Set.is_empty attesters then warn () + if Tezos_crypto.Signature.Public_key_hash.Set.is_empty attesters then + warn () else Lwt.return_unit in Node_rpc.register_dal_profiles dal_ctxt delegates diff --git a/src/proto_021_PsQuebec/lib_delegate/dune b/src/proto_021_PsQuebec/lib_delegate/dune index c76706c728b07770d8b6a35b0bc605d860b52415..264a9f9b1bec53a00493fd1daefc6f3ced2e0b1a 100644 --- a/src/proto_021_PsQuebec/lib_delegate/dune +++ b/src/proto_021_PsQuebec/lib_delegate/dune @@ -53,6 +53,17 @@ -open Tezos_crypto_dal) (modules (:standard \ Baking_commands Baking_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_baking_021_PsQuebec_commands) (public_name octez-protocol-021-PsQuebec-libs.baking-commands) diff --git a/src/proto_021_PsQuebec/lib_delegate/node_rpc.ml b/src/proto_021_PsQuebec/lib_delegate/node_rpc.ml index cac8a3cdb7627269429e88f4955d8e36816bacf8..ec23febc0f2e3cd545978fb7409c7fb4f54e3957 100644 --- a/src/proto_021_PsQuebec/lib_delegate/node_rpc.ml +++ b/src/proto_021_PsQuebec/lib_delegate/node_rpc.ml @@ -380,7 +380,7 @@ let get_attestable_slots dal_node_rpc_ctxt pkh ~attested_level = Tezos_rpc.Context.make_call Tezos_dal_node_services.Services.get_attestable_slots dal_node_rpc_ctxt - (((), pkh), attested_level) + (((), Tezos_crypto.Signature.Of_V1.public_key_hash pkh), attested_level) () () @@ -404,7 +404,11 @@ let get_dal_profiles dal_node_rpc_ctxt = let register_dal_profiles dal_node_rpc_ctxt delegates = let profiles = Tezos_dal_node_services.Operator_profile.make - ~attesters:(List.map (fun k -> k.public_key_hash) delegates) + ~attesters: + (List.map + (fun k -> + Tezos_crypto.Signature.Of_V1.public_key_hash k.public_key_hash) + delegates) () in Tezos_rpc.Context.make_call diff --git a/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/dune b/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/dune index 096d34793e2abd90ca6991975dbaed75dc989c04..cbec739b4309887eaeaf82cb0fab27ad40b3c7b6 100644 --- a/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/dune +++ b/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/dune @@ -31,3 +31,7 @@ -open Tezos_protocol_021_PsQuebec_parameters -open Tenderbrute_021_PsQuebec -open Tezt_core)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) diff --git a/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 96a99d358e05205961bff52dd8d96618854bf14c..1a91de65db3a486761167164176a905500281cf4 100644 --- a/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_021_PsQuebec/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -967,7 +967,6 @@ let baker_process ~(delegates : Baking_state.consensus_key list) ~base_dir List.iter_es (fun ({alias; public_key; public_key_hash; secret_key_uri} : Baking_state.consensus_key) -> - let open Tezos_client_base in let name = alias |> WithExceptions.Option.get ~loc:__LOC__ in let* public_key_uri = Client_keys.neuterize secret_key_uri in Client_keys.register_key @@ -1299,8 +1298,7 @@ let make_baking_delegate let run ?(config = default_config) bakers_spec = let open Lwt_result_syntax in - Tezos_client_base.Client_keys.register_signer - (module Tezos_signer_backends.Unencrypted) ; + Client_keys.register_signer (module Tezos_signer_backends.Unencrypted) ; let total_accounts = List.fold_left (fun acc (n, _) -> acc + n) 0 bakers_spec in diff --git a/src/proto_021_PsQuebec/lib_delegate/test/tenderbrute/lib/dune b/src/proto_021_PsQuebec/lib_delegate/test/tenderbrute/lib/dune index 52340d461b94fdee8a02ae89ab029953f3b12a5c..5b97211d170fb2822bf06f528bd8b0e2ca04c582 100644 --- a/src/proto_021_PsQuebec/lib_delegate/test/tenderbrute/lib/dune +++ b/src/proto_021_PsQuebec/lib_delegate/test/tenderbrute/lib/dune @@ -19,3 +19,10 @@ -open Tezos_protocol_021_PsQuebec -open Tezos_client_base -open Tezos_client_021_PsQuebec)) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_injector/dune b/src/proto_021_PsQuebec/lib_injector/dune index 964f0d4a20026d4ab88171a7f4ca8c41373b1324..caa994288e29c89c8c18141bf8c6c0ee2f00d4d1 100644 --- a/src/proto_021_PsQuebec/lib_injector/dune +++ b/src/proto_021_PsQuebec/lib_injector/dune @@ -21,3 +21,14 @@ -open Tezos_client_021_PsQuebec -open Tezos_client_base -open Tezos_protocol_plugin_021_PsQuebec)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_injector/injector_plugin.ml b/src/proto_021_PsQuebec/lib_injector/injector_plugin.ml index 3b3134a43a372b9e8cedd75d1f54f4ca8aa0ae04..c7f19d73a63b6d8d15e413d1e1a46226a66a7deb 100644 --- a/src/proto_021_PsQuebec/lib_injector/injector_plugin.ml +++ b/src/proto_021_PsQuebec/lib_injector/injector_plugin.ml @@ -232,7 +232,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -270,6 +270,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -444,7 +446,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in - + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_021_PsQuebec/lib_parameters/dune b/src/proto_021_PsQuebec/lib_parameters/dune index a89ce37f7cf8bc09755e739fdb0baab0dfdd1944..8e522ecf12f97fefecbd830e664663787083498f 100644 --- a/src/proto_021_PsQuebec/lib_parameters/dune +++ b/src/proto_021_PsQuebec/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_021_PsQuebec) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_021_PsQuebec/lib_plugin/dune b/src/proto_021_PsQuebec/lib_plugin/dune index 02c40b41a79e2eff913b7a416adfa859e15e95d7..365cb65412b9ed2757a6e3b0fc557723f926fa73 100644 --- a/src/proto_021_PsQuebec/lib_plugin/dune +++ b/src/proto_021_PsQuebec/lib_plugin/dune @@ -18,6 +18,13 @@ (documentation (package octez-protocol-021-PsQuebec-libs)) +(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"))) + (library (name tezos_protocol_plugin_021_PsQuebec_registerer) (public_name octez-protocol-021-PsQuebec-libs.plugin-registerer) diff --git a/src/proto_021_PsQuebec/lib_plugin/mempool.ml b/src/proto_021_PsQuebec/lib_plugin/mempool.ml index bc4dacf05049a93e0bab909b50ac4b5eae89b2cf..016000801ff3f2ea53e1bb612ce2cc9bcef16b38 100644 --- a/src/proto_021_PsQuebec/lib_plugin/mempool.ml +++ b/src/proto_021_PsQuebec/lib_plugin/mempool.ml @@ -798,6 +798,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 match contents with | Single (Failing_noop _) -> return_nil | Single (Preattestation consensus_content) @@ -808,7 +809,7 @@ let sources_from_operation ctxt in match slot_owner with | Ok (_ctxt, {delegate; consensus_pkh; consensus_pk = _}) -> - return [delegate; consensus_pkh] + return @@ map_pkh_env [delegate; consensus_pkh] | Error _ -> return_nil) | Single (Seed_nonce_revelation _) | Single (Double_preattestation_evidence _) @@ -818,10 +819,10 @@ let sources_from_operation ctxt | Single (Vdf_revelation _) -> return_nil | Single (Proposals {source; _}) | Single (Ballot {source; _}) -> - return [source] - | Single (Drain_delegate {delegate; _}) -> return [delegate] - | Single (Manager_operation {source; _}) -> return [source] - | Cons (Manager_operation {source; _}, _) -> return [source] + return @@ map_pkh_env [source] + | Single (Drain_delegate {delegate; _}) -> return @@ map_pkh_env [delegate] + | Single (Manager_operation {source; _}) -> return @@ map_pkh_env [source] + | Cons (Manager_operation {source; _}, _) -> return @@ map_pkh_env [source] module Internal_for_tests = struct let default_config_with_clock_drift clock_drift = diff --git a/src/proto_021_PsQuebec/lib_plugin/mempool.mli b/src/proto_021_PsQuebec/lib_plugin/mempool.mli index 2690bb5797d959da67127efbe877d1c4a4021add..80f9f004fcf471c22f7125b090e75c0a9e6904a4 100644 --- a/src/proto_021_PsQuebec/lib_plugin/mempool.mli +++ b/src/proto_021_PsQuebec/lib_plugin/mempool.mli @@ -192,7 +192,7 @@ val get_context : val sources_from_operation : ctxt -> Protocol.Alpha_context.packed_operation -> - Signature.public_key_hash list Lwt.t + Tezos_crypto.Signature.public_key_hash list Lwt.t module Internal_for_tests : sig open Protocol.Alpha_context diff --git a/src/proto_021_PsQuebec/lib_protocol/test/helpers/dune b/src/proto_021_PsQuebec/lib_protocol/test/helpers/dune index f945cee62547de0af7c621e842bb17335e264047..9f062a78655e2e27e061547a9f7c20d0daa2f762 100644 --- a/src/proto_021_PsQuebec/lib_protocol/test/helpers/dune +++ b/src/proto_021_PsQuebec/lib_protocol/test/helpers/dune @@ -37,3 +37,10 @@ -open Tezos_shell_services -open Tezos_crypto_dal -open Tezos_smart_rollup_021_PsQuebec)) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_021_PsQuebec/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index 1e6bd1433ed56301bbf8d16dab40e416bd16110c..987aeab8097e797047087d9d43eced893032bf9b 100644 --- a/src/proto_021_PsQuebec/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_021_PsQuebec/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -96,8 +96,7 @@ let dont_show _fmt _ = () let size = {Tezos_benchmark.Base_samplers.min = 4; max = 32} -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 10 let algo = `Default diff --git a/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_comparison.ml b/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_comparison.ml index 823ea7c35f1dbef3c84c39e4d7291107e586fc93..765a8a9cf06acb6af1f24e9b3184d8bdedb1b5e9 100644 --- a/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_comparison.ml +++ b/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_comparison.ml @@ -113,8 +113,7 @@ module Parameters = struct } end -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 1000 let algo = `Default diff --git a/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_roundtrip.ml b/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_roundtrip.ml index 03c38787ca5d4715e88b0460cda4cfc59675cacf..7c4f399588fbbc266c81b472ce34cc4eb8d2604f 100644 --- a/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_roundtrip.ml +++ b/src/proto_021_PsQuebec/lib_protocol/test/pbt/test_script_roundtrip.ml @@ -46,8 +46,7 @@ module Parameters = struct } end -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 1000 let algo = `Default diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_021_PsQuebec/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index 691e55a6ecc22a3113d2360a726c9bcf64bfb51d..bbe78eb63568feedd33d03c8892e05887f0f4010 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -331,10 +331,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Signature.V_latest.Of_V1.public_key_hash alice) + (Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -434,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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; @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Signature.Of_V1.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_021_PsQuebec/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_021_PsQuebec/lib_sc_rollup_node/daemon_helpers.ml index b0c37467a82a6ad374851478fb257eb58cfc3eb5..4c9adf86a501bd8d187d8381836d29df1888c02d 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/daemon_helpers.ml @@ -113,6 +113,9 @@ let maybe_recover_bond node_ctxt = | None -> return_unit | Some (Single operating_pkh) -> ( let* staked_on_commitment = + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) (node_ctxt.cctxt#chain, `Head 0) @@ -213,7 +216,10 @@ let process_included_l1_operation (type kind) ~catching_up | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -226,8 +232,13 @@ let process_included_l1_operation (type kind) ~catching_up | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -251,7 +262,9 @@ let process_included_l1_operation (type kind) ~catching_up match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -294,6 +307,11 @@ let process_included_l1_operation (type kind) ~catching_up (* No need to check whitelist updates for historical data. *) then return_unit else + let whitelist_update = + List.map + Tezos_crypto.Signature.Of_V1.public_key_hash + whitelist_update + in let*? () = Node_context.check_op_in_whitelist_or_bailout_mode node_ctxt @@ -367,6 +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 process_l1_operation ~catching_up node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_node/dune b/src/proto_021_PsQuebec/lib_sc_rollup_node/dune index 8892955ef334a4c3d52f1b9e9b255373b3272f92..1c4c6b4d119d0bff927899fdb1d8b1c977f02ed6 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/dune +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/dune @@ -73,3 +73,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_021_PsQuebec/lib_sc_rollup_node/layer1_helpers.ml index 1f4ef7b394fa06a9635fe3467b47829b6f90256e..51a92aaf69715c35fc74b42b6eb49e9d914c5067 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -237,11 +238,18 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist cctxt ?block rollup_address = + let open Lwt_result_syntax in let block = match block with Some b -> `Hash (b, 0) | None -> `Head 0 in - Plugin.RPC.Sc_rollup.whitelist - (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) - (cctxt#chain, block) - rollup_address + let* whitelist = + Plugin.RPC.Sc_rollup.whitelist + (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) + (cctxt#chain, block) + rollup_address + in + return + @@ Option.map + (List.map Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash) + whitelist let find_last_whitelist_update cctxt rollup_address = let open Lwt_result_syntax in @@ -275,6 +283,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_node/pvm_plugin.ml b/src/proto_021_PsQuebec/lib_sc_rollup_node/pvm_plugin.ml index 8d0a4fd39c0210dc6733c96cbb8968a748355068..56c66fb722302a047301c9f5919597a9f3f2fca4 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/pvm_plugin.ml @@ -155,7 +155,10 @@ let outbox_message_summary (output : Sc_rollup.output) = let summary = match output with | {message = Whitelist_update pkhs; _} -> - Outbox_message.Whitelist_update pkhs + Outbox_message.Whitelist_update + (Option.map + (List.map Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash) + pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in Transaction_batch transactions diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_021_PsQuebec/lib_sc_rollup_node/refutation_game_helpers.ml index 53211c554a80f64ddec5dee8a77705de5bfb0ec2..f6c8785ccabcbff2f0d09696392f0e2fd11e043c 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/refutation_game_helpers.ml @@ -350,6 +350,9 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -361,13 +364,16 @@ let timeout_reached node_ctxt ~self ~opponent = let open Sc_rollup.Game in match game_result with | Some (Loser {loser; _}) -> - let is_it_me = Signature.Public_key_hash.(self = loser) in + let is_it_me = Environment.Signature.Public_key_hash.(self = loser) in not is_it_me | _ -> false let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -381,6 +387,7 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt (cctxt#chain, `Head 0) rollup staker in @@ -389,6 +396,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -398,5 +406,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) games diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_021_PsQuebec/lib_sc_rollup_node/sc_rollup_injector.ml index 2cb82691c2dca64a24452c4bb1c363c7ef7c11fd..d1cbba9872e92a427804312c5cd5d167bc3815a3 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/sc_rollup_injector.ml @@ -47,6 +47,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -54,6 +55,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -102,6 +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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -282,7 +285,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -320,6 +323,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -496,6 +501,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_021_PsQuebec/lib_sc_rollup_node/test/test_octez_conversions.ml b/src/proto_021_PsQuebec/lib_sc_rollup_node/test/test_octez_conversions.ml index 791be285b83dc79358c4c9ade75058e3254b4127..ba6e0c7c646a79093f658c6a3e78e63fb3c5b9e4 100644 --- a/src/proto_021_PsQuebec/lib_sc_rollup_node/test/test_octez_conversions.ml +++ b/src/proto_021_PsQuebec/lib_sc_rollup_node/test/test_octez_conversions.ml @@ -118,12 +118,13 @@ let random_algo ~rng_state : Signature.algo = | 3 -> Bls | _ -> assert false -let gen_algo = QCheck2.Gen.oneofl [Signature.Ed25519; Secp256k1; P256; Bls] +let gen_algo = + QCheck2.Gen.oneofl [Tezos_crypto.Signature.Ed25519; Secp256k1; P256; Bls] let gen_pkh = let open QCheck2.Gen in let+ algo = gen_algo in - let pkh, _pk, _sk = Signature.generate_key ~algo () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key ~algo () in pkh let gen_stakers = diff --git a/src/proto_alpha/lib_benchmark/dune b/src/proto_alpha/lib_benchmark/dune index b6472e4a2318d7cf47e49784925a231bac2c8d7d..64a0fb6e287d510458511be20327b44740b3d7a1 100644 --- a/src/proto_alpha/lib_benchmark/dune +++ b/src/proto_alpha/lib_benchmark/dune @@ -31,3 +31,14 @@ -open Tezos_protocol_alpha -open Tezos_alpha_test_helpers) (private_modules kernel rules state_space)) + +(rule + (targets crypto_samplers.mli) + (action + (write-file + %{targets} + "include module type of Tezos_benchmark.Crypto_samplers.V1"))) + +(rule + (targets crypto_samplers.ml) + (action (write-file %{targets} "include Tezos_benchmark.Crypto_samplers.V1"))) diff --git a/src/proto_alpha/lib_benchmark/michelson_samplers.ml b/src/proto_alpha/lib_benchmark/michelson_samplers.ml index a872dc08ca635d4353ec7d75fda68edd99908cd2..469df205b7201d9c596142888726d11641afd606 100644 --- a/src/proto_alpha/lib_benchmark/michelson_samplers.ml +++ b/src/proto_alpha/lib_benchmark/michelson_samplers.ml @@ -604,7 +604,9 @@ module Make Data_encoding.Binary.of_string_exn Script_chain_id.encoding string let signature rng_state = - Script_signature.make (Michelson_base.signature rng_state) + Script_signature.make + (Tezos_crypto.Signature.V1.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 = let open Script_typed_ir in @@ -618,8 +620,8 @@ module Make | String_t -> Michelson_base.string | Bytes_t -> Michelson_base.bytes | Mutez_t -> Michelson_base.tez - | Key_hash_t -> Crypto_samplers.pkh - | Key_t -> Crypto_samplers.pk + | Key_hash_t -> fun pkh -> Crypto_samplers.pkh pkh + | Key_t -> fun pk -> Crypto_samplers.pk pk | Timestamp_t -> Michelson_base.timestamp | Bool_t -> Base_samplers.uniform_bool | Address_t -> address diff --git a/src/proto_alpha/lib_benchmarks_proto/dune b/src/proto_alpha/lib_benchmarks_proto/dune index 8abe61305a1b544dbf0c8e587173fb32d2e0079a..1f7fd4dd2cd4dd1c167a17dfab7fe1a230a37765 100644 --- a/src/proto_alpha/lib_benchmarks_proto/dune +++ b/src/proto_alpha/lib_benchmarks_proto/dune @@ -42,3 +42,10 @@ -open Tezos_alpha_test_helpers -open Tezos_client_alpha -open Tezos_protocol_plugin_alpha)) + +(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"))) diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 0d89a4117bc4911aacf952ea0f55dbd79d9a6217..bb4c725235188dcc998f77317cbb42785ee43bcf 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 = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk 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_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 afd1b37eca203175d1349a2a2b7951228367d4e0..b609baa80d6211c1518be1c27e6ad281bcf00572 100644 --- a/src/proto_alpha/lib_client/dune +++ b/src/proto_alpha/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_alpha -open Tezos_protocol_alpha_parameters -open Tezos_smart_rollup_alpha)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index e6e8d1c951dcf586a8781fe00e3e08020a444fca..958500a2ecb1ae13afff3e578225d65746ae574c 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -101,8 +101,8 @@ module Parsed_account = struct let to_bootstrap_account repr = let open Lwt_result_syntax in - let* pk_uri = Tezos_client_base.Client_keys.neuterize repr.sk_uri in - let* public_key = Tezos_client_base.Client_keys.public_key pk_uri in + let* pk_uri = Client_keys.neuterize repr.sk_uri in + let* public_key = Client_keys.public_key pk_uri in let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_alpha/lib_client_commands/dune b/src/proto_alpha/lib_client_commands/dune index 726fbd533057baccdf1c98aa7d78a2a518934f78..5f6379ca6229e27e62694b9a6e059a54bca5ee33 100644 --- a/src/proto_alpha/lib_client_commands/dune +++ b/src/proto_alpha/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_alpha) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_alpha_commands_registration) (public_name octez-protocol-alpha-libs.client.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 f132674c363ae1c9cec727774f026505ed2e62a2..311cdbaafe2748c843dcf31d8ff52cafba9f5cdd 100644 --- a/src/proto_alpha/lib_dal/dal_plugin_registration.ml +++ b/src/proto_alpha/lib_dal/dal_plugin_registration.ml @@ -202,9 +202,13 @@ module Plugin = struct | Receipt (Operation_metadata operation_metadata) -> ( match operation_metadata.contents with | Single_result (Attestation_result result) -> + let delegate = + Tezos_crypto.Signature.Of_V1.public_key_hash + result.delegate + in Some ( tb_slot, - Some result.delegate, + Some delegate, packed_operation, dal_attestation ) | _ -> @@ -226,8 +230,9 @@ module Plugin = struct in List.fold_left (fun acc ({delegate; indexes} : Plugin.RPC.Dal.S.shards_assignment) -> - Signature.Public_key_hash.Map.add delegate indexes acc) - Signature.Public_key_hash.Map.empty + let delegate = Tezos_crypto.Signature.Of_V1.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 let dal_attestation (block : block_info) = @@ -247,6 +252,7 @@ module Plugin = struct let is_delegate ctxt ~pkh = let open Lwt_result_syntax in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in (* We just want to know whether is a delegate. We call 'context/delegates//deactivated' just because it should be cheaper diff --git a/src/proto_alpha/lib_dal/dune b/src/proto_alpha/lib_dal/dune index f261457a9a5e2fe983528d9f8d0cf763173e8b64..93d502ab07d83c9313e76df8b3435d1baf888600 100644 --- a/src/proto_alpha/lib_dal/dune +++ b/src/proto_alpha/lib_dal/dune @@ -36,3 +36,10 @@ -open Tezos_embedded_protocol_alpha -open Tezos_layer2_utils_alpha -open Tezos_protocol_alpha)) + +(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"))) diff --git a/src/proto_alpha/lib_delegate/baking_scheduling.ml b/src/proto_alpha/lib_delegate/baking_scheduling.ml index d0da8c2c64dbe994a3513ce0bd4334c9f65bdde7..64fc10c6f096f151828c4e6bc7c0e19f24efff77 100644 --- a/src/proto_alpha/lib_delegate/baking_scheduling.ml +++ b/src/proto_alpha/lib_delegate/baking_scheduling.ml @@ -995,7 +995,8 @@ let register_dal_profiles cctxt dal_node_rpc_ctxt delegates = let attesters = Tezos_dal_node_services.Operator_profile.attesters operator_profile in - if Signature.Public_key_hash.Set.is_empty attesters then warn () + if Tezos_crypto.Signature.Public_key_hash.Set.is_empty attesters then + warn () else Lwt.return_unit in Node_rpc.register_dal_profiles dal_ctxt delegates diff --git a/src/proto_alpha/lib_delegate/dune b/src/proto_alpha/lib_delegate/dune index e9f78e780b1d40aab157ed33edf3b0819ceb7816..1f629c21bad35e1931de64537219419127f0f00d 100644 --- a/src/proto_alpha/lib_delegate/dune +++ b/src/proto_alpha/lib_delegate/dune @@ -53,6 +53,17 @@ -open Tezos_crypto_dal) (modules (:standard \ Baking_commands Baking_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_baking_alpha_commands) (public_name octez-protocol-alpha-libs.baking-commands) diff --git a/src/proto_alpha/lib_delegate/node_rpc.ml b/src/proto_alpha/lib_delegate/node_rpc.ml index ebad32dd2f150a093542a9abb8403289c7e5dd2a..3beb0f29b9426ae09ee95d809675269ff0149c4d 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 - (((), pkh), attested_level) + (((), Tezos_crypto.Signature.Of_V1.public_key_hash pkh), attested_level) () () @@ -407,7 +407,9 @@ let register_dal_profiles dal_node_rpc_ctxt delegates = Tezos_dal_node_services.Operator_profile.make ~attesters: (List.map - (fun k -> Consensus_key_id.to_pkh k.Consensus_key.id) + (fun k -> + Tezos_crypto.Signature.Of_V1.public_key_hash + @@ Consensus_key_id.to_pkh k.Consensus_key.id) 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 5000219b5b02cb186e1ee754e1cc241ce1b26d46..585a8363dd33deb261c68a1e88ab456cdf59b05f 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/dune +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/dune @@ -31,3 +31,7 @@ -open Tezos_protocol_alpha_parameters -open Tenderbrute_alpha -open Tezt_core)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 1aade797bce2de018bdd6d0f7381d7f102619375..eace277cae55d652ea4239e918fca3aaa76915f2 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -967,7 +967,6 @@ let baker_process ~(delegates : Baking_state.Consensus_key.t list) ~base_dir List.iter_es (fun ({alias; public_key; id; secret_key_uri} : Baking_state.Consensus_key.t) -> - let open Tezos_client_base in let name = alias |> WithExceptions.Option.get ~loc:__LOC__ in let* public_key_uri = Client_keys.neuterize secret_key_uri in let pkh = Baking_state.Consensus_key_id.to_pkh id in @@ -1298,8 +1297,7 @@ let make_baking_delegate let run ?(config = default_config) bakers_spec = let open Lwt_result_syntax in - Tezos_client_base.Client_keys.register_signer - (module Tezos_signer_backends.Unencrypted) ; + Client_keys.register_signer (module Tezos_signer_backends.Unencrypted) ; let total_accounts = List.fold_left (fun acc (n, _) -> acc + n) 0 bakers_spec in diff --git a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune index 2c5f1970f6f34fb7021e92dac6f0193798ffbc22..1754a62aeb67fb498f29ac80bb149c00afcf18cf 100644 --- a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune +++ b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/dune @@ -19,3 +19,10 @@ -open Tezos_protocol_alpha -open Tezos_client_base -open Tezos_client_alpha)) + +(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"))) diff --git a/src/proto_alpha/lib_injector/dune b/src/proto_alpha/lib_injector/dune index 5d09216ad2eee5a1f9715dba216af1e510b7cc86..b25f426e01871379a23eef63c0d411e66910b784 100644 --- a/src/proto_alpha/lib_injector/dune +++ b/src/proto_alpha/lib_injector/dune @@ -21,3 +21,14 @@ -open Tezos_client_alpha -open Tezos_client_base -open Tezos_protocol_plugin_alpha)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_alpha/lib_injector/injector_plugin.ml b/src/proto_alpha/lib_injector/injector_plugin.ml index f9afe4f07348a7bc2ff5f9c0594821af6fe6ff71..1818a39f818798a08327e1131ff3f7aac7b9f428 100644 --- a/src/proto_alpha/lib_injector/injector_plugin.ml +++ b/src/proto_alpha/lib_injector/injector_plugin.ml @@ -234,7 +234,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -272,6 +272,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -446,7 +448,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in - + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_alpha/lib_parameters/dune b/src/proto_alpha/lib_parameters/dune index c3a03c7f82db3777c1c50e600e123f79e11d1aca..d16d636f906c3792985d674267459d4147dee06f 100644 --- a/src/proto_alpha/lib_parameters/dune +++ b/src/proto_alpha/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_alpha) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_alpha/lib_plugin/dune b/src/proto_alpha/lib_plugin/dune index 5997d8940477b96d6eb9f87e971f91e5562f643b..eaba3e58437ef30948c00f89396b4677d38306ab 100644 --- a/src/proto_alpha/lib_plugin/dune +++ b/src/proto_alpha/lib_plugin/dune @@ -18,6 +18,13 @@ (documentation (package octez-protocol-alpha-libs)) +(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"))) + (library (name tezos_protocol_plugin_alpha_registerer) (public_name octez-protocol-alpha-libs.plugin-registerer) diff --git a/src/proto_alpha/lib_plugin/mempool.ml b/src/proto_alpha/lib_plugin/mempool.ml index 84df0640e5cad23188b46950eaaac36879d4e039..ec10e413c976cd8684626802ae1d99c2b924869b 100644 --- a/src/proto_alpha/lib_plugin/mempool.ml +++ b/src/proto_alpha/lib_plugin/mempool.ml @@ -804,6 +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 match contents with | Single (Failing_noop _) -> return_nil | Single (Preattestation consensus_content) @@ -814,7 +815,7 @@ let sources_from_operation ctxt in match slot_owner with | Ok (_ctxt, {delegate; consensus_pkh; consensus_pk = _}) -> - return [delegate; consensus_pkh] + return @@ map_pkh_env [delegate; consensus_pkh] | Error _ -> return_nil) | Single (Attestations_aggregate {consensus_content; committee}) -> let level = Level.from_raw ctxt consensus_content.level in @@ -829,7 +830,7 @@ let sources_from_operation ctxt [] committee in - return sources + return @@ map_pkh_env sources | Single (Seed_nonce_revelation _) | Single (Double_preattestation_evidence _) | Single (Double_attestation_evidence _) @@ -839,10 +840,10 @@ let sources_from_operation ctxt | Single (Vdf_revelation _) -> return_nil | Single (Proposals {source; _}) | Single (Ballot {source; _}) -> - return [source] - | Single (Drain_delegate {delegate; _}) -> return [delegate] - | Single (Manager_operation {source; _}) -> return [source] - | Cons (Manager_operation {source; _}, _) -> return [source] + return @@ map_pkh_env [source] + | Single (Drain_delegate {delegate; _}) -> return @@ map_pkh_env [delegate] + | Single (Manager_operation {source; _}) -> return @@ map_pkh_env [source] + | Cons (Manager_operation {source; _}, _) -> return @@ map_pkh_env [source] module Internal_for_tests = struct let default_config_with_clock_drift clock_drift = diff --git a/src/proto_alpha/lib_plugin/mempool.mli b/src/proto_alpha/lib_plugin/mempool.mli index 2690bb5797d959da67127efbe877d1c4a4021add..80f9f004fcf471c22f7125b090e75c0a9e6904a4 100644 --- a/src/proto_alpha/lib_plugin/mempool.mli +++ b/src/proto_alpha/lib_plugin/mempool.mli @@ -192,7 +192,7 @@ val get_context : val sources_from_operation : ctxt -> Protocol.Alpha_context.packed_operation -> - Signature.public_key_hash list Lwt.t + Tezos_crypto.Signature.public_key_hash list Lwt.t module Internal_for_tests : sig open Protocol.Alpha_context diff --git a/src/proto_alpha/lib_protocol/test/helpers/dune b/src/proto_alpha/lib_protocol/test/helpers/dune index 961f4e9869653d65ed6c5505b7175f00b0f3955b..9a67c96dbb94ad70efd7587845143c57ab15f110 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dune +++ b/src/proto_alpha/lib_protocol/test/helpers/dune @@ -37,3 +37,10 @@ -open Tezos_shell_services -open Tezos_crypto_dal -open Tezos_smart_rollup_alpha)) + +(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"))) diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index e0407beba755faebe8bf9b7ba49a7378a651e6c1..58526c51706779e04fe7fdac5cfe5b7adc663b8a 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -96,8 +96,7 @@ let dont_show _fmt _ = () let size = {Tezos_benchmark.Base_samplers.min = 4; max = 32} -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 10 let algo = `Default diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml b/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml index 0b30815b89feda06677763142ca1afdb88a2315e..cc1e96f6d472bd3ad1acf44b1fc2695011301c14 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml @@ -113,8 +113,7 @@ module Parameters = struct } end -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 1000 let algo = `Default diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_script_roundtrip.ml b/src/proto_alpha/lib_protocol/test/pbt/test_script_roundtrip.ml index b680d4f73f74b8efd04e557ad4829707dc60be94..18b2e6484cafc1f410225053b927c282c143a802 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_script_roundtrip.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_script_roundtrip.ml @@ -46,8 +46,7 @@ module Parameters = struct } end -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 1000 let algo = `Default 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 691e55a6ecc22a3113d2360a726c9bcf64bfb51d..c3ef8ca13b04b86d0bbe584d8a8a1b980350a6b2 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 @@ -331,10 +331,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Signature.Of_V1.public_key_hash alice) + (Signature.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -434,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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; @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Signature.Of_V1.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 3f781d3f663e016e819450e07abbadb1fdfa3918..fe5dd0cb5c0443557268aba60509def0dccefabe 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml @@ -112,6 +112,9 @@ let maybe_recover_bond node_ctxt = match operating_pkh with | None -> return_unit | Some (Single operating_pkh) -> ( + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in let* staked_on_commitment = RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) @@ -213,7 +216,10 @@ let process_included_l1_operation (type kind) ~catching_up | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -226,8 +232,13 @@ let process_included_l1_operation (type kind) ~catching_up | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -251,7 +262,9 @@ let process_included_l1_operation (type kind) ~catching_up match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -294,6 +307,11 @@ let process_included_l1_operation (type kind) ~catching_up (* No need to check whitelist updates for historical data. *) then return_unit else + let whitelist_update = + List.map + Tezos_crypto.Signature.Of_V1.public_key_hash + whitelist_update + in let*? () = Node_context.check_op_in_whitelist_or_bailout_mode node_ctxt @@ -367,6 +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 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 45b355b7e3710f3bfab113de3dcee9ac7869d2fe..556fb5d8266278d2d22ccbe7766c56f21fcfe21a 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dune +++ b/src/proto_alpha/lib_sc_rollup_node/dune @@ -73,3 +73,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) 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 1f4ef7b394fa06a9635fe3467b47829b6f90256e..3fce20a4ca9d16dd9c486b53841a1e438610c66c 100644 --- a/src/proto_alpha/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -237,11 +238,18 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist cctxt ?block rollup_address = + let open Lwt_result_syntax in let block = match block with Some b -> `Hash (b, 0) | None -> `Head 0 in - Plugin.RPC.Sc_rollup.whitelist - (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) - (cctxt#chain, block) - rollup_address + let* whitelist = + Plugin.RPC.Sc_rollup.whitelist + (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) + (cctxt#chain, block) + rollup_address + in + return + @@ Option.map + (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + whitelist let find_last_whitelist_update cctxt rollup_address = let open Lwt_result_syntax in @@ -275,6 +283,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt 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 66be48a5013aa85c8a0860bf1bd5b18767aaf8bf..a257b8e548821f2159fd8c0750800553a5ca981e 100644 --- a/src/proto_alpha/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_alpha/lib_sc_rollup_node/pvm_plugin.ml @@ -155,7 +155,10 @@ let outbox_message_summary (output : Sc_rollup.output) = let summary = match output with | {message = Whitelist_update pkhs; _} -> - Outbox_message.Whitelist_update pkhs + Outbox_message.Whitelist_update + (Option.map + (List.map Tezos_crypto.Signature.Of_V1.public_key_hash) + pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in Transaction_batch transactions 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 60b64f51c4770b7c2c4c72598b86d42748bc9f5f..8378d7ace8944ba13e6dbb2b06383848bbfe62b9 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 @@ -357,6 +357,8 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -368,13 +370,15 @@ let timeout_reached node_ctxt ~self ~opponent = let open Sc_rollup.Game in match game_result with | Some (Loser {loser; _}) -> - let is_it_me = Signature.Public_key_hash.(self = loser) in + let is_it_me = Environment.Signature.Public_key_hash.(self = loser) in not is_it_me | _ -> false let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -388,6 +392,7 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt (cctxt#chain, `Head 0) rollup staker in @@ -396,6 +401,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -405,5 +411,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) 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 53337355fb6f26271065033179d55381b461411e..3a393a0517b864e2d47f04407cc4619b8b708775 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 @@ -47,6 +47,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -54,6 +55,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -102,6 +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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -284,7 +287,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -322,6 +325,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -498,6 +503,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt 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 a52144ba564ca21b97d38b2572e810cfcbd18e4a..8e8b1de49f4d057330e486c72705061d30c5e6e4 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 @@ -118,12 +118,13 @@ let random_algo ~rng_state : Signature.algo = | 3 -> Bls | _ -> assert false -let gen_algo = QCheck2.Gen.oneofl [Signature.Ed25519; Secp256k1; P256; Bls] +let gen_algo = + QCheck2.Gen.oneofl [Tezos_crypto.Signature.Ed25519; Secp256k1; P256; Bls] let gen_pkh = let open QCheck2.Gen in let+ algo = gen_algo in - let pkh, _pk, _sk = Signature.generate_key ~algo () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key ~algo () in pkh let gen_stakers = @@ -266,6 +267,9 @@ let gen_slot_history = ( Raw_level.of_int32_exn lvl, List.map (fun (h, publisher, status) -> + let publisher = + Signature.Of_V_latest.get_public_key_hash_exn publisher + in ( Sc_rollup_proto_types.Dal.Slot_header.of_octez ~number_of_slots h, Contract.Implicit publisher, status )) @@ -297,6 +301,9 @@ let gen_slot_history_cache = ( Raw_level.of_int32_exn lvl, List.map (fun (h, publisher, status) -> + let publisher = + Signature.Of_V_latest.get_public_key_hash_exn publisher + in ( Sc_rollup_proto_types.Dal.Slot_header.of_octez ~number_of_slots h, Contract.Implicit publisher, status )) diff --git a/src/proto_next/lib_benchmark/dune b/src/proto_next/lib_benchmark/dune index a207795e8dcb8c2457bc82d9967f8906503640a9..f66c68e87797429700e48092e0ac7f1d8742806e 100644 --- a/src/proto_next/lib_benchmark/dune +++ b/src/proto_next/lib_benchmark/dune @@ -31,3 +31,14 @@ -open Tezos_protocol_next -open Tezos_next_test_helpers) (private_modules kernel rules state_space)) + +(rule + (targets crypto_samplers.mli) + (action + (write-file + %{targets} + "include module type of Tezos_benchmark.Crypto_samplers.V1"))) + +(rule + (targets crypto_samplers.ml) + (action (write-file %{targets} "include Tezos_benchmark.Crypto_samplers.V1"))) diff --git a/src/proto_next/lib_benchmark/michelson_samplers.ml b/src/proto_next/lib_benchmark/michelson_samplers.ml index a872dc08ca635d4353ec7d75fda68edd99908cd2..469df205b7201d9c596142888726d11641afd606 100644 --- a/src/proto_next/lib_benchmark/michelson_samplers.ml +++ b/src/proto_next/lib_benchmark/michelson_samplers.ml @@ -604,7 +604,9 @@ module Make Data_encoding.Binary.of_string_exn Script_chain_id.encoding string let signature rng_state = - Script_signature.make (Michelson_base.signature rng_state) + Script_signature.make + (Tezos_crypto.Signature.V1.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 = let open Script_typed_ir in @@ -618,8 +620,8 @@ module Make | String_t -> Michelson_base.string | Bytes_t -> Michelson_base.bytes | Mutez_t -> Michelson_base.tez - | Key_hash_t -> Crypto_samplers.pkh - | Key_t -> Crypto_samplers.pk + | Key_hash_t -> fun pkh -> Crypto_samplers.pkh pkh + | Key_t -> fun pk -> Crypto_samplers.pk pk | Timestamp_t -> Michelson_base.timestamp | Bool_t -> Base_samplers.uniform_bool | Address_t -> address diff --git a/src/proto_next/lib_benchmarks_proto/dune b/src/proto_next/lib_benchmarks_proto/dune index 9ae1b83e063647351aa1e79dadf14dedc0a34438..12f19f8c36cb8701cd008991da03a72537edb4f4 100644 --- a/src/proto_next/lib_benchmarks_proto/dune +++ b/src/proto_next/lib_benchmarks_proto/dune @@ -42,3 +42,10 @@ -open Tezos_next_test_helpers -open Tezos_client_next -open Tezos_protocol_plugin_next)) + +(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"))) diff --git a/src/proto_next/lib_client/client_proto_context.ml b/src/proto_next/lib_client/client_proto_context.ml index 0d89a4117bc4911aacf952ea0f55dbd79d9a6217..bb4c725235188dcc998f77317cbb42785ee43bcf 100644 --- a/src/proto_next/lib_client/client_proto_context.ml +++ b/src/proto_next/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 = Signature.Of_V1.public_key pk in - let sk = Signature.Of_V1.secret_key sk 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_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then diff --git a/src/proto_next/lib_client/dune b/src/proto_next/lib_client/dune index 7b12f8fbc7e6e110e0e8ade385606d97f391134f..fc5b2b58855ffa15f86833160bda4249e02262a8 100644 --- a/src/proto_next/lib_client/dune +++ b/src/proto_next/lib_client/dune @@ -38,3 +38,14 @@ -open Tezos_protocol_plugin_next -open Tezos_protocol_next_parameters -open Tezos_smart_rollup_next)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_next/lib_client/mockup.ml b/src/proto_next/lib_client/mockup.ml index e6e8d1c951dcf586a8781fe00e3e08020a444fca..958500a2ecb1ae13afff3e578225d65746ae574c 100644 --- a/src/proto_next/lib_client/mockup.ml +++ b/src/proto_next/lib_client/mockup.ml @@ -101,8 +101,8 @@ module Parsed_account = struct let to_bootstrap_account repr = let open Lwt_result_syntax in - let* pk_uri = Tezos_client_base.Client_keys.neuterize repr.sk_uri in - let* public_key = Tezos_client_base.Client_keys.public_key pk_uri in + let* pk_uri = Client_keys.neuterize repr.sk_uri in + let* public_key = Client_keys.public_key pk_uri in let public_key_hash = Signature.Public_key.hash public_key in return Parameters. diff --git a/src/proto_next/lib_client_commands/dune b/src/proto_next/lib_client_commands/dune index 330cba49fc188ec8c94ef7c353b3603e72d561b3..515ae070e15b560844d68ef640f621595e43ea06 100644 --- a/src/proto_next/lib_client_commands/dune +++ b/src/proto_next/lib_client_commands/dune @@ -38,6 +38,17 @@ -open Tezos_protocol_plugin_next) (modules (:standard \ alpha_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_client_next_commands_registration) (public_name octez-protocol-next-libs.client.commands-registration) diff --git a/src/proto_next/lib_dal/dal_plugin_registration.ml b/src/proto_next/lib_dal/dal_plugin_registration.ml index f132674c363ae1c9cec727774f026505ed2e62a2..311cdbaafe2748c843dcf31d8ff52cafba9f5cdd 100644 --- a/src/proto_next/lib_dal/dal_plugin_registration.ml +++ b/src/proto_next/lib_dal/dal_plugin_registration.ml @@ -202,9 +202,13 @@ module Plugin = struct | Receipt (Operation_metadata operation_metadata) -> ( match operation_metadata.contents with | Single_result (Attestation_result result) -> + let delegate = + Tezos_crypto.Signature.Of_V1.public_key_hash + result.delegate + in Some ( tb_slot, - Some result.delegate, + Some delegate, packed_operation, dal_attestation ) | _ -> @@ -226,8 +230,9 @@ module Plugin = struct in List.fold_left (fun acc ({delegate; indexes} : Plugin.RPC.Dal.S.shards_assignment) -> - Signature.Public_key_hash.Map.add delegate indexes acc) - Signature.Public_key_hash.Map.empty + let delegate = Tezos_crypto.Signature.Of_V1.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 let dal_attestation (block : block_info) = @@ -247,6 +252,7 @@ module Plugin = struct let is_delegate ctxt ~pkh = let open Lwt_result_syntax in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in (* We just want to know whether is a delegate. We call 'context/delegates//deactivated' just because it should be cheaper diff --git a/src/proto_next/lib_dal/dune b/src/proto_next/lib_dal/dune index 10261ebc80e6470c8ac1acd44b645ae1f5dbb72e..04cae27df5eb603dacad00d763f99f30b5034158 100644 --- a/src/proto_next/lib_dal/dune +++ b/src/proto_next/lib_dal/dune @@ -36,3 +36,10 @@ -open Tezos_embedded_protocol_next -open Tezos_layer2_utils_next -open Tezos_protocol_next)) + +(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"))) diff --git a/src/proto_next/lib_delegate/baking_scheduling.ml b/src/proto_next/lib_delegate/baking_scheduling.ml index d0da8c2c64dbe994a3513ce0bd4334c9f65bdde7..64fc10c6f096f151828c4e6bc7c0e19f24efff77 100644 --- a/src/proto_next/lib_delegate/baking_scheduling.ml +++ b/src/proto_next/lib_delegate/baking_scheduling.ml @@ -995,7 +995,8 @@ let register_dal_profiles cctxt dal_node_rpc_ctxt delegates = let attesters = Tezos_dal_node_services.Operator_profile.attesters operator_profile in - if Signature.Public_key_hash.Set.is_empty attesters then warn () + if Tezos_crypto.Signature.Public_key_hash.Set.is_empty attesters then + warn () else Lwt.return_unit in Node_rpc.register_dal_profiles dal_ctxt delegates diff --git a/src/proto_next/lib_delegate/dune b/src/proto_next/lib_delegate/dune index c0acf2db3e85886ee289bbb287ac3ae1c2051e35..5c151d3aa36ecc46334f2f07f7773b7baff7609d 100644 --- a/src/proto_next/lib_delegate/dune +++ b/src/proto_next/lib_delegate/dune @@ -53,6 +53,17 @@ -open Tezos_crypto_dal) (modules (:standard \ Baking_commands Baking_commands_registration))) +(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"))) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + (library (name tezos_baking_next_commands) (public_name octez-protocol-next-libs.baking-commands) diff --git a/src/proto_next/lib_delegate/node_rpc.ml b/src/proto_next/lib_delegate/node_rpc.ml index ebad32dd2f150a093542a9abb8403289c7e5dd2a..3beb0f29b9426ae09ee95d809675269ff0149c4d 100644 --- a/src/proto_next/lib_delegate/node_rpc.ml +++ b/src/proto_next/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 - (((), pkh), attested_level) + (((), Tezos_crypto.Signature.Of_V1.public_key_hash pkh), attested_level) () () @@ -407,7 +407,9 @@ let register_dal_profiles dal_node_rpc_ctxt delegates = Tezos_dal_node_services.Operator_profile.make ~attesters: (List.map - (fun k -> Consensus_key_id.to_pkh k.Consensus_key.id) + (fun k -> + Tezos_crypto.Signature.Of_V1.public_key_hash + @@ Consensus_key_id.to_pkh k.Consensus_key.id) delegates) () in diff --git a/src/proto_next/lib_delegate/test/mockup_simulator/dune b/src/proto_next/lib_delegate/test/mockup_simulator/dune index c6fb7d4b07564f25cbea0c11c9a4a8f8700f7c54..54585b38f59a1d301afa58ed6b962e4a230405c5 100644 --- a/src/proto_next/lib_delegate/test/mockup_simulator/dune +++ b/src/proto_next/lib_delegate/test/mockup_simulator/dune @@ -31,3 +31,7 @@ -open Tezos_protocol_next_parameters -open Tenderbrute_next -open Tezt_core)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) diff --git a/src/proto_next/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_next/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 1aade797bce2de018bdd6d0f7381d7f102619375..eace277cae55d652ea4239e918fca3aaa76915f2 100644 --- a/src/proto_next/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_next/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -967,7 +967,6 @@ let baker_process ~(delegates : Baking_state.Consensus_key.t list) ~base_dir List.iter_es (fun ({alias; public_key; id; secret_key_uri} : Baking_state.Consensus_key.t) -> - let open Tezos_client_base in let name = alias |> WithExceptions.Option.get ~loc:__LOC__ in let* public_key_uri = Client_keys.neuterize secret_key_uri in let pkh = Baking_state.Consensus_key_id.to_pkh id in @@ -1298,8 +1297,7 @@ let make_baking_delegate let run ?(config = default_config) bakers_spec = let open Lwt_result_syntax in - Tezos_client_base.Client_keys.register_signer - (module Tezos_signer_backends.Unencrypted) ; + Client_keys.register_signer (module Tezos_signer_backends.Unencrypted) ; let total_accounts = List.fold_left (fun acc (n, _) -> acc + n) 0 bakers_spec in diff --git a/src/proto_next/lib_delegate/test/tenderbrute/lib/dune b/src/proto_next/lib_delegate/test/tenderbrute/lib/dune index b87d464d23fe2149f2f2f4122f427536048b41c6..041a19c241fd68e9dbfa91826da2f06e4de114ae 100644 --- a/src/proto_next/lib_delegate/test/tenderbrute/lib/dune +++ b/src/proto_next/lib_delegate/test/tenderbrute/lib/dune @@ -19,3 +19,10 @@ -open Tezos_protocol_next -open Tezos_client_base -open Tezos_client_next)) + +(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"))) diff --git a/src/proto_next/lib_injector/dune b/src/proto_next/lib_injector/dune index 53d9f9122eb40708541abd458ccc2eeca6c402ec..e6393948ef7e186597d2f88a9032c04e46da174b 100644 --- a/src/proto_next/lib_injector/dune +++ b/src/proto_next/lib_injector/dune @@ -21,3 +21,14 @@ -open Tezos_client_next -open Tezos_client_base -open Tezos_protocol_plugin_next)) + +(rule + (targets client_keys.ml) + (action (write-file %{targets} "include Tezos_client_base.Client_keys_v1"))) + +(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"))) diff --git a/src/proto_next/lib_injector/injector_plugin.ml b/src/proto_next/lib_injector/injector_plugin.ml index f9afe4f07348a7bc2ff5f9c0594821af6fe6ff71..1818a39f818798a08327e1131ff3f7aac7b9f428 100644 --- a/src/proto_next/lib_injector/injector_plugin.ml +++ b/src/proto_next/lib_injector/injector_plugin.ml @@ -234,7 +234,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -272,6 +272,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -446,7 +448,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in - + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_next/lib_parameters/dune b/src/proto_next/lib_parameters/dune index f9472bca8955af20d17ccd8dd27c3529364885d6..18865fdeedcae376fd7961100665373bd6bb6fa3 100644 --- a/src/proto_next/lib_parameters/dune +++ b/src/proto_next/lib_parameters/dune @@ -16,6 +16,13 @@ -open Tezos_protocol_next) (modules (:standard \ gen))) +(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"))) + (executable (name gen) (libraries diff --git a/src/proto_next/lib_plugin/dune b/src/proto_next/lib_plugin/dune index 427156c973301ab7fc1c5afa5cf823ea1cc3738c..d287a0c5dd5ef57d02e52bcb0f661215e90a9513 100644 --- a/src/proto_next/lib_plugin/dune +++ b/src/proto_next/lib_plugin/dune @@ -18,6 +18,13 @@ (documentation (package octez-protocol-next-libs)) +(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"))) + (library (name tezos_protocol_plugin_next_registerer) (public_name octez-protocol-next-libs.plugin-registerer) diff --git a/src/proto_next/lib_plugin/mempool.ml b/src/proto_next/lib_plugin/mempool.ml index 84df0640e5cad23188b46950eaaac36879d4e039..ec10e413c976cd8684626802ae1d99c2b924869b 100644 --- a/src/proto_next/lib_plugin/mempool.ml +++ b/src/proto_next/lib_plugin/mempool.ml @@ -804,6 +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 match contents with | Single (Failing_noop _) -> return_nil | Single (Preattestation consensus_content) @@ -814,7 +815,7 @@ let sources_from_operation ctxt in match slot_owner with | Ok (_ctxt, {delegate; consensus_pkh; consensus_pk = _}) -> - return [delegate; consensus_pkh] + return @@ map_pkh_env [delegate; consensus_pkh] | Error _ -> return_nil) | Single (Attestations_aggregate {consensus_content; committee}) -> let level = Level.from_raw ctxt consensus_content.level in @@ -829,7 +830,7 @@ let sources_from_operation ctxt [] committee in - return sources + return @@ map_pkh_env sources | Single (Seed_nonce_revelation _) | Single (Double_preattestation_evidence _) | Single (Double_attestation_evidence _) @@ -839,10 +840,10 @@ let sources_from_operation ctxt | Single (Vdf_revelation _) -> return_nil | Single (Proposals {source; _}) | Single (Ballot {source; _}) -> - return [source] - | Single (Drain_delegate {delegate; _}) -> return [delegate] - | Single (Manager_operation {source; _}) -> return [source] - | Cons (Manager_operation {source; _}, _) -> return [source] + return @@ map_pkh_env [source] + | Single (Drain_delegate {delegate; _}) -> return @@ map_pkh_env [delegate] + | Single (Manager_operation {source; _}) -> return @@ map_pkh_env [source] + | Cons (Manager_operation {source; _}, _) -> return @@ map_pkh_env [source] module Internal_for_tests = struct let default_config_with_clock_drift clock_drift = diff --git a/src/proto_next/lib_plugin/mempool.mli b/src/proto_next/lib_plugin/mempool.mli index 2690bb5797d959da67127efbe877d1c4a4021add..80f9f004fcf471c22f7125b090e75c0a9e6904a4 100644 --- a/src/proto_next/lib_plugin/mempool.mli +++ b/src/proto_next/lib_plugin/mempool.mli @@ -192,7 +192,7 @@ val get_context : val sources_from_operation : ctxt -> Protocol.Alpha_context.packed_operation -> - Signature.public_key_hash list Lwt.t + Tezos_crypto.Signature.public_key_hash list Lwt.t module Internal_for_tests : sig open Protocol.Alpha_context diff --git a/src/proto_next/lib_protocol/test/helpers/dune b/src/proto_next/lib_protocol/test/helpers/dune index 3b2e19727cf0f4c1717407af685976656139ac92..14242d70c6f4c23409381ba6329f11aa00dc6c07 100644 --- a/src/proto_next/lib_protocol/test/helpers/dune +++ b/src/proto_next/lib_protocol/test/helpers/dune @@ -37,3 +37,10 @@ -open Tezos_shell_services -open Tezos_crypto_dal -open Tezos_smart_rollup_next)) + +(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"))) diff --git a/src/proto_next/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_next/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index e2c5c62a349b9f6490df94a3a356719e14bcbda4..862bec289990f9e47bdf13bf5e04113d2d68fb95 100644 --- a/src/proto_next/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_next/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -96,8 +96,7 @@ let dont_show _fmt _ = () let size = {Tezos_benchmark.Base_samplers.min = 4; max = 32} -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 10 let algo = `Default diff --git a/src/proto_next/lib_protocol/test/pbt/test_script_comparison.ml b/src/proto_next/lib_protocol/test/pbt/test_script_comparison.ml index bdd2b93a1c5ef2bd28d0034c6388cffdb4fb103c..6413c5d30a03333a5dbc7fd933098887c8eff94b 100644 --- a/src/proto_next/lib_protocol/test/pbt/test_script_comparison.ml +++ b/src/proto_next/lib_protocol/test/pbt/test_script_comparison.ml @@ -113,8 +113,7 @@ module Parameters = struct } end -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 1000 let algo = `Default diff --git a/src/proto_next/lib_protocol/test/pbt/test_script_roundtrip.ml b/src/proto_next/lib_protocol/test/pbt/test_script_roundtrip.ml index d6517039b0eda7cb68b35023a27caadd8185cd27..e28ce44dc36241265594ce0160d332ca82b61751 100644 --- a/src/proto_next/lib_protocol/test/pbt/test_script_roundtrip.ml +++ b/src/proto_next/lib_protocol/test/pbt/test_script_roundtrip.ml @@ -46,8 +46,7 @@ module Parameters = struct } end -module Crypto_samplers = -Tezos_benchmark.Crypto_samplers.Make_finite_key_pool (struct +module Crypto_samplers = Crypto_samplers.Make_finite_key_pool (struct let size = 1000 let algo = `Default diff --git a/src/proto_next/lib_sc_rollup_layer2/sc_rollup_proto_types.ml b/src/proto_next/lib_sc_rollup_layer2/sc_rollup_proto_types.ml index 691e55a6ecc22a3113d2360a726c9bcf64bfb51d..bbe78eb63568feedd33d03c8892e05887f0f4010 100644 --- a/src/proto_next/lib_sc_rollup_layer2/sc_rollup_proto_types.ml +++ b/src/proto_next/lib_sc_rollup_layer2/sc_rollup_proto_types.ml @@ -331,10 +331,14 @@ module Game = struct Move {choice = Sc_rollup.Tick.to_z choice; step = step_to_octez step} let index_of_octez Octez_smart_rollup.Game.{alice; bob} = - Sc_rollup.Game.Index.make 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) let index_to_octez Sc_rollup.Game.Index.{alice; bob} = - Octez_smart_rollup.Game.make_index alice bob + Octez_smart_rollup.Game.make_index + (Signature.V_latest.Of_V1.public_key_hash alice) + (Signature.V_latest.Of_V1.public_key_hash bob) let player_of_octez : Octez_smart_rollup.Game.player -> player = function | Alice -> Alice @@ -434,7 +438,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : conflict = { - other; + other = Signature.V1.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; @@ -445,7 +449,7 @@ module Game = struct {other; their_commitment; our_commitment; parent_commitment} : Octez_smart_rollup.Game.conflict = { - other; + other = Signature.Of_V1.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_next/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_next/lib_sc_rollup_node/daemon_helpers.ml index b0c37467a82a6ad374851478fb257eb58cfc3eb5..26d70bb463e265407866b31bbaacca95bfb2f27c 100644 --- a/src/proto_next/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_next/lib_sc_rollup_node/daemon_helpers.ml @@ -112,6 +112,9 @@ let maybe_recover_bond node_ctxt = match operating_pkh with | None -> return_unit | Some (Single operating_pkh) -> ( + let*? operating_pkh = + Signature.Of_V_latest.get_public_key_hash operating_pkh + in let* staked_on_commitment = RPC.Sc_rollup.staked_on_commitment (new Protocol_client_context.wrap_full node_ctxt.cctxt) @@ -213,7 +216,10 @@ let process_included_l1_operation (type kind) ~catching_up | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + | Loser {loser; reason} + when Node_context.is_operator + node_ctxt + (Tezos_crypto.Signature.Of_V1.public_key_hash loser) -> let result = match reason with | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved @@ -226,8 +232,13 @@ let process_included_l1_operation (type kind) ~catching_up | Draw -> let stakers = match operation with - | Sc_rollup_refute {opponent; _} -> [source; opponent] - | Sc_rollup_timeout {stakers = {alice; bob}; _} -> [alice; bob] + | Sc_rollup_refute {opponent; _} -> + [source; Tezos_crypto.Signature.Of_V1.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; + ] | _ -> assert false in fail_when @@ -251,7 +262,9 @@ let process_included_l1_operation (type kind) ~catching_up match Node_context.get_operator node_ctxt Operating with | Some (Single operating_pkh) -> fail_when - Signature.Public_key_hash.(operating_pkh = staker) + Tezos_crypto.Signature.Public_key_hash.( + operating_pkh + = Tezos_crypto.Signature.Of_V1.public_key_hash staker) Sc_rollup_node_errors.Exit_bond_recovered_bailout_mode | _ -> return_unit) | ( Sc_rollup_execute_outbox_message {output_proof; _}, @@ -294,6 +307,11 @@ let process_included_l1_operation (type kind) ~catching_up (* No need to check whitelist updates for historical data. *) then return_unit else + let whitelist_update = + List.map + Tezos_crypto.Signature.Of_V1.public_key_hash + whitelist_update + in let*? () = Node_context.check_op_in_whitelist_or_bailout_mode node_ctxt @@ -367,6 +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 process_l1_operation ~catching_up node_ctxt head ~source operation result in let apply_internal (type kind) accu ~source:_ diff --git a/src/proto_next/lib_sc_rollup_node/dune b/src/proto_next/lib_sc_rollup_node/dune index 45368be83da4e22a5464966e5f838db2d4014346..ba0ff371184b8fa550405c7844f8a04e4d29c23d 100644 --- a/src/proto_next/lib_sc_rollup_node/dune +++ b/src/proto_next/lib_sc_rollup_node/dune @@ -73,3 +73,10 @@ -open Octez_injector -open Octez_smart_rollup_node -open Tezos_crypto_dal)) + +(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"))) diff --git a/src/proto_next/lib_sc_rollup_node/layer1_helpers.ml b/src/proto_next/lib_sc_rollup_node/layer1_helpers.ml index 1f4ef7b394fa06a9635fe3467b47829b6f90256e..51a92aaf69715c35fc74b42b6eb49e9d914c5067 100644 --- a/src/proto_next/lib_sc_rollup_node/layer1_helpers.ml +++ b/src/proto_next/lib_sc_rollup_node/layer1_helpers.ml @@ -78,6 +78,7 @@ let get_last_published_commitment ?(allow_unstake = true) let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? operator = Signature.Of_V_latest.get_public_key_hash operator in let rollup_address = Sc_rollup_proto_types.Address.of_octez rollup_address in let*! res = Plugin.RPC.Sc_rollup.staked_on_commitment @@ -237,11 +238,18 @@ let get_boot_sector block_hash (node_ctxt : _ Node_context.t) = | _ -> missing_boot_sector ()) let find_whitelist cctxt ?block rollup_address = + let open Lwt_result_syntax in let block = match block with Some b -> `Hash (b, 0) | None -> `Head 0 in - Plugin.RPC.Sc_rollup.whitelist - (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) - (cctxt#chain, block) - rollup_address + let* whitelist = + Plugin.RPC.Sc_rollup.whitelist + (new Protocol_client_context.wrap_full (cctxt :> Client_context.full)) + (cctxt#chain, block) + rollup_address + in + return + @@ Option.map + (List.map Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash) + whitelist let find_last_whitelist_update cctxt rollup_address = let open Lwt_result_syntax in @@ -275,6 +283,7 @@ let get_balance_mutez cctxt ?block pkh = let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_next/lib_sc_rollup_node/pvm_plugin.ml b/src/proto_next/lib_sc_rollup_node/pvm_plugin.ml index 8d0a4fd39c0210dc6733c96cbb8968a748355068..56c66fb722302a047301c9f5919597a9f3f2fca4 100644 --- a/src/proto_next/lib_sc_rollup_node/pvm_plugin.ml +++ b/src/proto_next/lib_sc_rollup_node/pvm_plugin.ml @@ -155,7 +155,10 @@ let outbox_message_summary (output : Sc_rollup.output) = let summary = match output with | {message = Whitelist_update pkhs; _} -> - Outbox_message.Whitelist_update pkhs + Outbox_message.Whitelist_update + (Option.map + (List.map Tezos_crypto.Signature.V_latest.Of_V1.public_key_hash) + pkhs) | {message = Atomic_transaction_batch {transactions}; _} -> let transactions = List.map outbox_transaction_summary transactions in Transaction_batch transactions diff --git a/src/proto_next/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_next/lib_sc_rollup_node/refutation_game_helpers.ml index 60b64f51c4770b7c2c4c72598b86d42748bc9f5f..2ba0bb671b5331fa6963c83fb214cdfec4ad5a24 100644 --- a/src/proto_next/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_next/lib_sc_rollup_node/refutation_game_helpers.ml @@ -357,6 +357,9 @@ let make_dissection plugin (node_ctxt : _ Node_context.t) state_cache let timeout_reached node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ game_result = Plugin.RPC.Sc_rollup.timeout_reached (new Protocol_client_context.wrap_full cctxt) @@ -368,13 +371,16 @@ let timeout_reached node_ctxt ~self ~opponent = let open Sc_rollup.Game in match game_result with | Some (Loser {loser; _}) -> - let is_it_me = Signature.Public_key_hash.(self = loser) in + let is_it_me = Environment.Signature.Public_key_hash.(self = loser) in not is_it_me | _ -> false let timeout node_ctxt ~self ~opponent = let open Lwt_result_syntax in let Node_context.{config; cctxt; _} = node_ctxt in + let*? self = Signature.Of_V_latest.get_public_key_hash self in + let*? opponent = Signature.Of_V_latest.get_public_key_hash opponent in + let+ timeout = Plugin.RPC.Sc_rollup.timeout (new Protocol_client_context.wrap_full cctxt) @@ -388,6 +394,7 @@ let timeout node_ctxt ~self ~opponent = let get_conflicts cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ conflicts = Plugin.RPC.Sc_rollup.conflicts cctxt (cctxt#chain, `Head 0) rollup staker in @@ -396,6 +403,7 @@ let get_conflicts cctxt rollup staker = let get_ongoing_games cctxt rollup staker = let open Lwt_result_syntax in let cctxt = new Protocol_client_context.wrap_full cctxt in + let*? staker = Signature.Of_V_latest.get_public_key_hash staker in let+ games = Plugin.RPC.Sc_rollup.ongoing_refutation_games cctxt @@ -405,5 +413,7 @@ let get_ongoing_games cctxt rollup staker = in List.map (fun (game, staker1, staker2) -> - (Sc_rollup_proto_types.Game.to_octez 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 )) games diff --git a/src/proto_next/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_next/lib_sc_rollup_node/sc_rollup_injector.ml index 53337355fb6f26271065033179d55381b461411e..3a393a0517b864e2d47f04407cc4619b8b708775 100644 --- a/src/proto_next/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_next/lib_sc_rollup_node/sc_rollup_injector.ml @@ -47,6 +47,7 @@ let injector_operation_to_manager : let refutation = Sc_rollup_proto_types.Game.refutation_of_octez refutation in + let opponent = Signature.Of_V_latest.get_public_key_hash_exn opponent in Manager (Sc_rollup_refute {rollup; opponent; refutation}) | Timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -54,6 +55,7 @@ let injector_operation_to_manager : Manager (Sc_rollup_timeout {rollup; stakers}) | Recover_bond {rollup; staker} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in + let staker = Signature.Of_V_latest.get_public_key_hash_exn staker in Manager (Sc_rollup_recover_bond {sc_rollup = rollup; staker}) | Execute_outbox_message {rollup; cemented_commitment; output_proof} -> let rollup = Sc_rollup_proto_types.Address.of_octez rollup in @@ -102,6 +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 Some (Refute {rollup; opponent; refutation}) | Sc_rollup_timeout {rollup; stakers} -> let rollup = Sc_rollup_proto_types.Address.to_octez rollup in @@ -284,7 +287,7 @@ module Proto_client = struct let dummy_sk_uri = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Tezos_signer_backends.Unencrypted.make_sk - @@ Signature.Secret_key.of_b58check_exn + @@ Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3UqeiQWXX7NFEY1wUs6J1t2ez5aQ3hEWdqX5Jr5edZiGLW8nZr" let simulate_operations cctxt ~force ~source ~src_pk ~successor_level @@ -322,6 +325,8 @@ module Proto_client = struct in let safety_guard = Option.map Gas.Arith.integral_of_int_exn safety_guard in let*! simulation_result = + let*? source = Signature.Of_V_latest.get_public_key_hash source in + let*? src_pk = Signature.Of_V_latest.get_public_key src_pk in Injection.inject_manager_operation cctxt ~simulation:true (* Only simulation here *) @@ -498,6 +503,7 @@ module Proto_client = struct let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) in + let*? pkh = Signature.Of_V_latest.get_public_key_hash pkh in let+ balance = Plugin.Alpha_services.Contract.balance cctxt diff --git a/src/proto_next/lib_sc_rollup_node/test/test_octez_conversions.ml b/src/proto_next/lib_sc_rollup_node/test/test_octez_conversions.ml index 9aa7bab4a73b56b4cdecfa4229fdd6492f06534d..b29e542a3dc33daf4617772a7da1039d2e1b18e5 100644 --- a/src/proto_next/lib_sc_rollup_node/test/test_octez_conversions.ml +++ b/src/proto_next/lib_sc_rollup_node/test/test_octez_conversions.ml @@ -118,12 +118,13 @@ let random_algo ~rng_state : Signature.algo = | 3 -> Bls | _ -> assert false -let gen_algo = QCheck2.Gen.oneofl [Signature.Ed25519; Secp256k1; P256; Bls] +let gen_algo = + QCheck2.Gen.oneofl [Tezos_crypto.Signature.Ed25519; Secp256k1; P256; Bls] let gen_pkh = let open QCheck2.Gen in let+ algo = gen_algo in - let pkh, _pk, _sk = Signature.generate_key ~algo () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key ~algo () in pkh let gen_stakers = @@ -266,6 +267,9 @@ let gen_slot_history = ( Raw_level.of_int32_exn lvl, List.map (fun (h, publisher, status) -> + let publisher = + Signature.Of_V_latest.get_public_key_hash_exn publisher + in ( Sc_rollup_proto_types.Dal.Slot_header.of_octez ~number_of_slots h, Contract.Implicit publisher, status )) @@ -297,6 +301,9 @@ let gen_slot_history_cache = ( Raw_level.of_int32_exn lvl, List.map (fun (h, publisher, status) -> + let publisher = + Signature.Of_V_latest.get_public_key_hash_exn publisher + in ( Sc_rollup_proto_types.Dal.Slot_header.of_octez ~number_of_slots h, Contract.Implicit publisher, status )) diff --git a/teztale/bin_teztale_archiver/Proxford_machine.real.ml b/teztale/bin_teztale_archiver/Proxford_machine.real.ml index 9b2f62a499e575cbbb976a3d1db404ed13260e3d..f584cfdfb7742a0f86d35b4c05ef3d2b31b5bbdf 100644 --- a/teztale/bin_teztale_archiver/Proxford_machine.real.ml +++ b/teztale/bin_teztale_archiver/Proxford_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -153,7 +154,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -167,7 +171,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -231,7 +238,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -251,7 +258,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -270,7 +277,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/PsParisC_machine.real.ml b/teztale/bin_teztale_archiver/PsParisC_machine.real.ml index c1ffa4662766a7b7710ea69e0677127881b69d3f..f073618a1b7f3dc08e47ba8fd519c2e373ee8981 100644 --- a/teztale/bin_teztale_archiver/PsParisC_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsParisC_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -158,7 +159,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -172,7 +176,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -236,7 +243,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -256,7 +263,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -275,7 +282,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml b/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml index 663b93633e06bb2eda55cb804b31670a80a29bd9..16d10a04acd93c82fdd3ba6c115dc52b7f6df37d 100644 --- a/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -158,7 +159,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -172,7 +176,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -236,7 +243,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -256,7 +263,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -275,7 +282,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml b/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml index b490e304d9c3ffc2466b3c5c63ba8e499833d825..72a2b7814cc3ee994e8c01bb08e740ced4ac5858 100644 --- a/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; endorsing_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = endorsing_power; }) @@ -153,7 +154,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -167,7 +171,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -231,7 +238,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = preendorsement_power; } :: acc @@ -251,7 +258,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = endorsement_power; } :: acc @@ -270,7 +277,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/PtNairob_machine.real.ml b/teztale/bin_teztale_archiver/PtNairob_machine.real.ml index e3acaf988e7570b86d3f63cc017134d0ff6a3142..2387abcacc5c7ab3a6e9117cc0664201cd7d17c3 100644 --- a/teztale/bin_teztale_archiver/PtNairob_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtNairob_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -153,7 +154,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -167,7 +171,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -231,7 +238,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = preendorsement_power; } :: acc @@ -251,7 +258,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = endorsement_power; } :: acc @@ -270,7 +277,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/PtParisB_machine.real.ml b/teztale/bin_teztale_archiver/PtParisB_machine.real.ml index 72ddb8254d955d54e48efb7ca2d73f05c4789b5b..3eec043a5f609190f7e456f2cc4770adcc85fd7b 100644 --- a/teztale/bin_teztale_archiver/PtParisB_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtParisB_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -158,7 +159,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -172,7 +176,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -236,7 +243,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -256,7 +263,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -275,7 +282,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/alpha_machine.real.ml b/teztale/bin_teztale_archiver/alpha_machine.real.ml index 4c8fc182219168ee45fa9663961fc9e2ed9d8e55..6778f95186df79cc5d5038e9934be1efef8c0830 100644 --- a/teztale/bin_teztale_archiver/alpha_machine.real.ml +++ b/teztale/bin_teztale_archiver/alpha_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -158,7 +159,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -172,7 +176,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -236,7 +243,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -256,7 +263,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -275,7 +282,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/bin_teztale_archiver/next_machine.real.ml b/teztale/bin_teztale_archiver/next_machine.real.ml index b3e72eada107ab38c062ebd78bc71be81d135b20..01887525055bed5b2e2d2c6004b045175b028813 100644 --- a/teztale/bin_teztale_archiver/next_machine.real.ml +++ b/teztale/bin_teztale_archiver/next_machine.real.ml @@ -45,7 +45,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct {delegate; first_slot; attestation_power; _} -> Consensus_ops. { - address = delegate; + address = + Tezos_crypto.Signature.Of_V1.public_key_hash delegate; first_slot = slot_to_int first_slot; power = attestation_power; }) @@ -158,7 +159,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct let* cycle_info = cycle_info metadata cctxt (cctxt#chain, `Hash (hash, 0)) in - return (metadata.protocol_data.baker.delegate, cycle_info) + return + ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, + cycle_info ) let baking_rights cctxt level round = let* baking_rights = @@ -172,7 +176,10 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct match List.rev_map (fun ({delegate; round; _} : RPC.Baking_rights.t) -> - {Data.delegate; round = Protocol.Alpha_context.Round.to_int32 round}) + { + Data.delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; + round = Protocol.Alpha_context.Round.to_int32 round; + }) baking_rights with | [] -> fail_with_exn Not_found @@ -236,7 +243,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_preattestation_round protocol_data); kind = Consensus_ops.Preattestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -256,7 +263,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct round = Some (get_attestation_round protocol_data); kind = Consensus_ops.Attestation; }; - delegate; + delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; } :: acc @@ -275,7 +282,8 @@ 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 - ( ( metadata.protocol_data.baker.delegate, + ( ( Tezos_crypto.Signature.Of_V1.public_key_hash + metadata.protocol_data.baker.delegate, header.shell.timestamp, round, header.hash, diff --git a/teztale/lib_teztale_base/consensus_ops.mli b/teztale/lib_teztale_base/consensus_ops.mli index 51eefdf0d1f1c45c9404226de3e54ec8f3603e3f..32ef2a3445d736cda2006554e48f72d3af714664 100644 --- a/teztale/lib_teztale_base/consensus_ops.mli +++ b/teztale/lib_teztale_base/consensus_ops.mli @@ -6,7 +6,7 @@ (*****************************************************************************) type right = { - address : Tezos_crypto.Signature.Public_key_hash.t; + address : Signature.Public_key_hash.t; first_slot : int; power : int; }