Commit Graph

448 Commits

Author SHA1 Message Date
Andrew Chow
0b870d8673 Document how to build the simulator 2019-01-14 17:31:16 -05:00
Andrew Chow
8f1dff2f04 Change Digital Bitbox test to use simulator 2019-01-14 17:31:16 -05:00
Andrew Chow
07c97716e7 Build digital bitbox simulator in setup_environment.sh 2019-01-14 17:31:16 -05:00
Andrew Chow
814d02db50 Implement support for communicating with a dbb simulator
Implements support for communicated with my dbb simulator which
has an open udp socket at port 35345
2019-01-14 17:31:16 -05:00
Andrew Chow
7e715273c5
Merge #104: Update digital bitbox encryption scheme for firmware v5 and bug fixes
7b9c137 Fix der serialization bug (Andrew Chow)
de4ff1e Update digital bitbox encryption scheme for firmware v5 (Andrew Chow)

Pull request description:

  Firmvware v5.0.0 changed how messages are encrypted and authenticated, so update the encryption methodolgy to handle that.

  The changes come from https://github.com/digitalbitbox/mcu/blob/master/py/dbb_utils.py with some minor changes to accommodate older firmware versions.

  A bug in DER serialization which is only used by the bitbox is also fixed here.

Tree-SHA512: 01063f76dd132a8ad6938def01196e122b0eec7df63aaa5d688f6618b56294ec192607bbff5e385a9a8edf9fd2576293886aeb7b2efbe417e56558be3e8e11f3
2019-01-14 17:30:48 -05:00
Andrew Chow
7b9c137e60 Fix der serialization bug 2019-01-14 16:55:38 -05:00
Andrew Chow
566645d6a9
Merge #106: More verbose test output indicating which tests for which devices pass tests
b404a50 Include the device type in test case output (Andrew Chow)
a0fa208 Show full test case names in output (Andrew Chow)

Pull request description:

  Increases the verbosity level of the test runner to 2 which outputs the `str()` representation of each test case. This includes the test name by default. This has been modified to also print out the device types for the tests in `test_devices.py`. This will allow us to be able to see what tests each device is passing so debugging is easier.

Tree-SHA512: bf454b98b6d8d5701bd51ea8eaace95891e02d2765df4ea016f854e7d9b4f8e9b56e44c7988b38a521bb72f07ac3f26145698de70b974d6a6bcda667b74c8899
2019-01-14 15:51:40 -05:00
Andrew Chow
b404a5050d Include the device type in test case output 2019-01-14 15:42:27 -05:00
Andrew Chow
a0fa20888a Show full test case names in output 2019-01-14 15:00:41 -05:00
Andrew Chow
1645b85f60
Merge #102: Finalize implementation of keepkey and add automated tests for it
8ddf434 Refactor tests to optionally have emulator start and stop for each test (Andrew Chow)
a3f31aa Add keepkey automated test (Andrew Chow)
b7f5288 Use DebugLink for Keepkey UDPTransport (Andrew Chow)
8d53b7d Build keepkey emulator in setup_environment (Andrew Chow)
113bbe9 Enumerate the keepkey emulator (Andrew Chow)
50e72ad Update documentation for keepkey (Andrew Chow)
6857593 Implement multisig input signing and fixes to signtx for keepkey (Andrew Chow)
9d6949d Implement displayaddress for keepkey (Andrew Chow)
80873f9 Implement signmessage for keepkey (Andrew Chow)
bf67fc6 Use keepkey 6.0.1 from keepkey/python-keepkey repo (Andrew Chow)

Pull request description:

  Implements the signmessage, displayaddress, and signtx commands for the keepkey. This also completes its implementation and the documentation is updated as such.

  Note that because the Keepkey is a clone of the Trezor, these implementations are copies of the Trezor ones modified slightly to work with the Keepkey library.

  This also adds an automated test for the KeepKey using the KeepKey simulator.

Tree-SHA512: 3e2491f4909df2a34e85dd7f051762cad8a12e948eb87709a6c943b9a62f2a208eb36966a80b50ffa2f976c49c775e944b796855f1caa00c1c812c2a8bf7b3c9
2019-01-14 14:59:13 -05:00
Andrew Chow
8ddf434489 Refactor tests to optionally have emulator start and stop for each test
The trezor and keepkey emulators use the same port so they cannot
be run at the same time. To work around this, the emulators are
instead started and stopped before and after each test using
unittest's setUp and tearDown functions. However, other devices
which do not have conflicts can still be run at test suite creation
time. This is still done for the coldcard.

