Blockstream/satellite

api_data_reader.py fails to decrypt, error: public key decryption failed: Screen or window too small

remyers opened this issue · 1 comments

I've seen two issue that I think are related:

  1. I had to set the GPG_TTY environment variable for generate_keys.py to work from my console.

  2. I think there's a similar problem with api_data_reader.py because it fails to decrypt a message sent by api_data_sender.py even though both are accessing the same .gnupg directory and keys. It appears that gpg wants to prompt for a passphrase and fails due to a tty issue.

I'm using a MacOS terminal and installed python 2 with brew.

Debug output is below, key error from api_data_reader.py is:
DEBUG:gnupg:gpg: public key decryption failed: Screen or window too small

GPG key:

(blocksat-api) macbook-pro-5:examples richard$ gpg --homedir .gnupg -k
gpg: WARNING: unsafe permissions on homedir '/Users/richard/Documents/blockstream/satellite/api/examples/.gnupg'
/Users/richard/Documents/blockstream/satellite/api/examples/.gnupg/pubring.kbx
------------------------------------------------------------------------------
pub   rsa1024 2019-04-11 [SCEA]
      AB0B1948A037E40A3E12645F0888963AFFA2861B
uid           [ultimate] txtenna (blocksat) <rich@gotenna.com>

Terminal 1: (api_data_sender.py)

(blocksat-api) macbook-pro-5:examples richard$ ./api_data_sender.py --gnupghome .gnupg -f manifesto.txt --net test --debug
DEBUG:root:[Debug Mode]
DEBUG:gnupg:2907: gpg --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir .gnupg --version
DEBUG:gnupg:stderr reader: <Thread(Thread-1, initial daemon)>
DEBUG:gnupg:stdout reader: <Thread(Thread-2, initial daemon)>
DEBUG:gnupg:chunk: 'gpg (GnuPG) 2.2.15\nlibgcrypt 1.8.4\nCopyright (C) 2019 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to '
DEBUG:gnupg:gpg: WARNING: unsafe permissions on homedir '/Users/richard/Documents/blockstream/satellite/api/examples/.gnupg'
DEBUG:gnupg:2908: gpg --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir .gnupg --list-keys --fingerprint --fingerprint
DEBUG:gnupg:stderr reader: <Thread(Thread-3, initial daemon)>
DEBUG:gnupg:stdout reader: <Thread(Thread-4, initial daemon)>
DEBUG:gnupg:chunk: 'tru::1:1555019683:0:3:1:5\npub:u:1024:1:0888963AFFA2861B:1555019666:::u:::escaESCA::::::::0:\nfpr:::::::::AB0B1948A037E40A3E12645F0888963AFFA2861B:\nuid:u::::1555019666::E8761726D5EE3F79F93927C97FBE588956728CC9::txtenna (blocksat) <rich@gotenna.com>::::::::::'
DEBUG:gnupg:gpg: WARNING: unsafe permissions on homedir '/Users/richard/Documents/blockstream/satellite/api/examples/.gnupg'
DEBUG:gnupg:line: u'tru::1:1555019683:0:3:1:5'
DEBUG:gnupg:line: u'pub:u:1024:1:0888963AFFA2861B:1555019666:::u:::escaESCA::::::::0:'
DEBUG:gnupg:line: u'fpr:::::::::AB0B1948A037E40A3E12645F0888963AFFA2861B:'
DEBUG:gnupg:line: u'uid:u::::1555019666::E8761726D5EE3F79F93927C97FBE588956728CC9::txtenna (blocksat) <rich@gotenna.com>::::::::::0:'
File has 5156 bytes
Packed in data structure with a total of 5416 bytes
DEBUG:gnupg:2909: gpg --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir .gnupg --encrypt --recipient AB0B1948A037E40A3E12645F0888963AFFA2861B --armor
DEBUG:gnupg:data copier: <Thread(Thread-5, initial daemon)>, <_io.BytesIO object at 0x107331770>, <open file '<fdopen>', mode 'wb' at 0x1071c79c0>
DEBUG:gnupg:closed output, 5416 bytes sent
DEBUG:gnupg:stderr reader: <Thread(Thread-6, initial daemon)>
DEBUG:gnupg:stdout reader: <Thread(Thread-7, initial daemon)>
DEBUG:gnupg:gpg: WARNING: unsafe permissions on homedir '/Users/richard/Documents/blockstream/satellite/api/examples/.gnupg'
DEBUG:gnupg:[GNUPG:] KEY_CONSIDERED AB0B1948A037E40A3E12645F0888963AFFA2861B 2
DEBUG:gnupg:chunk: '-----BEGIN PGP MESSAGE-----\n\nhIwDCIiWOv+ihhsBBACkye5s7CkKqJ2kFj4NSEliIRz3Zg/tKuvx/pKaJ7MPsx7h\nzi1Uv5dWxkJ4iAcNt65PSzssajOx7vLs5NPTPQY+CnyQKJ687OX1oSNbh8AzV8nu\nj53LVM4MSdXlceHmJ9/0oTnz/WvqURODnwc84Yuoz6LA3u9QwpGYMwQxqf5I1NLr\nAW/9uvAQ02CBwWIo1MJgKiYEDVPvGxms'
DEBUG:gnupg:[GNUPG:] PROGRESS need_entropy X 8 32
DEBUG:gnupg:chunk: 'ilHJ3zl80++QFCAuDldVNRGTxxq742CdvP8FFi8y8KUr\nNU4v/pIOWwbDnRfVtRiIcwh4UW3rFFRL0MbMTt/j4WAa2z8SENMLAGcTZ+ldyg/l\nDX0ug3NvtdQgCKKz+wd8ImmsTaSJ1q/eNVTeokLh9+cNmtzprBiI07qoYa3ig1qs\n3mDzILjRmLnw3FGD1x7vBjhXkQQnRYpR4KYyz1ONb4EH3PBZOqbnbV8FYTbqxKmH\nBZoX76nQBWNbxLAq'
DEBUG:gnupg:message ignored: PROGRESS, need_entropy X 8 32
DEBUG:gnupg:chunk: 'tt+Tbb/BH4kXseOwzzR5CC5G/w5ohJS6WspJHF5BFw/cpP3fBv0L0n2K4DWt\nbhxpcJQDSJwg5Uz4B4EBq72TXbZ6jMMe6U109cBVGMASbpatxB683jGiRC3A0KVR\n7FtRhUPHERdS2o6aBHYVs4fyBEDB0PhdEW4v6rq1Q4IBJ7UBx1LDr4Yftp33L5fl\nHWINWGWtyFNdeEsSGHc/WK/nmqKy6deokk9kAxSdGh+NwqfIUTuviThyzH10To32\n'
DEBUG:gnupg:[GNUPG:] PROGRESS need_entropy X 32 32
DEBUG:gnupg:message ignored: PROGRESS, need_entropy X 32 32
DEBUG:gnupg:chunk: 'BQ2G/IiDN28\nnLiy4EHjDG1JSnHiEZcRt/Uf5LuJtd8qorciHQNJTO8WAlxtw2ZHrdH9Q35mWZaV\ncGPlugJUFbCsCKEw739WTAihcV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XuLxVkJCxSJEb7K4VQwbXaAZcqOaAbSKx\nrJaeK7GHUYOtMkgy66b9qrUxxIv/KLCiUl1n6NIaLkbAMUHyOofO7GFXWvUsJafN\n1NuLTjIocEkjbJY+u+Wo9+4eyFWwl2wo3+G/kNZWTBwqDbSCfrGZQBQ2G/IiDN28\nnLiy4EHjDG1JSnHiEZcRt/Uf5LuJtd8qorciHQNJTO8WAlxtw2ZHrdH9Q35mWZaV\ncGPlugJUFbCsCKEw739WTAihcVdQhoCYGGUpQy/dqtKUuqb1Hst+ziI6C8qHgnDf\nNW3UX/74XgCBlzZl1Q8I+7GyP+CXHkr/El47t0mExJ9R2LQgYKqpyM7Wkeregcxv\nJDfVmxj57nqHd8sZ76QvNp05Qk+BRMXtsbm8ctXGd3XOOsk=\n=FpL5\n-----END PGP MESSAGE-----\n'
Encrypted version of the data structure has 3360 bytes
Satellite transmission will use 3392 bytes
Your bid to transmit 3392 bytes (in millisatoshis): [169600] 
Post data with bid of 169600 millisatoshis (50.00 msat/byte)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.blockstream.space:443
DEBUG:urllib3.connectionpool:https://api.blockstream.space:443 "POST /testnet/order HTTP/1.1" 200 881
Data successfully transmitted
--
Authentication Token:
56fae1383f2e61c0139b8552c36ff322376974b05ee94c2a0e535727b3fe3892
--
UUID:
84706831-b1e6-4ee8-b26e-298e73094488
--
Lightning Invoice Number:
lntb1696n1pwtqsrspp5rsuy4vjndj56q2u5pq667glml68rau2fc62w6nycauptz3f5wmlsdphgfkx7cmtwd68yetpd5s9xct5v4kxc6t5v5s9gunpdeek66tnwd5k7mscqp2rzjqt24x3myn9ytymg8gu0sqefdxllyxd3jgystzexte5x38y9srrequ93u7cqqqtcqqqqqqq02qqqqqzsqqcrtv5py86n9htq6gktun32l0jkzh0wf7r99sc6dmv3eph0jrvh9wpx4c0k9hj8htekuwgx9laanldzcp9vxyzrlltkfucyzwejmddq8spjtm9uf
--
Amount Due:
169600 millisatoshis

DEBUG:root:API Response:
DEBUG:root:{
    "auth_token": "56fae1383f2e61c0139b8552c36ff322376974b05ee94c2a0e535727b3fe3892", 
    "lightning_invoice": {
        "created_at": 1555054704, 
        "description": "Blockstream Satellite Transmission", 
        "expires_at": 1555058304, 
        "id": "1a7hU5hOgKUyqZO3OLKum", 
        "metadata": {
            "sha256_message_digest": "c45ce72c460a674f441b3cee7f5b2437126a97a0bda8d625a32325ab4169cce1", 
            "uuid": "84706831-b1e6-4ee8-b26e-298e73094488"
        }, 
        "msatoshi": "169600", 
        "payreq": "lntb1696n1pwtqsrspp5rsuy4vjndj56q2u5pq667glml68rau2fc62w6nycauptz3f5wmlsdphgfkx7cmtwd68yetpd5s9xct5v4kxc6t5v5s9gunpdeek66tnwd5k7mscqp2rzjqt24x3myn9ytymg8gu0sqefdxllyxd3jgystzexte5x38y9srrequ93u7cqqqtcqqqqqqq02qqqqqzsqqcrtv5py86n9htq6gktun32l0jkzh0wf7r99sc6dmv3eph0jrvh9wpx4c0k9hj8htekuwgx9laanldzcp9vxyzrlltkfucyzwejmddq8spjtm9uf", 
        "rhash": "1c384ab2536ca9a02b940835af23fbfe8e3ef149c694ed4c98ef02b1453476ff", 
        "status": "unpaid"
    }, 
    "uuid": "84706831-b1e6-4ee8-b26e-298e73094488"
}
(blocksat-api) macbook-pro-5:examples richard$ 

Terminal 2: (api_data_reader.py)

DEBUG:root:Total data length is ready in the read buffer
DEBUG:gnupg:2812: gpg --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir .gnupg --decrypt
DEBUG:gnupg:data copier: <Thread(Thread-8, initial daemon)>, <_io.BytesIO object at 0x1034dce90>, <open file '<fdopen>', mode 'wb' at 0x1034adc00>
DEBUG:gnupg:stderr reader: <Thread(Thread-9, initial daemon)>
DEBUG:gnupg:closed output, 3364 bytes sent
DEBUG:gnupg:stdout reader: <Thread(Thread-10, initial daemon)>
DEBUG:gnupg:gpg: WARNING: unsafe permissions on homedir '/Users/richard/Documents/blockstream/satellite/api/examples/.gnupg'
DEBUG:gnupg:[GNUPG:] ENC_TO 0888963AFFA2861B 1 0
DEBUG:gnupg:[GNUPG:] KEY_CONSIDERED AB0B1948A037E40A3E12645F0888963AFFA2861B 0
DEBUG:gnupg:[GNUPG:] PINENTRY_LAUNCHED 2813 curses 1.1.0 /dev/ttys003 xterm-256color -
DEBUG:gnupg:[GNUPG:] KEY_CONSIDERED AB0B1948A037E40A3E12645F0888963AFFA2861B 0
DEBUG:gnupg:gpg: encrypted with 1024-bit RSA key, ID 0888963AFFA2861B, created 2019-04-11
DEBUG:gnupg:      "txtenna (blocksat) <rich@gotenna.com>"
DEBUG:gnupg:gpg: public key decryption failed: Screen or window too small
DEBUG:gnupg:[GNUPG:] ERROR pkdecrypt_failed 83886381
WARNING:gnupg:potential problem: ERROR: pkdecrypt_failed 83886381
DEBUG:gnupg:[GNUPG:] BEGIN_DECRYPTION
DEBUG:gnupg:[GNUPG:] DECRYPTION_FAILED
DEBUG:gnupg:gpg: decryption failed: No secret key
DEBUG:gnupg:[GNUPG:] END_DECRYPTION
DEBUG:gnupg:decrypt result: ''

I fixed this by changing the pinentry for my system to use pinentry-mac:

brew install pinentry-mac
cat pinentry-program /usr/local/bin/pinentry-mac > .gnupng/gpg-agent.conf
gpgconf --homedir .gnupg --reload