I'm attempting to import a transcribed geth UTC--... format keyfile into geth on ubuntu, using this guidance, and am getting the following error:

Fatal: Failed to load the private key: encoding/hex: invalid byte: U+007 B '{'

There are a few other similar questions but none ask why this error occurs.

I'm guessing the file must be in UTF-8 encoding. On using file -i on a terminal it returns:

UTC--etc_file_name text/plain; charset=us-ascii

I think us-ascii is a subset of UTF-8, so it should work....

Why is this error occuring?

What is the correct encoding for geth keystore files?

2 Answers 2


I do not know why this error is occuring, but:

  • I'm on ubuntu, and file -i keyfile gives the same result as for you. As I have no problem with my key, it is probably not an encoding problem in your side.

  • The '{' character is used to format the keyfile. My file format is: {"address":x,"crypto":{"cipher":"aes-128-ctr","ciphertext":x,"cipherparams":{"iv":x},"kdf":"scrypt","kdfparams":{"dklen":x,"n":x,"p":x,"r":x,"salt":x},"mac":x},"id":x,"version":x} so it should be something like that in your file.

  • You should verify that your '{' and your quotes (") are all balanced, because it seems to me that it comes from such a mistake. However, if you did not modify the file, it should not have occured. Note that some fields have quotes in their value (e.g. hex fields) while others have not.


This stemmed from a mistake:

I needed to save the file to /.ethereum/keystore

I had it saved in /.ethereum

I was also not completely clear on how geth interprets private-key, encryted private key and keystore info:

encryted private-key: stored in "ciphertext" field of JSON keystore file, encryted with settings in that file.

private key un-encryted version of above (this is what most of the linked questions refer to) - I was attempting to import the whole JSON file, not just the key! Hence the error with invalid { char.

JSON keystore file this is what I was attempting to import, but saved to incorrect directory then jumped to "oh maybe there's an import procedure..." search and went up a blind alley..

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.