Piston addkey problem (hangs after password is entered)

in #piston8 years ago (edited)

Edit: see @xeroc 's reply below for the correct explanation and fix

I encountered a problem getting Piston to work correctly that I have not seen discussed. I managed to figure out a fix myself, so I'm partially posting this because I feel like a genius and want to brag, but mostly in case anyone has the same problem and needs a reference.

When I installed piston, It worked fine except for one problem. I could not use the "addkey" function. Any time I tried, Piston would ask for my wallet password, and then hang indefinitely until I broke out with control-c. It produced this:

^CTraceback (most recent call last):
  File "/home/sigmajin/.local/bin/piston", line 11, in <module>
    sys.exit(main())
  File "/home/sigmajin/.local/lib/python3.5/site-packages/piston/__main__.py", line 816, in main
    pub = (steem.wallet.addPrivateKey(wifkey))
  File "/home/sigmajin/.local/lib/python3.5/site-packages/piston/wallet.py", line 243, in addPrivateKey
    self.keyStorage.add(self.encrypt_wif(wif), pub)
  File "/home/sigmajin/.local/lib/python3.5/site-packages/piston/wallet.py", line 187, in encrypt_wif
    return format(bip38.encrypt(PrivateKey(wif), self.masterpassword), "encwif")
  File "/home/sigmajin/.local/lib/python3.5/site-packages/graphenebase/bip38.py", line 61, in encrypt
    key           = scrypt.scrypt(bytes(passphrase, "utf-8"), salt, 16384, 8, 8)
  File "/home/sigmajin/.local/lib/python3.5/site-packages/pylibscrypt/pypyscrypt_inline.py", line 212, in scrypt
    smix(B, i * 32 * r, r, N, V, XY)
  File "/home/sigmajin/.local/lib/python3.5/site-packages/pylibscrypt/pypyscrypt_inline.py", line 175, in smix
    blockmix_salsa8(X, 32 * r, r)                  # ROMix - 9(outer)
  File "/home/sigmajin/.local/lib/python3.5/site-packages/pylibscrypt/pypyscrypt_inline.py", line 155, in blockmix_salsa8
    salsa20_8(X, tmp, BY, i * 16, BY, Yi + i*16)   # BlockMix - 3(outer)
  File "/home/sigmajin/.local/lib/python3.5/site-packages/pylibscrypt/pypyscrypt_inline.py", line 77, in salsa20_8

I'm don't know anything about programming, so obviously, I have no idea what any of this means, but I was able to find someone who had experienced a similar problem that produced a similar traceback with another program here:

https://github.com/cathalgarvey/deadlock/issues/4

The solution given for this program was to upgrade to the latest version, which included a fix. So I just installed the program (called deadlock), and it fixed my issue . I'm sure there is a better way to do it, but I wasn't really clear enough on the explanation to try and figure it out.

Hopefully, this post saves someone a little bit of time.

EDIT: though the above worked for me, the real and more direct fix (courtesy of @xeroc in the comments) is :
pip3 install scrypt

Sort:  

It doesn't actually hang. The reason it takes so long in your case is that the private keys are encrypted using scrypt and you only have the software implementation of scrypt installed. You can fix this by installing:

pip3 install scrypt

If that's not working try:

pip install https://pypi.python.org/packages/7d/fc/3e65f21be05f5f1bafa8f2262fea474c6dd84cc7dc226d453dd488675305/scrypt-0.7.1-cp34-none-win32.whl

Ha... i figured there was a much simpler way. Glad i posted, though hopefully it'll help out the next guy googling around like a tool box. Edited the OP to reflect your reply.

While im posting about things that are probably common sense to most of the tech savvy people here but took me some time to figure out.

Empty password.

WHen you try to set an empty password, you get a message that says to use the unlock environmental variable instead.

To do this, type
export UNLOCK="xxx"
where xxx is the password you set.

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.030
BTC 67536.76
ETH 3771.86
USDT 1.00
SBD 3.57