Furthermore, since the trezor and keepkey both create and use
emulator.img files in the current working directory, when they are
started, the working directory is changed to be the one containing
the emulator executable to avoid conflicting emulator.img files
2019-01-12 21:45:42 -05:00
Andrew Chow
a3f31aae60 Add keepkey automated test 2019-01-12 21:45:42 -05:00
Andrew Chow
b7f5288bab Use DebugLink for Keepkey UDPTransport 2019-01-12 21:45:42 -05:00
Andrew Chow
8d53b7da64 Build keepkey emulator in setup_environment 2019-01-12 21:45:42 -05:00
Andrew Chow
113bbe9cc3 Enumerate the keepkey emulator
Allows enumerating the UDPTransport in order to connect to the
Keepkey emulator.

Because the keepkey and trezor emulators use the same interface, some
conditions are used to avoid enumerating the emulator as the wrong type.
2019-01-12 21:45:42 -05:00
Andrew Chow
50e72ade35 Update documentation for keepkey
All commands are implemented for the keepkey, so update the docs to
reflect that
2019-01-12 21:45:42 -05:00
Andrew Chow
685759377d Implement multisig input signing and fixes to signtx for keepkey 2019-01-12 21:45:42 -05:00
Andrew Chow
9d6949d1b0 Implement displayaddress for keepkey 2019-01-12 19:40:31 -05:00
Andrew Chow
80873f9fed Implement signmessage for keepkey 2019-01-12 19:40:31 -05:00
Andrew Chow
bf67fc61ce Use keepkey 6.0.1 from keepkey/python-keepkey repo 2019-01-12 19:40:31 -05:00
Andrew Chow
de4ff1e0fe Update digital bitbox encryption scheme for firmware v5
Firmvware v5.0.0 changed how messages are encrypted and authenticated,
so update the encryption methodolgy to handle that.
2019-01-12 18:42:49 -05:00
Andrew Chow
3578ecaee5
Merge #96: Bitbox test
41d3fae Digital Bitbox manual tests (Andrew Chow)
a834e13 Allow providing device passwords for manual tests (Andrew Chow)

Pull request description:

  Like the ledger test, but for bitbox.

  Also lets you specify the password for the device. This is currently only used for the bitbox.

Tree-SHA512: 04ee87cc9b176d151c1d0367c6dca6d03b9fc1087837185180cc9ba89f97b059ef29571d6c32fa2a445ca7ab1d738c1fc7f19c76aa421c97532fcb18c757b335
2019-01-11 14:12:55 -05:00
Andrew Chow
2ecb0f0c9e
Merge #103: Ensure that a bogus signature will always be created for ignored inputs on Trezor
c54bc33 Ensure that a bogus signature will always be created for ignored inputs (Andrew Chow)

Pull request description:

  Fixes the issue where multisig inputs not belonging to the trezorwould cause an error. Also re-enables that test for the trezor

  Fixes #100

Tree-SHA512: abbda04827a942eeb4c8b61ebd8b803fc6ae58871ec0646ebb8468889b7d4dcd5e0f92e58f47c1dd2ec8b6c6b67b3f663f65843b3d0708a001deb80407d362dc
2019-01-11 14:03:23 -05:00
Andrew Chow
c54bc33381 Ensure that a bogus signature will always be created for ignored inputs
Fixes the issue where multisig inputs not belonging to the trezor
would cause an error. Also re-enables that test for the trezor
2019-01-11 13:44:43 -05:00
Andrew Chow
3e8073c123
Merge #99: Test signtx with unknown inputs by wiping master fingerprint and processing
0d6ad3a Test signtx with unknown inputs by wiping master fingerprint and processing (Gregory Sanders)

Pull request description:

  For now I'm excepting Trezor from these specific test cases because it cannot handle multisig inputs that it won't sign yet.

