Comments (13)
@prusnak I was researching possible application level USB libraries to use to interface with TREZOR v1 devices, and had some questions that coincide with what this issue is advocating.
Since the device registers its interfaces as USB HID with the host system, I'm leaning towards using a hidapi based library by default.
I also found these links that seem to indicate that a hidapi based library may be more compatible with OS X hosts (I don't have one to test):
https://github.com/libusb/libusb/wiki/FAQ#does-libusb-support-usb-hid-devices
https://github.com/gary-rowe/hid4java#why-not-just-use-usb4java-
I'm wondering if you have any experience or guidance with regards to library compatibility, or suggestions to avoid pitfalls? Does the fact that "we don't really need HID features" cancel out the compatibility problems?
Also, it looks like now you're in control of pypi for hidapi, so is this issue still as relevant as it was when you opened it?
I'm debating whether to use Python or Java and have narrowed it down to these options that I'm considering:
For Python:
libusb 1.0 based -> https://pypi.python.org/pypi/libusb1/1.6.4
hidapi based -> https://pypi.python.org/pypi/hidapi/0.7.99.post21
For Java:
libusb 1.0 based -> https://github.com/usb4java/usb4java
hidapi based -> https://github.com/gary-rowe/hid4java
from python-trezor.
We'll be switching to WebUSB soon (both for T1 and T2). Further research shows it makes sense to support both (libhidapi for legacy HID and libusb for WebUSB).
Funnily enough, the current implementation for Android (trezor-android) works for both HID and WebUSB.
from python-trezor.
Hmm, WebUSB is not very good right now compatibility wise for our purposes.
For example, I'm testing it on Ubuntu 16.04.3 LTS with Chrome 63 and am hitting this issue that the Chrome team has marked as "won't fix": https://bugs.chromium.org/p/chromium/issues/detail?id=679314
To reproduce, plug in T1 device and go to WebUSB test page.
You'll get "DOMException: Unable to claim interface."
Then I run a usb1 python script that contains the following:
if handle.kernelDriverActive(TREZOR_INTERFACE):
handle.detachKernelDriver(TREZOR_INTERFACE)
Then I go back to the WebUSB test page and it works.
EDIT: Oh, I just noticed that issue was opened by @karel-3d. Small world :)
from python-trezor.
It should be enough to install the udev rules that we offer with extension - deb package https://wallet.trezor.io/data/udev/trezor-udev_1_all.deb or manually http://doc.satoshilabs.com/trezor-user/settingupchromeonlinux.html
from python-trezor.
@karel-3d thanks for the suggestion. i tried it and was able to still reproduce the same issue. it really is the kernel driver issue that you reported. when my python script detaches and does not re-attach the kernel driver, it has the side effect of letting chrome claim the interface afterwards (assuming that i don't unplug my device in-between running the python script and going back over to chrome).
for reference, when the udev rules are incorrect, chrome gives me "DOMException: Access denied." which is different.
fwiw, i was using very liberal udev rules to begin with:
SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001", MODE="0666"
from python-trezor.
@mcudev the WIP branch in this PR: trezor/trezor-mcu#260 is supposed to be used with WebUSB. Currently we ship devices with HID for communication and HID for U2F, after the change we will ship devices with WebUSB for communication and HID for U2F.
from python-trezor.
@mcudev oh, you are trying webusb with the current firmware with HID interface? OK, this will not work without detaching the driver.
We are making a new firmware that will not have HID on the first interface (see the linked branch) and that should not require the python script.
from python-trezor.
neat. thanks, i'll check that out. that should beat running a script from a udev rule :)
from python-trezor.
@mcudev the problem is that we could not make this backwards compatible. We originally wanted to make the third interface WebUSB and keep the HID interfaces as-are, but there is an issue on windows libusb implementation, that is used in Chrome, where HID and WinUSB (which is needed for WebUSB to work without drivers) are on the same device. WinUSB needs to come before HID.
The resolution is either to wait for Chrome to fix their stuff (they are completely rewriting the usb backend away from libusb), or to put WinUSB/WebUSB first. Which will break things like python-trezor.anyway (if we kept HID but put it on interface 3). And if we put WebUSB first and swith HID to 3, we need to rewrite python-trezor anyway.
We decided to ax HID interface and keep only the webusb one, because the implementation will be cleaner.
from python-trezor.
Yeah, that's a tough spot to be in. No great option so far. I was thinking of fingerprinting the host during enumeration to determine which order of interface descriptors to send, but that may be too brittle.
Hopefully the package maintainers for python-trezor will update in a timely manner when this is ready (e.g.- the debian package [and downstream systems] has only been updated once in the last year+).
from python-trezor.
from python-trezor.
in the meantime I'm going to try to switch to hidapi-cffi
so that we can get rid of Cython
from python-trezor.
using hidapi-cffi is not viable because of Windows - we'd need to supply a separate dll. That's the advantage of Cython-based hidapi.
hidapi feature is now marked as extra in python-trezor, so the dependencies don't install by default. That is in anticipation of T1 switch to WebUSB. I'd consider the bug closed through this -- a full switch is not going to happen, AFAICT, we will need to support hidapi as a legacy option in any case.
from python-trezor.
Related Issues (20)
- Why is the v1 protocol forced for HID devices? HOT 2
- Update Error HOT 1
- ./trezorctl sign-tx non functional for most networks HOT 1
- tx_api.get_tx incompatible with current blockbook
- test sometimes fail with "Unsupported device" HOT 1
- Don't show PIN matrix for Trezor T when changing PIN
- Add a test case for segwit inputs/outputs with very high amounts
- zcash sapling not supported in 0.10.2 HOT 2
- Ethereum transaction fails to generate raw transaction HOT 2
- add monero_get_address to trezorctl HOT 1
- Travis CL seems to be failing 10.x PRs due to Py3.4 requirements HOT 1
- Use ChoiceType for set_passphrase_source HOT 1
- ethereum-sign-tx does not work
- Can't sign Ethereum transaction offline on v0.11.2 HOT 2
- Is there a way to restore seed words in scrambled order? HOT 7
- Trezor passphrase keyboard HOT 1
- wipe-device hangs after confirming on device HOT 3
- trezorlib ethereum.get_address returns None HOT 1
- MINIMUM_FIRMWARE_VERSION issues HOT 2
- python-trezor 0.11.3 released on PyPI but not tagged here HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-trezor.