Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Always Wiping Multisig Descriptor at Main Menu #528

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2353f1b
Add initial functionality to load secrets from SeedKeeper
3rdIteration Nov 29, 2023
e51fde7
Initial ability to export secret to seedkeeper
3rdIteration Nov 29, 2023
f11c395
add ability to export seed+passphrase
3rdIteration Nov 29, 2023
de8abc1
Improve workflows
3rdIteration Nov 30, 2023
93c8905
Add ability to install/uninstall applets (Installation is unreliable …
3rdIteration Nov 30, 2023
51074c6
Draft documentation
3rdIteration Dec 1, 2023
3e93764
Update smartcard_support_installation.md
3rdIteration Dec 1, 2023
ab42619
Add OpenCT based USB option
3rdIteration Dec 4, 2023
dabae48
Update tools_views.py
3rdIteration Dec 4, 2023
ac0b9e5
Update tools_views.py
3rdIteration Dec 4, 2023
544ac87
Update smartcard_support_installation.md
3rdIteration Dec 4, 2023
81cbd73
Update smartcard_support_installation.md
3rdIteration Dec 4, 2023
dbf05cf
Update smartcard_support_installation.md
3rdIteration Dec 4, 2023
65e64a3
add loading screens for slow operations
3rdIteration Dec 4, 2023
29db388
add more useful errors for managing applets
3rdIteration Dec 4, 2023
cad9333
Update tools_views.py
3rdIteration Dec 4, 2023
17b4960
Add additional NFC Scan test tool
3rdIteration Dec 11, 2023
2ca1e5d
Update smartcard_support_installation.md
3rdIteration Dec 11, 2023
217897e
*Add NFC diagnostics
3rdIteration Dec 14, 2023
218f1ba
Merge branch 'dev' of https://github.com/3rdIteration/seedsigner into…
3rdIteration Dec 14, 2023
55ebee8
menu fix
3rdIteration Dec 14, 2023
d664571
Make Phoenix initialisation more reliable
3rdIteration Dec 14, 2023
f9c98d1
Add ability to disable USB ports when not needed
3rdIteration Dec 14, 2023
8f2b2cb
re-org menus
3rdIteration Dec 18, 2023
de5199f
*Add loading screen to enable/disable USB.
3rdIteration Dec 18, 2023
e148d60
*Improve reliability of processes when connecting over PN532 NFC
3rdIteration Dec 23, 2023
dab4c77
Update controller.py
3rdIteration Dec 23, 2023
129e3c8
seedsigner os tweaks
3rdIteration Feb 6, 2024
b427ea9
fix typo
3rdIteration Feb 6, 2024
c6bb02b
fix typos
3rdIteration Feb 6, 2024
06b8be4
Update tools_views.py
3rdIteration Feb 6, 2024
a12b692
Update tools_views.py
3rdIteration Feb 6, 2024
7f3a46a
Update settings.py
3rdIteration Feb 7, 2024
30c5a40
Added ability to build applets from menu
3rdIteration Feb 13, 2024
63d7484
fix for microsd imagaging on manual build
3rdIteration Feb 13, 2024
957b30d
Add javacard build file for seedsigneros
3rdIteration Feb 13, 2024
4f30962
Merge branch 'dev' of https://github.com/3rdIteration/seedsigner into…
3rdIteration Feb 13, 2024
00cea4b
microsd tools update
3rdIteration Feb 13, 2024
eb36092
Update tools_views.py
3rdIteration Feb 13, 2024
1bb0060
Update tools_views.py
3rdIteration Feb 13, 2024
bedea05
microsd tools tweaks
3rdIteration Feb 13, 2024
4e64835
Update tools_views.py
3rdIteration Feb 13, 2024
3ea016c
Update tools_views.py
3rdIteration Feb 13, 2024
c8eb810
dd bugfix & tweak
3rdIteration Feb 13, 2024
95cfc98
applet build tweak
3rdIteration Feb 13, 2024
7ef383a
fix export
3rdIteration Feb 13, 2024
8c16dcf
fix wipe screen order
3rdIteration Feb 13, 2024
b48f78b
MicroSD menu button text
3rdIteration Feb 14, 2024
932dfeb
Update tools_views.py
3rdIteration Feb 15, 2024
65e3889
Add ability to load passphrase from any password on the seedkeeeper c…
3rdIteration Feb 17, 2024
df7e1cb
Fix Always Wiping Multisig Descriptor at Main Menu
3rdIteration Feb 17, 2024
39fc63a
Add initial ability to save/load wallet descriptors to Seedkeeper
3rdIteration Feb 17, 2024
d4be7ec
fix bug that wipes multisig descriptor on return to main menu
3rdIteration Feb 17, 2024
51230f2
improve wallet descriptor export
3rdIteration Feb 17, 2024
fca41a2
Change text & add warning when signing a Multisig transaction without…
3rdIteration Feb 18, 2024
b29f111
Fix menu navigation
3rdIteration Feb 18, 2024
66d6804
Fix up CI tests to handle new warning screen
3rdIteration Feb 18, 2024
346708a
Merge branch 'dev' into fix_multisig_descriptor_wipe
3rdIteration Feb 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions docs/smartcard_support_installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Smartcard Seed Storage Support
## Background
Smart Cards are specifically designed to securely store digital data. Javacards are a type of Smart Cards that implement open standards development tools, making them ideal for DIY.

SeedKeeper is a open source seed storage product from Satochip which can be used to securely store multiple BIP39 seeds & passphrases. (And other types of secrets, but these aren't relevant to SeedSigner) In addition to providing the nessesary functionality, along with security features like secure-channel to protect the data exchange from eavesdropping, etc, the SeedKeeper also has standalone software available for users who may need to securely retrieve their data without access to a SeedSigner...

This guide focuses on DIY SeedKeeper cards (which are the best for testing) but this will also work with retail SeedKeeper cards for those who prefer that simplicity...

Demo 1: Pi4 + NFC - https://youtu.be/WHVWqJJBNdA
Demo 2: PiZero 1.3 + NFC + USB Sim Reader (Phoenix) - https://youtu.be/uG44Fw3rOLg

## Hardware Requirements
### USB Smart Card Readers
Any USB smart card reader that is compatible with will work, either hard-wired (Contact) or NFC (Contactless).

If you are running SeedSigner on a system image that is derived from a standard Raspberry Pi OS image, USB devices should be plug and play once PC/SC services are installed.

**Compatibility Notes**

The **ACS ACR 122U reader** is unreliable for flashing applets and may brick your card. (Though works fine for normal operation after they have been flashed)

### GPIO Connected Smart Card Readers
The PN352 NFC V3 module is low cost ($5 on Aliexpress) can be connected via available IO pins and is well supported by LibNFC.

Instructions on how to physically connect it can be found here: https://blog.stigok.com/2017/10/12/setting-up-a-pn532-nfc-module-on-a-raspberry-pi-using-i2c.html (Stop when you get to the section on LibNFC, as that part is not relevant)

## Software Installation

The following guide assumes that you have completed the [Manual Installation guide...](./manual_installation.md)

### SeedSigner with SeedKeeper Support
You will need to clone this repository in the place of the existing seedsigner folder in `/home/pi/seedsigner`

### Smartcard Libraries

Install the following additional software

sudo apt-get install git autoconf libtool libusb-dev libusb-dev libpcsclite-dev i2c-tools pcscd libpcsclite1 swig

### PySatoChip
While you can install PySatoChip directly from pip, the current (Nov 2023) release of PySatoChip needs a few tweaks before it will work with the code here. (Which may have been merged into the Master by the time you read this)

For now, you can download and build my fork using the code below. This will manually build the cryptography module which will take a few hours and also requires that you have a working installation of the Rust Compiler.

**Install Rust**

curl https://sh.rustup.rs -sSf | sh

_Choose option 1 to install Rust_

**Install PySatoChip**

cd ~
git clone https://github.com/3rdIteration/pysatochip
cd pysatochip
pip3 install -r requirements.txt
cd pysatochip
python setup.py install

### LibNFC + IFDNFC (Optional: Needed for PN352 connected via GPIO Pins)

**Install LibNFC**

cd ~
git clone https://github.com/nfc-tools/libnfc
cd libnfc
autoreconf -vis
./configure --with-drivers=pn532_i2c
make
sudo make install
sudo sh -c "echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf"
sudo ldconfig

**Install IfdNFC**

cd ~
git clone https://github.com/nfc-tools/ifdnfc
cd ifdnfc
autoreconf -vis
./configure
make
sudo make install

**Note Concerning IfdNFC**
You may get a message like `Insufficient buffer` you run `idfnfc-activate`, or a message like `ifdnfc inactive` but it is actually working. (Even on x86 platforms when it doesn't work with other tools like pcsc_scan)

**Add Configuration Files**
Create the folder

sudo mkdir /usr/local/etc/nfc/

Create the file `/usr/local/etc/nfc/libnfc.conf` and add the following (`sudo nano /usr/local/etc/nfc/libnfc.conf`)

device.name = "IFD-NFC"
device.connstring = "pn532_i2c:/dev/i2c-1"

Create the file `/etc/reader.conf.d/libifdnfc` and add the following (`sudo nano /etc/reader.conf.d/libifdnfc`)

FRIENDLYNAME "IFD-NFC"
LIBPATH /usr/local/lib/libifdnfc.so
CHANNELID 0

**Restart PCSCD**

sudo service pcscd restart

**Activating IFD-NFC**

You will notice that there is a menu option to `Start PN532(PN532)` under the tools->SeedKeeper menu. Basically IFDNFC only needs to be run once on each boot, after which you may also need to restart the SeedSigner app. (But not the device)

Applet management operations (Installing, uninstalling, etc) often terminate the `idfnfc` process after completing, so if you can no longer do SeedKeeper operations like change PIN, load or save secrets, immediatly after flashing the applet, then this is likely why. (Just re-run the `ifdnfc-activate` process I mention above, restart the app and it should work fine)

### Python Bindings for LibNFC (Optional: Useful for Debugging the PN532 NFC)

Install some additional build packages

sudo apt install cmake

Download, install and build

cd ~
git clone https://github.com/xantares/nfc-bindings.git
cd nfc-bindings
cmake cmake -DCMAKE_INSTALL_PREFIX=~/.local -DPYTHON_EXECUTABLE=/usr/local/bin/python3.10 -DPYTHON_LIBRARY=/usr/local/lib/libpython3.10.a -DPYTHON_INCLUDE_DIR=/usr/local/include/python3.10
make install
cp /home/pi/.local/lib/python3.7/site-packages/_nfc.py ~/.envs/seedsigner-env/lib/python3.10/site-packages/nfc.py
cp /home/pi/.local/lib/python3.7/site-packages/_nfc.so ~/.envs/seedsigner-env/lib/python3.10/site-packages/_nfc.so

### uhubctl (Optional: Disables USB ports when not needed for Smartcard Interface)

sudo apt install uhubctl

### Javacard Managment Tools (Optional: Needed to flash SeedKeeper to Javacards)

You just need to install openjdk-8-jdk and Apache Ant

Follow the guide here: https://github.com/3rdIteration/Satochip-DIY

_The applet management (install/uninstall) in the SeedSigner menu assume that the Satochip-DIY repository was cloned into /home/pi/Satochip-DIY and built as per the guide in the repository._

The commands that the menu items run are currently hardcoded to be:

java -jar /home/pi/Satochip-DIY/gp.jar --install /home/pi/Satochip-DIY/build/SeedKeeper-official-3.0.4.cap

java -jar /home/pi/Satochip-DIY/gp.jar --uninstall /home/pi/Satochip-DIY/build/SeedKeeper-official-3.0.4.cap

### Javacard Build Environment (Optional: Needed to build SeedKeeper from Source)

Follow the guide here: https://github.com/3rdIteration/Satochip-DIY

### OpenCT and Generic/Old Blue "Sim Readers" (Optional: Get a more modern Smart Card reader if possible... )
**Included only for Reference/Education/Backup, as these can be built from Scratch...**

It's possible to obtain very cheap USB "Sim Readers" (Often Blue) for under $5 USD that can be used to access the Seedkeeper. (Or you can build on using the schematic here: https://circuitsarchive.org/circuits/smartcard/smartcard-pc-serial-reader-writer-phoenix/)

These types of devices will *not* be automatically detected or usable on modern Systems (Windows will give you an explicit error that the PL2302 USB-to-Serial converter is not supported) but can be made to work on Linux and/or Raspberry Pi through using OpenCT and configuring it to work as a Phoenix type reader.

_Note: The version of OpenST that can be installed via APT is buggy and will not work, it must be built from source..._

To Install and configure OpenCT

cd ~
git clone https://github.com/OpenSC/openct
cd openct
./bootstrap
./configure --enable-pcsc
make
sudo make install
sudo ldconfig
sudo mkdir -p /usr/local/var/run/openct/

Then Add configuration files to use it with PCSC tools

Add it to the list of readers `sudo nano /etc/reader.conf.d/openct`

FRIENDLYNAME "OpenCT"
DEVICENAME /dev/null
LIBPATH /usr/local/lib/openct-ifd.so
CHANNELID 0

Enable the Phoenix Driver in OpenCT `sudo nano /usr/local/etc/openct.conf`

and add the following to the end of the file

reader phoenix {
driver = phoenix;
device = serial:/dev/ttyUSB0;
};


Once you have done this, you can boot the device with the USB SIM reader connected.

Once the device is started, go into `tools->seedkeeper>Start OpenCT(SIM)` and the USB reader should then work until the next restart.

**Troubleshooting Connection Issues with OpenCT(Sim Readers)**

It's possible that when you run `Start OpenCT(SIM)` that this command will fail and the device will go into a bugged state. During normal operation, the Red LED on the SIM reader will flash once or twice when you start OpenCT, but should then stay off unless you are performing operations on your SeedKeeper... If the red LED just flashes continiously after you have started OpenCT, disconnect the power, re-start the device and try again... (And if it keeps happening, try a different power supply)

_Adapted from https://timesinker.blogspot.com/2016/04/using-cheap-sim-card-readers.html_
4 changes: 2 additions & 2 deletions requirements-raspi.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
picamera==1.13
RPi.GPIO==0.7.0
spidev==3.5
RPi.GPIO
spidev==3.5
5 changes: 2 additions & 3 deletions src/seedsigner/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Controller(Singleton):
rather than at the top in order avoid circular imports.
"""

VERSION = "0.7.0"
VERSION = "0.7.0+Satochip-ALPHA1"

# Declare class member vars with type hints to enable richer IDE support throughout
# the code.
Expand Down Expand Up @@ -285,7 +285,7 @@ def run(self):
next_destination = Destination(MainMenuView)

# Set up our one-time toast notification tip to remove the SD card
self.activate_toast(RemoveSDCardToastManagerThread())
# self.activate_toast(RemoveSDCardToastManagerThread()) TODO ADD THIS BACK FOR ANY PROPER MERGE

while True:
# Destination(None) is a special case; render the Home screen
Expand All @@ -298,7 +298,6 @@ def run(self):

# Home always wipes the back_stack/state of temp vars
self.resume_main_flow = None
self.multisig_wallet_descriptor = None
self.unverified_address = None
self.address_explorer_data = None
self.psbt = None
Expand Down
Loading
Loading