Tree-SHA512: 37bf6ce641cb86692cbc4a93f12d06734f8434233fd75acd60939355e7d5c72dba3013b1195a22eb7618794285621a2ee0f0e7bbf9280c45197f37ca5ddf1ba3
2019-01-11 13:25:54 -05:00
Gregory Sanders
0d6ad3a996 Test signtx with unknown inputs by wiping master fingerprint and processing 2019-01-10 22:13:48 -05:00
Andrew Chow
41d3faedfd Digital Bitbox manual tests 2019-01-09 13:09:06 -05:00
Andrew Chow
a834e13e18 Allow providing device passwords for manual tests 2019-01-09 13:06:40 -05:00
Andrew Chow
28cf2146d1
Merge #89: Implement multisig and external input signing with Trezor and mark its implementation complete
d8d74ac Enable multisig tests for Trezor (Andrew Chow)
3b0429b Go through the signing process multiple times so that multisigs are fully signed (Andrew Chow)
cde7dfe Update documentation for Trezor (Andrew Chow)
c5b5a91 Implement signmessage for Trezor (Andrew Chow)
327f1e0 Have trezor ignore inputs it cannot sign rather than throwing an error (Andrew Chow)
f2f8b5d Implement multisig input signing for Trezor (Andrew Chow)

Pull request description:

  This PR implements the ability to sign multisig inputs with a Trezor and the ability to sign a transaction that has inputs that do not belong to the device for Trezor. Documentation is also updated to reflect these changes and the Trezor implementation is marked as completed.

  Multisig inputs can now be signed.

  Although the Trezor has an `EXTERNAL` input type, it appears that the firmware does not recognize this type. So to work around this, for inputs that are not the Trezor's, a signature will still be create and instead just ignored at the end so the signature does not go into the resulting psbt.

  Fixes #49

Tree-SHA512: 84325b7172ae587aebfa8b8f38d7e7be093d79ccf50b8cbb4031da525a004f1c09b5c4881cea12002e5f54723b52b3055a61489914dde1e46908d821d33f1503
2019-01-09 13:00:38 -05:00
Andrew Chow
d8d74ac2dc Enable multisig tests for Trezor 2019-01-09 12:47:57 -05:00
Andrew Chow
3b0429b7ec Go through the signing process multiple times so that multisigs are fully signed
Goes through the entire signing process multiple times in order to fully sign
multisigs that have multiple keys from this device.
2019-01-09 12:47:56 -05:00
Andrew Chow
cde7dfef41 Update documentation for Trezor 2019-01-09 12:47:56 -05:00
Andrew Chow
c5b5a91956 Implement signmessage for Trezor 2019-01-09 12:06:01 -05:00
Andrew Chow
327f1e0122 Have trezor ignore inputs it cannot sign rather than throwing an error
Instead of erroring and failing to sign the transaction when an input
cannot be signed, just ignore that input. Ideally this would be done
using InputScriptType.EXTERNAL, but the firmware does not support this
So to achieve this, we instead fill in the input with bogus data and
let the Trezor sign it anyways. Then we just ignore the signature
that was produced.
2019-01-09 12:06:01 -05:00
Andrew Chow
f2f8b5de93 Implement multisig input signing for Trezor 2019-01-09 12:06:01 -05:00
Andrew Chow
b015a0f7a5
Merge #97: multisig test
68a4935 multisig test (Gregory Sanders)

Pull request description:

  When device is marked as multi-sig enabled
  create and spend 3 standard multisig types:

  sh(wsh(multi()), sh(multi()), wsh(multi())

Tree-SHA512: 9d1300b0e98d4ee1ca073096d1043119b544e5ae9f161b48690b613215756cccd5a21e9bccf00d69b72b228454e625f253d7dd12ca7891c8a6f906f5492e1e1f
2019-01-09 12:04:07 -05:00
Gregory Sanders
68a4935c88 multisig test
When device is marked as multi-sig enabled
create and spend 3 standard multisig types:

sh(wsh(multi()), sh(multi()), wsh(multi())
2019-01-09 11:15:22 -05:00
Andrew Chow
2e5b948172
Merge #95: Ledger test
dd5533f Adapt signing test to support devices that can't do mixed input signing (Gregory Sanders)
08f1a94 Add basic physical Ledger test with ./run_tests.py --ledger option. (Gregory Sanders)

Pull request description:

  Built on https://github.com/achow101/HWI/pull/94 to properly test for the mixed-input case.

  This has to be done with a physical device since there is no simulator. It bootstraps itself by grabbing the xpub and other info using enumerate(which is kind of cheating yes but you can't initialize via software), then goes through the rest of the test normally.

Tree-SHA512: 6113885348f58f13b88319f4b01046ae5442c2eaf5b7537662b2e96b02b14f8506b9a2d905187a9cf2018acb9b0eb535569a09671aa3179b6ddab20384b2e239
2019-01-08 14:38:46 -05:00
Gregory Sanders
dd5533f286 Adapt signing test to support devices that can't do mixed input signing 2019-01-08 14:19:37 -05:00
Gregory Sanders
08f1a94752 Add basic physical Ledger test with ./run_tests.py --ledger option. 2019-01-08 14:19:37 -05:00
Andrew Chow
811f1ef99a
Merge #94: Send the full amount of funds in TestSignTx to test all input types
106c231 Send the full amount of funds in TestSignTx to test all input types (Gregory Sanders)

Pull request description:

  Also beef up the signing test a bit to try combinations of 1 to 3 inputs to catch corner cases in signing logic.

  I am writing a Ledger test and this case was not failing previously because it can handle legacy or witness, but not both.

Tree-SHA512: 815d620e9051c5f031cea2fd3ff4a9a36ada07e8903c906b92b802b72dd9a0c41cc23e471b1c1ca021a7457bdef10ae424971bc5cd08060151f9110d6e3b2de3
2019-01-08 12:15:13 -05:00
Gregory Sanders
106c23128b Send the full amount of funds in TestSignTx to test all input types 2019-01-08 10:29:55 -05:00
Andrew Chow
7b4a7055f9
Merge #92: Fix broken tests and test failures
bdadd8e Coldcard: send keypresses to the simulator for user input things (Andrew Chow)
942969c Ensure RPC is available for each test case (Andrew Chow)
47c3951 Install all necessary libraries correctly (Andrew Chow)
0f6081f Return correct error code from tests (Andrew Chow)

Pull request description:

  Apparently `run_tests.py` was not exiting with a failure status code which caused travis to think that everything was fine when tests were actually failing. This fixes that by having it exit with the right status code.

  Some tests were also failing, so those were fixed. The Coldcard tests needed have `ckcc-protocol[cli]` installed (previously the `cli` extra was not being installed), so that was added to setup.py. At the same time, `ecdsa` was added to fix #74.

  Additionally, the tests for `displayaddress` and `signmessage` on the Coldcard were not working because a keypress is needed on the device. It turns out a keypress can be sent to the device if it is a simulator, so those commands have been changed to send the keypress necessary to simulators. Since `signtx` needs that too, I added it there and enabled the `signtx` test for Coldcard.

  Lastly there were broken pipe errors when sending RPC commands to bitcoind. This was fixed by making a new RPC object when setting up each test case.

Tree-SHA512: 61ab5b552dfbeb7a55a398a575f0a52d409855f96fcacd3f051bbf2ea4178148edd051026af1adf7d72f2442e81fd35401a2bb53f3a3ff475653ef016ca0d578
2019-01-07 20:23:42 -05:00
Andrew Chow
bdadd8e19e Coldcard: send keypresses to the simulator for user input things
signtx, signmessage, and displayaddress need user input which can't
be sent on the headless simulator. So instead send the keypresses
in those commands if it's the simulator.
2019-01-07 11:13:48 -05:00
Andrew Chow
942969cfb7 Ensure RPC is available for each test case 2019-01-07 11:13:48 -05:00
Andrew Chow
47c3951eb4 Install all necessary libraries correctly
Some libraries were missing, so install them in the setup.py
2019-01-07 11:13:48 -05:00
Andrew Chow
0f6081ffd3 Return correct error code from tests 2019-01-06 13:40:37 -05:00
Andrew Chow
28dd8ce59c
Merge #87: Implement signmessage for Coldcard to complete its implementation
f3dcf95 Update Coldcard docs for signmessage (Andrew Chow)
14a1345 Implement signmessage for the Coldcard with a simple test (Andrew Chow)

Pull request description:

  Implements the `signmessage` command for the Coldcard. This completes the Coldcard implementation and the documentation is updated as such.

  Requires #84 and #82 which add the other commands for the Coldcard.

Tree-SHA512: 3a1f64c997dc41e37bbbb90aa95290a70b2e1ff4e429b98b00bbee0788a0a4ea01bb06b66d1f08370b2fc8166428549b386c90391a3ff3e30b597c5ef858966c
2019-01-04 19:24:48 -05:00
Andrew Chow
f3dcf95548 Update Coldcard docs for signmessage 2019-01-04 19:23:52 -05:00
Andrew Chow
14a1345ad1 Implement signmessage for the Coldcard with a simple test 2019-01-04 19:23:52 -05:00