From d1c46b5cf20829d8d998f83b5b5d659b4d00c12a Mon Sep 17 00:00:00 2001 From: Vincent Bernardoff Date: Thu, 9 Aug 2018 18:28:08 +0200 Subject: [PATCH] Signer: add other remote signers For redundancy purposes, there is no reason why a remote signer could not sign with other remote signers. This patch adds remote signers support for signers. --- src/bin_signer/main_signer.ml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/bin_signer/main_signer.ml b/src/bin_signer/main_signer.ml index f126d8856..1cd28c4a0 100644 --- a/src/bin_signer/main_signer.ml +++ b/src/bin_signer/main_signer.ml @@ -302,6 +302,29 @@ let main () = Client_keys.register_signer (module Tezos_signer_backends.Ledger) ; Logging_unix.init () >>= fun () -> + let module Remote_params = struct + let authenticate pkhs payload = + Client_keys.list_keys cctxt >>=? fun keys -> + match List.filter_map begin function + | (_, known_pkh, _, Some known_sk_uri) + when List.exists (fun pkh -> Signature.Public_key_hash.equal pkh known_pkh) pkhs -> + Some known_sk_uri + | _ -> None + end keys with + | sk_uri :: _ -> + Client_keys.sign cctxt sk_uri payload + | [] -> failwith + "remote signer expects authentication signature, \ + but no authorized key was found in the wallet" + let logger = RPC_client.full_logger Format.err_formatter + end in + let module Socket = Tezos_signer_backends.Socket.Make(Remote_params) in + let module Http = Tezos_signer_backends.Http.Make(Remote_params) in + let module Https = Tezos_signer_backends.Https.Make(Remote_params) in + Client_keys.register_signer (module Socket.Unix) ; + Client_keys.register_signer (module Socket.Tcp) ; + Client_keys.register_signer (module Http) ; + Client_keys.register_signer (module Https) ; let commands = Clic.add_manual ~executable_name