I can't find any way to get the unencrypted private key from an encrypted private key from the tezos client.

I have found a way using tezbox. You import a private key into tezbox and then show the private key. The key that it shows you is unencrypted. I am unable to import an encrypted private key into tezbox that has a 'blank' password so this method is not available to me.

I have been told I can use eztz using:


And I have been told I can use pytezos using:

Key(key='edesk...', passphrase='123456').secret_key()

I can't figure out how to get the above options to work, though. I have tried the eztz node.js method, but I would appreciate an example of how to do this.

  • 2
    You need to import eztz lib first and then use this: eztz.crypto.extractEncryptedKeys(encryptedPrivateKey, password) It will return a full set of extracted keys. Commented Feb 10, 2019 at 16:31
  • Btw, that function is used on client side, will not work if you are using it on backend as it needs the window obj. You need to change it to work on backend. Commented Feb 10, 2019 at 16:55

3 Answers 3


With pytezos

import pytezos
print(pytezos.Key('edesk...', passphrase='yourpassword').secret_key())


>>> from pytezos import Key
>>> key = Key.generate()
>>> key.public_key_hash()
>>> esk = key.secret_key(passphrase='12345'.encode())
>>> esk
>>> Key.from_encoded_key(esk, passphrase='12345'.encode()).secret_key()

According to the developer: "Passing password as bytes is not convenient indeed, plain string support will be added to mitigate this."

  • im getting this error : ``` File "/Users/user/Desktop/privkeyconvert/pytezos.py", line 54 def __init__(self, key: str, passphrase: str = None, email: str = None): ^ SyntaxError: invalid syntax```
    – Mr Z
    Commented Feb 10, 2019 at 17:46
  • How are you running it?
    – Arthur B
    Commented Feb 10, 2019 at 21:22
  • AttributeError: module 'pytezos' has no attribute 'key'. running in the python3 cli
    – Gaia
    Commented Aug 8, 2019 at 19:20
  • same issue here 'pytezos' has no attribute 'key'...
    – Mack Baise
    Commented Jan 19, 2021 at 9:05
  • 1
    Updated the example Commented Jan 21, 2021 at 14:06

You may want to read this guide. There is some Python code inside.

  • link is dead... can you provide a new link?
    – Mack Baise
    Commented Jan 10, 2021 at 2:10

With pytezos :

from pytezos.crypto import Key
print(Key('edesk....', passphrase='pasword...').secret_key())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.