From 401eeceefb044f81baaa10ea06f8520fc07c1c0d Mon Sep 17 00:00:00 2001 From: Vincent Bernardoff Date: Mon, 9 Apr 2018 16:40:56 +0200 Subject: [PATCH] Client: fix error when signing with encrypted keys --- src/lib_client_base/client_keys.ml | 1 + src/lib_client_base_unix/client_signer_encrypted.ml | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index 0f1753d7e..a0cd0c5ef 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -142,6 +142,7 @@ let find_signer_for_key cctxt ~scheme = | signer, false -> let module Signer = (val signer : SIGNER) in Signer.init cctxt >>=? fun () -> + Hashtbl.replace signers_table scheme (signer, true) ; return signer | signer, true -> return signer diff --git a/src/lib_client_base_unix/client_signer_encrypted.ml b/src/lib_client_base_unix/client_signer_encrypted.ml index ba63aaecb..20c7c17a2 100644 --- a/src/lib_client_base_unix/client_signer_encrypted.ml +++ b/src/lib_client_base_unix/client_signer_encrypted.ml @@ -74,19 +74,20 @@ module Encrypted_signer : SIGNER = struct if Secret_key_locator.scheme skloc <> scheme then Lwt.return a else - match Base58.safe_decode (Secret_key_locator.location skloc) with + let location = Secret_key_locator.location skloc in + match Base58.safe_decode location with | None -> Lwt.fail Exit - | Some loc -> - let salt, skenc = salt_skenc_of_skloc loc in + | Some payload -> + let salt, skenc = salt_skenc_of_skloc payload in match decrypt_sk skenc salt a with | Some sk -> - Hashtbl.replace decrypted_sks loc + Hashtbl.replace decrypted_sks location (Ed25519.Secret_key.of_bytes_exn sk) ; Lwt.return a | None -> passwd_ask_loop cctxt ~name ~salt ~skenc >>= fun (passwd, decrypted_sk) -> - Hashtbl.replace decrypted_sks loc decrypted_sk ; + Hashtbl.replace decrypted_sks location decrypted_sk ; Lwt.return (passwd :: a) end [] sks