Client: fix error when signing with encrypted keys

This commit is contained in:
Vincent Bernardoff 2018-04-09 16:40:56 +02:00
parent ce2d196bb5
commit 401eeceefb
2 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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