{"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":8,"created_at":"2016-10-16T21:55:18Z","updated_at":"2016-10-17T09:57:09Z","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/254164445","html_url":"https://github.com/romanz/trezor-agent/issues/52#issuecomment-254164445","issue_url":"https://api.github.com/repos/romanz/trezor-agent/issues/52","id":254164445,"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-17T09:57:08Z","updated_at":"2016-10-17T09:57:08Z","body":"```\r\n[roland@Turtle:~/git/trezor-gpg-test] % echo \"Hello World!\" | gpg2 --sign -u 7E9266BFAA9BE177D92DDAFB51F3833053F2E698 | gpg2 --verify\r\ngpg: Signature made Mon Oct 17 11:53:44 2016 CEST\r\ngpg:                using ECDSA key 51F3833053F2E698\r\ngpg: Good signature from \"Roland Planitz <github@planitz.at>\" [ultimate]\r\n```\r\nThat works fine, no crashes.\r\n\r\nI ran `it config --local user.signingkey 7E9266BFAA9BE177D92DDAFB51F3833053F2E698`\r\nand now my .git/config shows this:\r\n```\r\n...\r\n[gpg]\r\n\tprogram = gpg2\r\n[user]\r\n\tsigningkey = 7E9266BFAA9BE177D92DDAFB51F3833053F2E698\r\n```\r\n\r\nbut still:\r\n```\r\n[roland@Turtle:~] % clear;export TREZOR_GPG_USER_ID=\"Roland Planitz <github@planitz.at>\"; trezor-gpg -v agent\r\n\r\n2016-10-17 11:55:50,874 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 11:55:50,892 DEBUG      serving on SSH_AUTH_SOCK=/Users/roland/.gnupg/S.gpg-agent\r\n2016-10-17 11:55:50,893 DEBUG      waiting for connection on /Users/roland/.gnupg/S.gpg-agent\r\n2016-10-17 11:55:54,104 DEBUG      accepted connection on /Users/roland/.gnupg/S.gpg-agent\r\n2016-10-17 11:55:54,121 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,121 DEBUG      -> 'RESET'\r\n2016-10-17 11:55:54,121 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,122 DEBUG      -> 'OPTION ttytype=xterm'\r\n2016-10-17 11:55:54,122 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,129 DEBUG      -> 'GETINFO version'\r\n2016-10-17 11:55:54,130 DEBUG      <- 'D 2.1.15'\r\n2016-10-17 11:55:54,130 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,130 DEBUG      -> 'OPTION allow-pinentry-notify'\r\n2016-10-17 11:55:54,130 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,131 DEBUG      -> 'OPTION agent-awareness=2.1.0'\r\n2016-10-17 11:55:54,131 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,131 DEBUG      -> 'AGENT_ID'\r\n2016-10-17 11:55:54,131 DEBUG      <- 'D TREZOR'\r\n2016-10-17 11:55:54,131 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,133 DEBUG      -> 'HAVEKEY DAB26946E82099931400D154BB197035B5324F5C C3A0AB22ECBD28F010F44DB387892A2C4A586AD6'\r\n2016-10-17 11:55:54,133 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,136 DEBUG      -> 'RESET'\r\n2016-10-17 11:55:54,136 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,136 DEBUG      -> 'SIGKEY DAB26946E82099931400D154BB197035B5324F5C'\r\n2016-10-17 11:55:54,137 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,137 DEBUG      -> 'SETKEYDESC Please+enter+the+passphrase+to+unlock+the+OpenPGP+secret+key:%0A%22Roland+Planitz+<github@planitz.at>%22%0A256-bit+ECDSA+key,+ID+51F3833053F2E698,%0Acreated+2016-10-16.%0A'\r\n2016-10-17 11:55:54,137 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,138 DEBUG      -> 'SETHASH 8 741081A2EFD3D4AB55ED58080173E2CE9531B0E927014346716CD70C738B8691'\r\n2016-10-17 11:55:54,138 DEBUG      <- 'OK'\r\n2016-10-17 11:55:54,140 DEBUG      -> 'PKSIGN'\r\n2016-10-17 11:55:54,206 DEBUG      prefix byte: 0b10011000\r\n2016-10-17 11:55:54,207 DEBUG      packet length: 82\r\n2016-10-17 11:55:54,210 DEBUG      parsing elliptic curve key\r\n2016-10-17 11:55:54,211 DEBUG      mpi: 4449154ddcc2460afd028cfb0224aff70342becb57f21698b042c423d0ffe8a1d74036d5ad0ad6a6d936ae2229063f440c79953a44f6eb420c76708f2839dcacd (515 bits)\r\n2016-10-17 11:55:54,434 DEBUG      key ID: 51F3833053F2E698\r\n2016-10-17 11:55:54,435 DEBUG      packet \"pubkey\": {'created': 1476651084, 'verifying_key': <ecdsa.keys.VerifyingKey instance at 0x10fb85cf8>, 'tag': 6, 'curve_oid': '*\\x86H\\xce=\\x03\\x01\\x07', 'verifier': <function _nist256p1_verify at 0x10fb990c8>, '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 11:55:54,435 DEBUG      prefix byte: 0b10110100\r\n2016-10-17 11:55:54,435 DEBUG      packet length: 34\r\n2016-10-17 11:55:54,435 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 11:55:54,435 DEBUG      prefix byte: 0b10001000\r\n2016-10-17 11:55:54,436 DEBUG      packet length: 121\r\n2016-10-17 11:55:54,436 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 11:55:54,436 DEBUG      prefix byte: 0b10111000\r\n2016-10-17 11:55:54,436 DEBUG      packet length: 86\r\n2016-10-17 11:55:54,436 DEBUG      parsing elliptic curve key\r\n2016-10-17 11:55:54,437 DEBUG      mpi: 408933d7028f6ad2e099f00f84c52aabfee1d5ccd6fbd051d44f057a1d6263d4188ca607f310410116a21afbd83d2e73b4f97e40d178d0904097777c846997825 (515 bits)\r\n2016-10-17 11:55:54,494 DEBUG      key ID: 6DACEBD50DF117C4\r\n2016-10-17 11:55:54,494 DEBUG      packet \"subkey\": {'created': 1476651084, 'verifying_key': <ecdsa.keys.VerifyingKey instance at 0x10fb85d40>, 'kdf': '\\x01\\x08\\x07', 'tag': 14, 'curve_oid': '*\\x86H\\xce=\\x03\\x01\\x07', 'verifier': <function _nist256p1_verify at 0x10f187b18>, '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 11:55:54,494 DEBUG      prefix byte: 0b10001000\r\n2016-10-17 11:55:54,494 DEBUG      packet length: 109\r\n2016-10-17 11:55:54,495 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 11:55:54,495 DEBUG      loaded public key \"Roland Planitz <github@planitz.at>\"\r\n2016-10-17 11:55:54,628 DEBUG      nist256p1 ECDSA signature is OK (True)\r\n2016-10-17 11:55:54,628 DEBUG      GPG public key is OK\r\n2016-10-17 11:55:54,628 DEBUG      found custom pubkey\r\n2016-10-17 11:55:54,629 DEBUG      pubkey_dict: {'user_id': 'Roland Planitz <github@planitz.at>', '_is_custom': True, 'created': 1476651084, 'verifying_key': <ecdsa.keys.VerifyingKey instance at 0x10fb85cf8>, 'tag': 6, 'curve_oid': '*\\x86H\\xce=\\x03\\x01\\x07', 'verifier': <function _nist256p1_verify at 0x10fb990c8>, '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\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 47, in pksign\r\n    pubkey, conn = encode.load_from_public_key(pubkey_dict=pubkey_dict)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/encode.py\", line 119, in load_from_public_key\r\n    conn = device.HardwareSigner(user_id, curve_name=curve_name)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/gpg/device.py\", line 11, in __init__\r\n    self.client_wrapper = factory.load()\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/factory.py\", line 248, in load\r\n    device_list.extend(device)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezor_agent/factory.py\", line 27, in _load_client\r\n    connection = client_type(hid_transport(d))\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 361, in __init__\r\n    self.init_device()\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 368, in init_device\r\n    self.features = expect(proto.Features)(self.call)(proto.Initialize())\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 85, in wrapped_f\r\n    ret = f(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 98, in wrapped_f\r\n    return f(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 134, in call\r\n    resp = self.call_raw(msg)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 98, in wrapped_f\r\n    return f(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/client.py\", line 130, in call_raw\r\n    return self.transport.read_blocking()\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/transport.py\", line 68, in read_blocking\r\n    data = self._read()\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/transport.py\", line 128, in _read\r\n    (msg_type, datalen, data) = self.parse_first(chunk)\r\n  File \"/usr/local/lib/python2.7/site-packages/trezorlib/transport.py\", line 140, in parse_first\r\n    raise Exception(\"Unexpected magic characters\")\r\nException: Unexpected magic characters\r\n```\r\n"}}
{"actor":{"display_login":"fruitloop"}}