cryptoadvance / specter-diy

DIY airgapped hardware wallet that uses QR codes for communication with the host
MIT License
441 stars 73 forks source link

Add hot storage USB support #31

Closed stepansnigirev closed 4 years ago

stepansnigirev commented 4 years ago

QR codes are nice but there are some cases when we want to connect hardware wallet to the computer:

For all this we need USB connectivity.

At the moment USB is used for MicroPython's REPL (that should be disabled in production). For development we can bind REPL to UART3 and use USB for communication.

Small snippet that implements this:

# UART3 connected to stlink
repl = pyb.UART('YB',115200)
# redirect REPL to UART
os.dupterm(repl,0)
# unconnect REPL from USB
os.dupterm(None, 1)
# use usb as a virtual serial port
usb = pyb.USB_VCP()

From the main logic side we should implement a class for communication that can be unidirectional and user-driven (qrscanner, user activates it from the GUI) or bidirectional and interactive (usb, host can ask for data / verification)