hs-airdrop icon indicating copy to clipboard operation
hs-airdrop copied to clipboard

Can't decrypt ed25519 key with passphrase

Open dos1 opened this issue 5 years ago • 7 comments

Error: Failed to finalize cipher.
    at Decipher.final (/home/dos/git/hs-airdrop/node_modules/bcrypto/lib/native/cipher.js:48:21)
    at Object.decrypt (/home/dos/git/hs-airdrop/node_modules/bcrypto/lib/native/cipher.js:113:9)
    at decrypt (/home/dos/git/hs-airdrop/node_modules/bcrypto/lib/ssh.js:1110:17)
    at SSHPrivateKey.decodeSSH (/home/dos/git/hs-airdrop/node_modules/bcrypto/lib/ssh.js:462:17)
    at SSHPrivateKey.fromString (/home/dos/git/hs-airdrop/node_modules/bcrypto/lib/ssh.js:712:21)
    at Function.fromString (/home/dos/git/hs-airdrop/node_modules/bufio/lib/struct.js:155:23)
    at readKey (/home/dos/git/hs-airdrop/bin/hs-airdrop:412:33)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

Decoding the key manually to not contain a passphrase allows hs-airdrop to proceed further.

I've also tested with a passphrase-protected rsa key and it worked.

dos1 avatar Apr 05 '19 19:04 dos1

I met the same issue.

heroxbd avatar Feb 19 '20 02:02 heroxbd

I have the same issue like in the title description, but a different error message:

./bin/hs-airdrop ~/.ssh/id_ed25519 hs1.......

Passphrase:

Error: Invalid padding.
    at RawPrivateKey.read (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/node_modules/bcrypto/lib/ssh.js:1006:13)
    at RawPrivateKey.decode (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/node_modules/bufio/lib/struct.js:94:10)
    at Function.decode (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/node_modules/bufio/lib/struct.js:147:23)
    at SSHPrivateKey.decodeSSH (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/node_modules/bcrypto/lib/ssh.js:473:32)
    at SSHPrivateKey.fromString (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/node_modules/bcrypto/lib/ssh.js:717:21)
    at Function.fromString (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/node_modules/bufio/lib/struct.js:159:23)
    at readKey (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/bin/hs-airdrop:545:33)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async parseArgs (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/bin/hs-airdrop:729:21)
    at async main (/tmp/handshake/download/hs-airdrop-0.9.0/hs-airdrop/bin/hs-airdrop:755:19)

hexagon6 avatar Sep 25 '20 07:09 hexagon6

Fixed by removing lines 1005 & 1006 which throws this error https://github.com/bcoin-org/bcrypto/blame/master/lib/ssh.js#L1005

hexagon6 avatar Sep 25 '20 07:09 hexagon6

@hexagon6 did claim work that way? i think this is where i had given up on my last attempt, but it's reassuring to find out it may still be possible with fixes to just the airdrop tool

brandondees avatar Sep 25 '20 07:09 brandondees

@brandondees yes!

$ ./bin/hs-airdrop ~/.ssh/my_github_key hs1mywalletaddress
Passphrase:
Attempting to create proof.
This may take a bit.
Decrypting nonce...
Downloading: https://github.com/handshake-org/hs-tree-data/raw/master/nonces/017.bin...
Found nonce!
Rebuilding tree...
Downloading: https://github.com/handshake-org/hs-tree-data/raw/master/tree.bin...
Finding merkle leaf for reward 0...

4 keys found in your subtree:
....
hs-client-0.0.9/hs-client$ ./bin/hsw-cli balance
{
  "account": -1,
  "tx": 1,
  "coin": 1,
  "unconfirmed": 4246894314,
  "confirmed": 4246894314,
  "lockedUnconfirmed": 0,
  "lockedConfirmed": 0
}

hexagon6 avatar Sep 28 '20 06:09 hexagon6

This still seems to be an issue today with ed25519 keys.

alxjsn avatar May 10 '21 14:05 alxjsn

Yep, same issue here. I just removed the passphrase with ssh-keygen -p -f meykey_ed25519 and set it to an empty one to make it work.

dewey avatar May 12 '21 13:05 dewey