Skip to content

Commit

Permalink
Add hal command to support BIP39 keys management use-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
aitorpazos committed Feb 28, 2021
1 parent 68dd7d2 commit b99d487
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 4 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Build iso file
id: build_iso
run: make
Expand All @@ -37,7 +40,7 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./files-min/debian-custom.iso
asset_name: shamir-manage-min-${{ github.event.release.tag_name }}.iso
asset_name: shamir-manage-min-${{ steps.get_version.outputs.VERSION }}.iso
asset_content_type: application/octet-stream
- name: Upload xfce Release Asset
id: upload-release-asset-xfce
Expand All @@ -47,5 +50,5 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./files-xfce/debian-custom.iso
asset_name: shamir-manage-xfce-${{ github.event.release.tag_name }}.iso
asset_name: shamir-manage-xfce-${{ steps.get_version.outputs.VERSION }}.iso
asset_content_type: application/octet-stream
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Backup files
**/*~

# HAL binary
hal

# IDEs
.idea
**/*.iml
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.0] - 2021-02-28

### Added

- `hal` command from [https://github.com/stevenroose/hal](https://github.com/stevenroose/hal) to manage BIP39 crypto wallets word lists

### Fixed

- Version set in GitHub release workflow

## [0.4.0] - 2021-02-27

### Added
Expand Down
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
CREATE_DEBIAN_ISO_VERSION:=0.2.0
HAL_VERSION:=0.6.1
HAL_RPM_FILE:=hal-bitcoin-$(HAL_VERSION)-1.el7.x86_64.rpm
EXTRACT_DIR:=/tmp/shamir-iso-hal

.PHONY: all
all: minimal xfce

.PHONY: clean
clean:
rm -rf hal
sudo rm -rf files-min/debian-custom.iso files-xfce/debian-custom.iso

hal:
mkdir -p $(EXTRACT_DIR)
curl -L -o $(EXTRACT_DIR)/hal.rpm https://github.com/stevenroose/hal/releases/download/v$(HAL_VERSION)/$(HAL_RPM_FILE)
(cd $(EXTRACT_DIR); rpm2cpio ./hal.rpm | cpio -idmv)
cp $(EXTRACT_DIR)/usr/bin/hal ./hal

.PHONY: minimal
minimal: files-min/custom-debian.iso

.PHONY: xfce
xfce: files-xfce/custom-debian.iso

files-min/custom-debian.iso:
files-min/custom-debian.iso: hal
cp hal files-min/config/
docker run --rm -t -v $(shell pwd)/files-min:/root/files aitorpazos/create-debian-iso:$(CREATE_DEBIAN_ISO_VERSION)

files-xfce/custom-debian.iso:
files-xfce/custom-debian.iso: hal
cp hal files-xfce/config/
docker run --rm -t -v $(shell pwd)/files-xfce:/root/files aitorpazos/create-debian-iso:$(CREATE_DEBIAN_ISO_VERSION)
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ Share [3/3]: 5-1224ff0f3253ac71999744
Resulting secret: hello world
```

### BIP39 Keys

If you want to use this image to backup or restore your crypto wallet words list, the image includes the `hal` command (from [https://github.com/stevenroose/hal](https://github.com/stevenroose/hal)) which provides different crypto related operations.

For example:
- Generate entropy value from words list and pass it to `ssss-split`:
```shell
hal bip39 get-seed "your BIP words" | jq -r .entropy | ssss-split -t <x> -n <n>
```
- Generate words list from entropy value:
```shell
hal bip39 generate -w <number of words> --entropy <entropy value>
```
If you don't select the correct number of words, the generation will fail. However the possible values are: 3, 6, 9, 12, 15, 18, 21 or 24 (the usual ones being 12 and 24).

## Download the image

The latest image is published to the [GitHub releases page](https://github.com/aitorpazos/shamir-iso/releases).
Expand All @@ -85,3 +100,7 @@ You can build the image yourself with `make`.

`make minimal` will build the minimal image
`make xfce` will build xfce based image

## TODO

- Create image for arm64 boards
11 changes: 11 additions & 0 deletions files-min/config/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ split -n <n> <my file with the key>
echo "My text" | qrencode -o <qr file.png>
- Display QR image:
display <qr file.png>

If you are dealing with BIP39 word lists or seeds you can use the `hal` command:
hal bip39 get-seed "your BIP words" | jq -r .entropy | ssss-split -t <x> -n <n>

In order to recover the original words, you can run:
ssss-combine -t <t>
and then generate the words from the returned value:
hal bip39 generate -w <number of words> --entropy <entropy value>

If you don't select the correct number of words, the generation will fail. However the possible values are:
3, 6, 9, 12, 15, 18, 21 or 24 (the usual ones being 12 and 24).
2 changes: 2 additions & 0 deletions files-min/config/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export DEBIAN_FRONTEND=noninteractive
apt-get purge -y iproute2 iputils-ping

cp /root/shamir-background.png /usr/share/pixmaps/shamir-background.png
cp /root/hal /usr/bin/
chmod a+rx /usr/bin/hal

cat > /etc/systemd/system/user-autologin.service << EOF
[Unit]
Expand Down
1 change: 1 addition & 0 deletions files-min/config/packages
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
icewm
imagemagick
jq
less
links
nano
Expand Down
Binary file modified files-min/config/shamir-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions files-xfce/config/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ echo "My text" | qrencode -o <qr file.png>
- Display QR image:
display <qr file.png>

If you are dealing with BIP39 word lists or seeds you can use the `hal` command:
hal bip39 get-seed "your BIP words" | jq -r .entropy | ssss-split -t <x> -n <n>

In order to recover the original words, you can run:
ssss-combine -t <t>
and then generate the words from the returned value:
hal bip39 generate -w <number of words> --entropy <entropy value>

If you don't select the correct number of words, the generation will fail. However the possible values are:
3, 6, 9, 12, 15, 18, 21 or 24 (the usual ones being 12 and 24).

## Experimental USB printer support:

- Add a printer (user: user , password: user) using CUPS admin page in the browser:
Expand Down
3 changes: 3 additions & 0 deletions files-xfce/config/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ apt-get purge -y iproute2 iputils-ping
cp /root/shamir-background.png /usr/share/pixmaps/shamir-background.png
chmod a+r /usr/share/pixmaps/shamir-background.png

cp /root/hal /usr/bin/
chmod a+rx /usr/bin/hal

cat > /etc/skel/.config/epiphany/web-extension-settings.ini << EOF
[org/gnome/epiphany]
homepage-url='http://127.0.0.1:631/admin'
Expand Down
1 change: 1 addition & 0 deletions files-xfce/config/packages
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ hp-ppd
hpijs-ppds
hplip
imagemagick
jq
less
links
nano
Expand Down
Binary file modified files-xfce/config/shamir-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shamir-background.kra
Binary file not shown.

0 comments on commit b99d487

Please sign in to comment.