mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-17 23:34:19 +01:00
116 lines
2.6 KiB
Markdown
116 lines
2.6 KiB
Markdown
# sphinx-key
|
|
|
|
A Lightning Hardware Wallet based on [Validating Lightning Signer](https://gitlab.com/lightning-signer/validating-lightning-signer)
|
|
|
|
### set CFLAGS
|
|
|
|
Before building the sphinx-key esp software, run this:
|
|
|
|
`export CFLAGS=-fno-pic`
|
|
|
|
### find your esp GCC
|
|
|
|
Find the path to your `riscv32-esp-elf-gcc` binary within the `.embuild` dir:
|
|
|
|
`export CC=$PWD/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-patch3-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc`
|
|
|
|
### build test
|
|
|
|
`cargo build --features pingpong`
|
|
|
|
### flash test
|
|
|
|
`espflash target/riscv32imc-esp-espidf/debug/sphinx-key --monitor`
|
|
|
|
### build release
|
|
|
|
`cargo build --release`
|
|
|
|
### flash release
|
|
|
|
`esptool.py --chip esp32c3 elf2image target/riscv32imc-esp-espidf/release/sphinx-key`
|
|
|
|
`esptool.py --chip esp32c3 -p /dev/tty.usbserial-1420 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x10000 target/riscv32imc-esp-espidf/release/sphinx-key.bin`
|
|
|
|
### monitor
|
|
|
|
Find your port (`ls /dev/tty.*`)
|
|
|
|
`PORT=/dev/tty.usbserial-1420`
|
|
|
|
`espmonitor $PORT`
|
|
|
|
### configure the hardware
|
|
|
|
make a seed: `./sphinx-key/newseed.sh`
|
|
|
|
make a `.env` file like:
|
|
|
|
```
|
|
SSID={my_ssid}
|
|
PASS={my_wifi_password}
|
|
BROKER={my_ip}:1883
|
|
SEED={my_seed_hex}
|
|
NETWORK=regtest
|
|
```
|
|
|
|
connect to the `sphinxkey` network on your computer
|
|
|
|
`cargo run --bin config`
|
|
|
|
This will encrypt your seed and send to the hardware, along with your home wifi information and broker address
|
|
|
|
### clear NVS storage
|
|
|
|
`espflash target/riscv32imc-esp-espidf/debug/clear`
|
|
|
|
`espmonitor /dev/tty.usbserial-1420`
|
|
|
|
## dependencies
|
|
|
|
##### cargo nightly:
|
|
|
|
`rustup install nightly`
|
|
|
|
`rustup component add rust-src --toolchain nightly`
|
|
|
|
`rustup default nightly`
|
|
|
|
##### python 3.7 or higher is required
|
|
|
|
##### cargo sub-commands:
|
|
|
|
`cargo install cargo-generate`
|
|
|
|
`cargo install ldproxy`
|
|
|
|
`cargo install espflash`
|
|
|
|
`cargo install espmonitor`
|
|
|
|
##### cargo generate esp-rs
|
|
|
|
`cargo generate --git https://github.com/esp-rs/esp-idf-template cargo`
|
|
|
|
```
|
|
std support: true
|
|
v4.4
|
|
esp32c3
|
|
nightly
|
|
```
|
|
|
|
`cargo build`
|
|
|
|
#### espflash notes
|
|
|
|
`espflash save-image esp32-c3 target/riscv32imc-esp-espidf/release/sphinx-key ./test-flash`
|
|
|
|
`espflash board-info`
|
|
|
|
`esptool.py --chip esp32c3 elf2image target/riscv32imc-esp-espidf/release/sphinx-key`
|
|
|
|
`esptool.py --chip esp32c3 -p /dev/tty.usbserial-1420 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x10000 target/riscv32imc-esp-espidf/release/sphinx-key.bin`
|
|
|
|
`espmonitor /dev/tty.usbserial-1420`
|
|
|
|
for ESP-IDF#4.3.2: `export CC=$PWD/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc` |