diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_events.ml b/src/proto_021_PsQuebec/lib_delegate/baking_events.ml index adbccc199f064c881aa302a01add9f2ddadcfa12..1c23c031239b512921454d2b9da520f15bbead52 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_events.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_events.ml @@ -613,7 +613,9 @@ module Delegates = struct Format.( pp_print_list ~pp_sep:pp_print_cut Baking_state.pp_consensus_key) delegates) - ("delegates", Data_encoding.list Baking_state.consensus_key_encoding) + ( "delegates", + Data_encoding.list + Baking_state.consensus_key_without_sk_encoding__cannot_decode ) end module Scheduling = struct diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_state.ml b/src/proto_021_PsQuebec/lib_delegate/baking_state.ml index 8f3e9e8231533c88392c59c1ba768f58fab6ff35..6c6a12dd621fb3b712c887e2f8abcd4f7b4b3874 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_state.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_state.ml @@ -62,6 +62,18 @@ let consensus_key_encoding = (req "public_key_hash" Signature.Public_key_hash.encoding) (req "secret_key_uri" string)) +let consensus_key_without_sk_encoding__cannot_decode = + let open Data_encoding in + conv + (fun {alias; public_key; public_key_hash; _} -> + (alias, public_key, public_key_hash)) + (fun (_alias, _public_key, _public_key_hash) -> + Stdlib.failwith "Unexpected secret key") + (obj3 + (req "alias" (option string)) + (req "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Signature.Public_key_hash.encoding)) + let pp_consensus_key fmt {alias; public_key_hash; _} = match alias with | None -> Format.fprintf fmt "%a" Signature.Public_key_hash.pp public_key_hash diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_state.mli b/src/proto_021_PsQuebec/lib_delegate/baking_state.mli index 0244ed7342b79c330b7f8d85496d963e1c143f5c..6ba1c4857e43021537889e79038dac98e1aba176 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_state.mli +++ b/src/proto_021_PsQuebec/lib_delegate/baking_state.mli @@ -35,6 +35,12 @@ type consensus_key = { val consensus_key_encoding : consensus_key Data_encoding.t +(* Encodes the consensus_key but removes the [secret_key_uri] to avoid + leaking information. + Warning: this encoding was designed to encode, decoding will fail. *) +val consensus_key_without_sk_encoding__cannot_decode : + consensus_key Data_encoding.t + val pp_consensus_key : Format.formatter -> consensus_key -> unit type consensus_key_and_delegate = consensus_key * Signature.Public_key_hash.t diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_events.ml b/src/proto_022_PsRiotum/lib_delegate/baking_events.ml index 3365dbeaf8e0451837fa252110b919f819b302dc..eef4f1f65efd7a7f6137233caed6726163f87ca6 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_events.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_events.ml @@ -600,7 +600,10 @@ module Delegates = struct Format.( pp_print_list ~pp_sep:pp_print_cut Baking_state.Consensus_key.pp) delegates) - ("delegates", Data_encoding.list Baking_state.Consensus_key.encoding) + ( "delegates", + Data_encoding.list + Baking_state.Consensus_key + .consensus_key_without_sk_encoding__cannot_decode ) end module Scheduling = struct diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_state.ml b/src/proto_022_PsRiotum/lib_delegate/baking_state.ml index 01dfd7829c402fa2ebbba5d15c3561e06b39d67e..e6728319de67aeaadb689b19e6c03f4dd58b503a 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_state.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_state.ml @@ -77,6 +77,17 @@ module Consensus_key = struct (req "public_key_hash" Signature.Public_key_hash.encoding) (req "secret_key_uri" string)) + let consensus_key_without_sk_encoding__cannot_decode = + let open Data_encoding in + conv + (fun {alias; public_key; id; _} -> (alias, public_key, id)) + (fun (_alias, _public_key, _id) -> + Stdlib.failwith "Unexpected secret key") + (obj3 + (req "alias" (option string)) + (req "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Signature.Public_key_hash.encoding)) + let pp fmt {alias; id; _} = match alias with | None -> Format.fprintf fmt "%a" Signature.Public_key_hash.pp id diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_state.mli b/src/proto_022_PsRiotum/lib_delegate/baking_state.mli index 69c4756058252e830d5ea03db309048b837d70ff..ee6b1ba11d8709df659738ddd76cafe196e29fa6 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_state.mli +++ b/src/proto_022_PsRiotum/lib_delegate/baking_state.mli @@ -63,6 +63,11 @@ module Consensus_key : sig val encoding : t Data_encoding.t + (* Encodes the consensus_key but removes the [secret_key_uri] to avoid + leaking information. + Warning: this encoding was designed to encode, decoding will fail. *) + val consensus_key_without_sk_encoding__cannot_decode : t Data_encoding.t + val pp : Format.formatter -> t -> unit end diff --git a/src/proto_alpha/lib_delegate/baking_events.ml b/src/proto_alpha/lib_delegate/baking_events.ml index 93641c3110451d36f137478cb7cc30760820a9ea..b96204b7fbff80bd277e4c43ba891fc13f4353cf 100644 --- a/src/proto_alpha/lib_delegate/baking_events.ml +++ b/src/proto_alpha/lib_delegate/baking_events.ml @@ -607,7 +607,10 @@ module Delegates = struct Format.( pp_print_list ~pp_sep:pp_print_cut Baking_state.Consensus_key.pp) delegates) - ("delegates", Data_encoding.list Baking_state.Consensus_key.encoding) + ( "delegates", + Data_encoding.list + Baking_state.Consensus_key + .consensus_key_without_sk_encoding__cannot_decode ) end module Scheduling = struct diff --git a/src/proto_alpha/lib_delegate/baking_state.ml b/src/proto_alpha/lib_delegate/baking_state.ml index daf2cdf5f0592d6d438ec36d0238183adf6c86c2..ffb4130dfa6dfc73a06f75a9f3d8eb2c661efe28 100644 --- a/src/proto_alpha/lib_delegate/baking_state.ml +++ b/src/proto_alpha/lib_delegate/baking_state.ml @@ -77,6 +77,17 @@ module Consensus_key = struct (req "public_key_hash" Signature.Public_key_hash.encoding) (req "secret_key_uri" string)) + let consensus_key_without_sk_encoding__cannot_decode = + let open Data_encoding in + conv + (fun {alias; public_key; id; _} -> (alias, public_key, id)) + (fun (_alias, _public_key, _id) -> + Stdlib.failwith "Unexpected secret key") + (obj3 + (req "alias" (option string)) + (req "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Signature.Public_key_hash.encoding)) + let pp fmt {alias; id; _} = match alias with | None -> Format.fprintf fmt "%a" Signature.Public_key_hash.pp id diff --git a/src/proto_alpha/lib_delegate/baking_state.mli b/src/proto_alpha/lib_delegate/baking_state.mli index 94d2ece13d1c2888d0bbdff54626e535bf88ee1f..6ce42effd2a70e481607107cf8e0aa1278e3e71e 100644 --- a/src/proto_alpha/lib_delegate/baking_state.mli +++ b/src/proto_alpha/lib_delegate/baking_state.mli @@ -63,6 +63,11 @@ module Consensus_key : sig val encoding : t Data_encoding.t + (* Encodes the consensus_key but removes the [secret_key_uri] to avoid + leaking information. + Warning: this encoding was designed to encode, decoding will fail. *) + val consensus_key_without_sk_encoding__cannot_decode : t Data_encoding.t + val pp : Format.formatter -> t -> unit end