handshake-org / hs-airdrop

Decentralized airdrop to open source developers
Other
1.4k stars 169 forks source link

Error: Hi bit unset in PGP packet header. #40

Closed yuangezhizao closed 4 years ago

yuangezhizao commented 4 years ago

Hi,i use my PGP key but a error occur.

# node -v
v13.8.0
# npm -v
6.13.7

At first i export my private key like this.

C:\Users\yuangezhizao>gpg -K
C:/Users/yuangezhizao/AppData/Roaming/gnupg/pubring.kbx
-------------------------------------------------------
sec   rsa2048 2018-09-29 [SC] [expires: 2020-09-29]
      CDBEC3268512836F92AA92DCED075DCBF4BFFD51
uid           [ultimate] yuangezhizao <root@yuangezhizao.cn>
ssb   rsa2048 2018-09-29 [E] [expires: 2020-09-29]
C:\Users\yuangezhizao>gpg -a -o secring.gpg  --export-secret-keys CDBEC3268512836F92AA92DCED075DCBF4BFFD51

Then,i use the hs-airdrop command tools.

# ./bin/hs-airdrop ../secring.gpg CDBEC3268512836F92AA92DCED075DCBF4BFFD51 <rm> 0.01  
Error: Hi bit unset in PGP packet header.
    at PGPPacket.read (/root/workspace/hs-airdrop/node_modules/bcrypto/lib/pgp.js:368:13)
    at Function.read (/root/workspace/hs-airdrop/node_modules/bufio/lib/struct.js:139:23)
    at PGPMessage.read (/root/workspace/hs-airdrop/node_modules/bcrypto/lib/pgp.js:278:29)
    at PGPMessage.decode (/root/workspace/hs-airdrop/node_modules/bufio/lib/struct.js:91:10)
    at Function.decode (/root/workspace/hs-airdrop/node_modules/bufio/lib/struct.js:143:23)
    at readKey (/root/workspace/hs-airdrop/bin/hs-airdrop:529:30)
    at async parseArgs (/root/workspace/hs-airdrop/bin/hs-airdrop:702:21)
    at async main (/root/workspace/hs-airdrop/bin/hs-airdrop:740:19)

So,how to fix it? Thanks.

boymanjor commented 4 years ago

@yuangezhizao can you try exporting your key in binary format, i.e. unarmored.

gaoyichuan commented 4 years ago

I got an error says Error: Unknown S2K function. after export my seckey unarmored using GnuPG2, could you help?

Edit: my exported key file is: secring.gpg: PGP Secret Key - 4096b created on Fri Apr 8 06:40:52 2016 - RSA (Encrypt or Sign) e=65537 hashed AES with 128-bit key Salted&Iterated S2K SHA-1

And cat secring.gpg | gpg --list-packets | grep S2K shows:

        iter+salt S2K, algo: 7, SHA1 protection, hash: 2, salt: 91CA7001942645F2
        iter+salt S2K, algo: 7, SHA1 protection, hash: 2, salt: 305FCA3BCE1AD8DB
        gnu-divert-to-card S2K, algo: 0, simple checksum, hash: 0
        gnu-divert-to-card S2K, algo: 0, simple checksum, hash: 0
        gnu-divert-to-card S2K, algo: 0, simple checksum, hash: 0
        gnu-divert-to-card S2K, algo: 0, simple checksum, hash: 0
boymanjor commented 4 years ago

@yuangezhizao can you try exporting your key in binary format, i.e. unarmored.

@yuangezhizao lternatively, you can use a .asc extension on the armored file. It looks like hs-airdrop expects .gpg files to be in binary format, while armored files should have .asc extensions.

yuangezhizao commented 4 years ago

@boymanjor It works,thanks a lot!

C:\Users\yuangezhizao>gpg --armor --output secret.asc --export-secret-keys CDBEC3268512836F92AA92DCED075DCBF4BFFD51
# ./bin/hs-airdrop ../secret.asc CDBEC3268512836F92AA92DCED075DCBF4BFFD51 <rm> 0.01
I found key 0xCDBEC3268512836F92AA92DCED075DCBF4BFFD51, but it's encrypted.
Passphrase: 
Attempting to create proof.
This may take a bit.
Decrypting nonce...
NonceError: Could not find nonce in bucket 180.
    at findNonces (/root/workspace/hs-airdrop/bin/hs-airdrop:275:17)
    at async createKeyProofs (/root/workspace/hs-airdrop/bin/hs-airdrop:328:17)
    at async main (/root/workspace/hs-airdrop/bin/hs-airdrop:746:8)

This means your key was not found in the airdrop tree.
If you registered at handshake.org, use that address.
Usage: $ hs-airdrop [addr]

However, unfortunately my key was not found. :joy: