{"action":"created","issue":{"url":"https://api.github.com/repos/romanz/trezor-agent/issues/52","repository_url":"https://api.github.com/repos/romanz/trezor-agent","labels_url":"https://api.github.com/repos/romanz/trezor-agent/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/romanz/trezor-agent/issues/52/comments","events_url":"https://api.github.com/repos/romanz/trezor-agent/issues/52/events","html_url":"https://github.com/romanz/trezor-agent/issues/52","id":183294419,"number":52,"title":"AssertionError - Keygrip mismatch at `trezor-gpg agent` during sign operation","user":{"login":"fruitloop","id":5485777,"avatar_url":"https://avatars.githubusercontent.com/u/5485777?v=3","gravatar_id":"","url":"https://api.github.com/users/fruitloop","html_url":"https://github.com/fruitloop","followers_url":"https://api.github.com/users/fruitloop/followers","following_url":"https://api.github.com/users/fruitloop/following{/other_user}","gists_url":"https://api.github.com/users/fruitloop/gists{/gist_id}","starred_url":"https://api.github.com/users/fruitloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fruitloop/subscriptions","organizations_url":"https://api.github.com/users/fruitloop/orgs","repos_url":"https://api.github.com/users/fruitloop/repos","events_url":"https://api.github.com/users/fruitloop/events{/privacy}","received_events_url":"https://api.github.com/users/fruitloop/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/romanz/trezor-agent/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/romanz/trezor-agent/labels/GPG","name":"GPG","color":"0052cc"},{"url":"https://api.github.com/repos/romanz/trezor-agent/labels/MacOS","name":"MacOS","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"romanz","id":9900,"avatar_url":"https://avatars.githubusercontent.com/u/9900?v=3","gravatar_id":"","url":"https://api.github.com/users/romanz","html_url":"https://github.com/romanz","followers_url":"https://api.github.com/users/romanz/followers","following_url":"https://api.github.com/users/romanz/following{/other_user}","gists_url":"https://api.github.com/users/romanz/gists{/gist_id}","starred_url":"https://api.github.com/users/romanz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romanz/subscriptions","organizations_url":"https://api.github.com/users/romanz/orgs","repos_url":"https://api.github.com/users/romanz/repos","events_url":"https://api.github.com/users/romanz/events{/privacy}","received_events_url":"https://api.github.com/users/romanz/received_events","type":"User","site_admin":false},"assignees":[{"login":"romanz","id":9900,"avatar_url":"https://avatars.githubusercontent.com/u/9900?v=3","gravatar_id":"","url":"https://api.github.com/users/romanz","html_url":"https://github.com/romanz","followers_url":"https://api.github.com/users/romanz/followers","following_url":"https://api.github.com/users/romanz/following{/other_user}","gists_url":"https://api.github.com/users/romanz/gists{/gist_id}","starred_url":"https://api.github.com/users/romanz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romanz/subscriptions","organizations_url":"https://api.github.com/users/romanz/orgs","repos_url":"https://api.github.com/users/romanz/repos","events_url":"https://api.github.com/users/romanz/events{/privacy}","received_events_url":"https://api.github.com/users/romanz/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-10-16T21:55:18Z","updated_at":"2016-10-17T08:58:51Z","closed_at":null,"body":"Hi, \r\nMy Setup is: OS X 10.11.5, trezor (0.7.4), trezor-agent (0.7.2), Trezor Firmware 1.4.0\r\n\r\nWhen I use trezor-gpg -v agent, I sometimes get this error:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/local/bin/trezor-gpg\", line 11, in <module>\r\n    sys.exit(main())\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/__main__.py\", line 95, in main\r\n    args.run(args)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/__main__.py\", line 69, in run_agent\r\n    agent.handle_connection(conn)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/agent.py\", line 121, in handle_connection\r\n    sig = pksign(keygrip, digest, algo)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/agent.py\", line 49, in pksign\r\n    assert pubkey.keygrip == binascii.unhexlify(keygrip)\r\nAssertionError\r\n```\r\nSometimes everything works fine for two or three times, and then I get this error for the rest of the day.\r\n\r\nIs there something wrong with my Python installation?\r\n\r\nBest Regards\r\nRoland"},"comment":{"url":"https://api.github.com/repos/romanz/trezor-agent/issues/comments/254151286","html_url":"https://github.com/romanz/trezor-agent/issues/52#issuecomment-254151286","issue_url":"https://api.github.com/repos/romanz/trezor-agent/issues/52","id":254151286,"user":{"login":"fruitloop","id":5485777,"avatar_url":"https://avatars.githubusercontent.com/u/5485777?v=3","gravatar_id":"","url":"https://api.github.com/users/fruitloop","html_url":"https://github.com/fruitloop","followers_url":"https://api.github.com/users/fruitloop/followers","following_url":"https://api.github.com/users/fruitloop/following{/other_user}","gists_url":"https://api.github.com/users/fruitloop/gists{/gist_id}","starred_url":"https://api.github.com/users/fruitloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fruitloop/subscriptions","organizations_url":"https://api.github.com/users/fruitloop/orgs","repos_url":"https://api.github.com/users/fruitloop/repos","events_url":"https://api.github.com/users/fruitloop/events{/privacy}","received_events_url":"https://api.github.com/users/fruitloop/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T08:58:51Z","updated_at":"2016-10-17T08:58:51Z","body":"Hi, thanks for the fast response\r\n\r\n```\r\n[roland@Turtle:~] % gpg2 -k --with-keygrip github\r\npub   nistp256 2016-10-16 [SC]\r\n      7E9266BFAA9BE177D92DDAFB51F3833053F2E698\r\n      Keygrip = DAB26946E82099931400D154BB197035B5324F5C\r\nuid           [ultimate] Roland Planitz <github@planitz.at>\r\nsub   nistp256 2016-10-16 [E]\r\n      Keygrip = C3A0AB22ECBD28F010F44DB387892A2C4A586AD6\r\n```\r\n\r\n```\r\n[roland@Turtle:~] % gpg2 --export github | gpg2 --list-packets \r\n# off=0 ctb=98 tag=6 hlen=2 plen=82\r\n:public key packet:\r\n\tversion 4, algo 19, created 1476651084, expires 0\r\n\tpkey[0]: [72 bits] nistp256 (1.2.840.10045.3.1.7)\r\n\tpkey[1]: [515 bits]\r\n\tkeyid: 51F3833053F2E698\r\n# off=84 ctb=b4 tag=13 hlen=2 plen=34\r\n:user ID packet: \"Roland Planitz <github@planitz.at>\"\r\n# off=120 ctb=88 tag=2 hlen=2 plen=121\r\n:signature packet: algo 19, keyid 51F3833053F2E698\r\n\tversion 4, created 1476651084, md5len 0, sigclass 0x13\r\n\tdigest algo 8, begin of digest 6c 53\r\n\thashed subpkt 2 len 4 (sig created 2016-10-16)\r\n\thashed subpkt 11 len 1 (pref-sym-algos: 9)\r\n\thashed subpkt 27 len 1 (key flags: 03)\r\n\thashed subpkt 21 len 1 (pref-hash-algos: 8)\r\n\thashed subpkt 22 len 1 (pref-zip-algos: 0)\r\n\thashed subpkt 23 len 1 (keyserver preferences: 80)\r\n\tsubpkt 16 len 8 (issuer key ID 51F3833053F2E698)\r\n\tsubpkt 100 len 10 (experimental / private subpacket)\r\n\tdata: [256 bits]\r\n\tdata: [255 bits]\r\n# off=243 ctb=b8 tag=14 hlen=2 plen=86\r\n:public sub key packet:\r\n\tversion 4, algo 18, created 1476651084, expires 0\r\n\tpkey[0]: [72 bits] nistp256 (1.2.840.10045.3.1.7)\r\n\tpkey[1]: [515 bits]\r\n\tpkey[2]: [32 bits]\r\n\tkeyid: 6DACEBD50DF117C4\r\n# off=331 ctb=88 tag=2 hlen=2 plen=109\r\n:signature packet: algo 19, keyid 51F3833053F2E698\r\n\tversion 4, created 1476651084, md5len 0, sigclass 0x18\r\n\tdigest algo 8, begin of digest 7f ac\r\n\thashed subpkt 2 len 4 (sig created 2016-10-16)\r\n\thashed subpkt 27 len 1 (key flags: 0C)\r\n\tsubpkt 16 len 8 (issuer key ID 51F3833053F2E698)\r\n\tsubpkt 100 len 10 (experimental / private subpacket)\r\n\tdata: [255 bits]\r\n\tdata: [255 bits]\r\n```\r\n\r\nI updated trezor-agent and ran it again\r\n```\r\n2016-10-17 10:49:02,149 WARNING    This GPG tool is still in EXPERIMENTAL mode, so please note that the API and features may change without backwards compatibility!\r\n2016-10-17 10:49:02,169 DEBUG      serving on SSH_AUTH_SOCK=/Users/roland/.gnupg/S.gpg-agent\r\n2016-10-17 10:49:02,169 DEBUG      waiting for connection on /Users/roland/.gnupg/S.gpg-agent\r\n2016-10-17 10:49:05,783 DEBUG      accepted connection on /Users/roland/.gnupg/S.gpg-agent\r\n2016-10-17 10:49:05,802 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,803 DEBUG      -> 'RESET'\r\n2016-10-17 10:49:05,803 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,803 DEBUG      -> 'OPTION ttytype=xterm'\r\n2016-10-17 10:49:05,803 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,811 DEBUG      -> 'GETINFO version'\r\n2016-10-17 10:49:05,811 DEBUG      <- 'D 2.1.15'\r\n2016-10-17 10:49:05,811 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,812 DEBUG      -> 'OPTION allow-pinentry-notify'\r\n2016-10-17 10:49:05,812 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,812 DEBUG      -> 'OPTION agent-awareness=2.1.0'\r\n2016-10-17 10:49:05,813 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,813 DEBUG      -> 'AGENT_ID'\r\n2016-10-17 10:49:05,813 DEBUG      <- 'D TREZOR'\r\n2016-10-17 10:49:05,813 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,816 DEBUG      -> 'HAVEKEY E8AAD7A22972124DB68075FD64F070D221C2FD67 D7A218E5A497B42CEF3BC9C0F33BE9C1BA4AC619'\r\n2016-10-17 10:49:05,816 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,819 DEBUG      -> 'RESET'\r\n2016-10-17 10:49:05,820 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,820 DEBUG      -> 'SIGKEY E8AAD7A22972124DB68075FD64F070D221C2FD67'\r\n2016-10-17 10:49:05,820 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,821 DEBUG      -> 'SETKEYDESC Please+enter+the+passphrase+to+unlock+the+OpenPGP+secret+key:%0A%22Roland+Planitz+<roland@planitz.at>%22%0A256-bit+ECDSA+key,+ID+44F2BB535E654B16,%0Acreated+2016-10-16.%0A'\r\n2016-10-17 10:49:05,821 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,822 DEBUG      -> 'SETHASH 8 CC863C7F00CF0CC7CC327F0EA39732FC532DF137250DBE750F8D0AC2E8C4E2EE'\r\n2016-10-17 10:49:05,822 DEBUG      <- 'OK'\r\n2016-10-17 10:49:05,822 DEBUG      -> 'PKSIGN'\r\n2016-10-17 10:49:05,836 DEBUG      prefix byte: 0b10011000\r\n2016-10-17 10:49:05,837 DEBUG      packet length: 82\r\n2016-10-17 10:49:05,837 DEBUG      parsing elliptic curve key\r\n2016-10-17 10:49:05,838 DEBUG      mpi: 4449154ddcc2460afd028cfb0224aff70342becb57f21698b042c423d0ffe8a1d74036d5ad0ad6a6d936ae2229063f440c79953a44f6eb420c76708f2839dcacd (515 bits)\r\n2016-10-17 10:49:05,917 DEBUG      key ID: 51F3833053F2E698\r\n2016-10-17 10:49:05,917 DEBUG      packet \"pubkey\": {'created': 1476651084, 'verifying_key': <ecdsa.keys.VerifyingKey instance at 0x10988ccf8>, 'tag': 6, 'curve_oid': '*\\x86H\\xce=\\x03\\x01\\x07', 'verifier': <function _nist256p1_verify at 0x1098a00c8>, 'version': 4, 'algo': 19, 'key_id': 'Q\\xf3\\x830S\\xf2\\xe6\\x98', 'type': 'pubkey', '_to_hash': '\\x99\\x00R\\x04X\\x03\\xe8L\\x13\\x08*\\x86H\\xce=\\x03\\x01\\x07\\x02\\x03\\x04D\\x91T\\xdd\\xcc$`\\xaf\\xd0(\\xcf\\xb0\"J\\xffp4+\\xec\\xb5\\x7f!i\\x8b\\x04,B=\\x0f\\xfe\\x8a\\x1dt\\x03mZ\\xd0\\xadjm\\x93j\\xe2\"\\x90c\\xf4@\\xc7\\x99S\\xa4On\\xb4 \\xc7g\\x08\\xf2\\x83\\x9d\\xca\\xcd'}\r\n2016-10-17 10:49:05,918 DEBUG      prefix byte: 0b10110100\r\n2016-10-17 10:49:05,918 DEBUG      packet length: 34\r\n2016-10-17 10:49:05,918 DEBUG      packet \"user_id\": {'tag': 13, 'type': 'user_id', 'value': 'Roland Planitz <github@planitz.at>', '_to_hash': '\\xb4\\x00\\x00\\x00\"Roland Planitz <github@planitz.at>'}\r\n2016-10-17 10:49:05,918 DEBUG      prefix byte: 0b10001000\r\n2016-10-17 10:49:05,919 DEBUG      packet length: 121\r\n2016-10-17 10:49:05,919 DEBUG      packet \"signature\": {'hash_prefix': 'lS', 'hashed_subpackets': ['\\x02X\\x03\\xe8L', '\\x0b\\t', '\\x1b\\x03', '\\x15\\x08', '\\x16\\x00', '\\x17\\x80'], 'pubkey_alg': 19, '_is_custom': True, 'hash_alg': 8, 'tag': 2, 'sig_type': 19, 'version': 4, 'sig': (102528692007018662478410427344616484795132055260561832797479366964600507666647L, 57719256278049600832974411777041248160917410385421014829423897735370847269749L), 'unhashed_subpackets': ['\\x10Q\\xf3\\x830S\\xf2\\xe6\\x98', 'dTREZOR-GPG'], 'type': 'signature', '_to_hash': '\\x04\\x13\\x13\\x08\\x00\\x15\\x05\\x02X\\x03\\xe8L\\x02\\x0b\\t\\x02\\x1b\\x03\\x02\\x15\\x08\\x02\\x16\\x00\\x02\\x17\\x80\\x04\\xff\\x00\\x00\\x00\\x1b'}\r\n2016-10-17 10:49:05,919 DEBUG      prefix byte: 0b10111000\r\n2016-10-17 10:49:05,919 DEBUG      packet length: 86\r\n2016-10-17 10:49:05,920 DEBUG      parsing elliptic curve key\r\n2016-10-17 10:49:05,920 DEBUG      mpi: 408933d7028f6ad2e099f00f84c52aabfee1d5ccd6fbd051d44f057a1d6263d4188ca607f310410116a21afbd83d2e73b4f97e40d178d0904097777c846997825 (515 bits)\r\n2016-10-17 10:49:05,987 DEBUG      key ID: 6DACEBD50DF117C4\r\n2016-10-17 10:49:05,987 DEBUG      packet \"subkey\": {'created': 1476651084, 'verifying_key': <ecdsa.keys.VerifyingKey instance at 0x10988cd40>, 'kdf': '\\x01\\x08\\x07', 'tag': 14, 'curve_oid': '*\\x86H\\xce=\\x03\\x01\\x07', 'verifier': <function _nist256p1_verify at 0x108e8eb18>, 'version': 4, 'algo': 18, 'key_id': 'm\\xac\\xeb\\xd5\\r\\xf1\\x17\\xc4', 'type': 'subkey', '_to_hash': '\\x99\\x00V\\x04X\\x03\\xe8L\\x12\\x08*\\x86H\\xce=\\x03\\x01\\x07\\x02\\x03\\x04\\x08\\x93=p(\\xf6\\xad.\\t\\x9f\\x00\\xf8LR\\xaa\\xbf\\xee\\x1d\\\\\\xcdo\\xbd\\x05\\x1dD\\xf0W\\xa1\\xd6&=A\\x88\\xca`\\x7f1\\x04\\x10\\x11j!\\xaf\\xbd\\x83\\xd2\\xe7;O\\x97\\xe4\\r\\x17\\x8d\\t\\x04\\tww\\xc8F\\x99x%\\x03\\x01\\x08\\x07'}\r\n2016-10-17 10:49:05,987 DEBUG      prefix byte: 0b10001000\r\n2016-10-17 10:49:05,987 DEBUG      packet length: 109\r\n2016-10-17 10:49:05,988 DEBUG      packet \"signature\": {'hash_prefix': '\\x7f\\xac', 'hashed_subpackets': ['\\x02X\\x03\\xe8L', '\\x1b\\x0c'], 'pubkey_alg': 19, '_is_custom': True, 'hash_alg': 8, 'tag': 2, 'sig_type': 24, 'version': 4, 'sig': (51411217383221898020449732713403463792152212539112153765469687666398206976286L, 52574456261918540967165567050963813670579719393906417307543590784493354206261L), 'unhashed_subpackets': ['\\x10Q\\xf3\\x830S\\xf2\\xe6\\x98', 'dTREZOR-GPG'], 'type': 'signature', '_to_hash': '\\x04\\x18\\x13\\x08\\x00\\t\\x05\\x02X\\x03\\xe8L\\x02\\x1b\\x0c\\x04\\xff\\x00\\x00\\x00\\x0f'}\r\n2016-10-17 10:49:05,988 DEBUG      loaded public key \"Roland Planitz <github@planitz.at>\"\r\n2016-10-17 10:49:06,129 DEBUG      nist256p1 ECDSA signature is OK (True)\r\n2016-10-17 10:49:06,129 DEBUG      GPG public key is OK\r\n2016-10-17 10:49:06,129 DEBUG      found custom pubkey\r\n2016-10-17 10:49:06,130 DEBUG      pubkey_dict: {'user_id': 'Roland Planitz <github@planitz.at>', '_is_custom': True, 'created': 1476651084, 'verifying_key': <ecdsa.keys.VerifyingKey instance at 0x10988ccf8>, 'tag': 6, 'curve_oid': '*\\x86H\\xce=\\x03\\x01\\x07', 'verifier': <function _nist256p1_verify at 0x1098a00c8>, 'version': 4, 'algo': 19, 'key_id': 'Q\\xf3\\x830S\\xf2\\xe6\\x98', 'type': 'pubkey', '_to_hash': '\\x99\\x00R\\x04X\\x03\\xe8L\\x13\\x08*\\x86H\\xce=\\x03\\x01\\x07\\x02\\x03\\x04D\\x91T\\xdd\\xcc$`\\xaf\\xd0(\\xcf\\xb0\"J\\xffp4+\\xec\\xb5\\x7f!i\\x8b\\x04,B=\\x0f\\xfe\\x8a\\x1dt\\x03mZ\\xd0\\xadjm\\x93j\\xe2\"\\x90c\\xf4@\\xc7\\x99S\\xa4On\\xb4 \\xc7g\\x08\\xf2\\x83\\x9d\\xca\\xcd'}\r\n2016-10-17 10:49:06,300 DEBUG      connected to Trezor 79D99D130E0C8CA632F860E3\r\n2016-10-17 10:49:06,300 DEBUG      label    : planitz\r\n2016-10-17 10:49:06,300 DEBUG      vendor   : bitcointrezor.com\r\n2016-10-17 10:49:06,301 DEBUG      version  : 1.4.0\r\n2016-10-17 10:49:06,301 DEBUG      revision : e0e190b3dc29bcb0f6ab9699c439fe7bfbcde370\r\n2016-10-17 10:49:06,365 DEBUG      address string: '\\x00\\x00\\x00\\x00gpg://Roland Planitz <github@planitz.at>'\r\nUse the numeric keypad to describe number positions. The layout is:\r\n    7 8 9\r\n    4 5 6\r\n    1 2 3\r\nPlease enter current PIN: \r\n\r\n2016-10-17 10:49:16,635 INFO       GPG public key nist256p1/53F2E698 created at 2016-10-16 22:51:24 for \"Roland Planitz <github@planitz.at>\"\r\nTraceback (most recent call last):\r\n  File \"/usr/local/bin/trezor-gpg\", line 11, in <module>\r\n    sys.exit(main())\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/__main__.py\", line 95, in main\r\n    args.run(args)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/__main__.py\", line 69, in run_agent\r\n    agent.handle_connection(conn)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/agent.py\", line 121, in handle_connection\r\n    sig = pksign(keygrip, digest, algo)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/agent.py\", line 49, in pksign\r\n    assert pubkey.keygrip == binascii.unhexlify(keygrip)\r\nAssertionError\r\n```\r\nI didn't see the debug code you added however.\r\n\r\nBut when I tried it a second time (restarted trezor-gpg -v agent in one terminal and reran the git --gpg-sign command in the second) the agent crashed with a whole new exception.\r\n\r\nI opened another issue here: https://github.com/romanz/trezor-agent/issues/53\r\n\r\nBest regards\r\nRoland"}}
{"actor":{"display_login":"fruitloop"}}