Skip to content

Commit 031411a

Browse files
authored
Merge pull request #34 from BlockchainCommons/shannona-Docs-update
Shannona docs update
2 parents 7225304 + ab3f493 commit 031411a

File tree

5 files changed

+247
-209
lines changed

5 files changed

+247
-209
lines changed

Docs/Install-Windows.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Building Seedtool on Windows
2+
3+
This document describes building `seedtool` with `MSYS2` and its usage on `Windows 10` 64-bit.
4+
5+
## Installing MSYS2 and Packages
6+
7+
1. Install `MSYS2` by downloading the installer and following the installation guide in [www.msys2.org](www.msys2.org).
8+
2. Run `MSYS2` and make sure the package database is updated:
9+
```bash
10+
# pacman -Syu
11+
# pacman -Su
12+
```
13+
3. Next, install the compiler and the required packages:
14+
```bash
15+
# pacman -S mingw-w64-x86_64-clang
16+
# pacman -S patch
17+
# pacman -S git
18+
# pacman -S make
19+
# pacman -S mingw-w64-x86_64-libc++
20+
# pacman -S autoconf
21+
# pacman -S automake1.8
22+
```
23+
24+
## Compiling Seedtool
25+
26+
1. Clone `bc-seedtool-cli`, e.g. into `C:\msys64\home`
27+
2. Open `MSYS2 MinGW 64-bit` application and `cd` into `C:\msys64\home\bc-seedtool-cli`
28+
3. Run the build script with:
29+
```bash
30+
# export CC="clang" && export CXX="clang++" && ./build.sh
31+
```
32+
4. Install:
33+
```bash
34+
# make install
35+
```
36+
You can now freely use `seedtool` inside `MSYS2 MinGW 64-bit` console.
37+
38+
### Running Seedtool as a Native Windows App
39+
40+
To be able to use `seedtool` as a native app on Windows outside `msys2/mingw64`, you have to expose three files to the system: `seedtool.exe`, `libc++.dll`, and `libunwind.dll`, which all reside in `C:\msys64\mingw64\bin`.
41+
42+
To do so, add that folder to the `Windows PATH` by the following command in `Windows Cmd`:
43+
```bash
44+
# set PATH=%PATH%;C:\msys64\mingw64\bin
45+
```
46+
That's it. Now you can use `seedtool` as a native Windows app in the Windows command-line tool.
47+
48+
*Note:* If you want to pipe seedtool ouput into a QR code generator, you could use:
49+
50+
```bash
51+
# seedtool --ur | python -c "import sys; print(sys.stdin.readlines()[0].upper())" | qr > seedqrcode.png
52+
```
53+
54+
For this you'll need `Python` and the following package:
55+
56+
```bash
57+
# pip install qrcode[pil]
58+
```
59+

MANUAL.md renamed to Docs/MANUAL.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🌱 Seedtool
22

3-
**Version 0.8.0**<br/>**September 15, 2020**
3+
**Version 0.8.1**<br/>**September 22, 2020**
44

55
*Copyright © 2020 by Blockchain Commons, LLC*<br/>*Licensed under the "BSD-2-Clause Plus Patent License"*
66

@@ -10,7 +10,7 @@
1010

1111
* [Introduction](#introduction)
1212
* [General Functionality](#general-functionality)
13-
* [Generate Random Seeds](#generate-random-seeds)
13+
* [Generating Random Seeds](#generating-random-seeds)
1414
* [Generating Seeds from Provided Entropy](#generating-seeds-from-provided-entropy)
1515
* [Deterministic Randomness](#deterministic-randomness)
1616
* [Compatibility](#compatibility)
@@ -21,7 +21,7 @@
2121

2222
`seedtool` is a command-line tool for creating and transforming cryptographic seeds of the sort commonly used by blockchain applications.
2323

24-
See [`README.md`](README.md) for installation and credits.
24+
See [`README.md`](../README.md) for installation and credits.
2525

2626
## General Functionality
2727

@@ -52,6 +52,8 @@ $ seedtool --in random --out hex
5252
06799f71d16fad08ec5407d32d670147
5353
```
5454

55+
### Bytewords
56+
5557
The Bytewords format can be used in place of `hex`. Unlike hex, where every possible input is a seed, Bytewords includes error detection.
5658

5759
```
@@ -83,7 +85,7 @@ deli-need-cats-taxi-dice-door-webs-vows-free-zest-legs-wall-half-waxy-trip-oval-
8385
$ seedtool --in hex --out btwm 279b18d0282aefe845fb83e956eed8a6
8486
dindcstidedrwsvsfeztlswlhfwytpolmossrkhl
8587
```
86-
88+
### Outputs & Counts
8789
An output format `--out` and count `--count` may be specified. Count may be in [1-1024] and the default `count` is 16. For the `hex` and Bytewords (`btw`, `btwu`, `btwm`) output formats, the count is the number of bytes generated. For other output formats, `count` is the number of "output units" (e.g., bits, cards, die rolls, etc.)
8890

8991
```
@@ -139,6 +141,7 @@ $ seedtool --out cards --count 5
139141

140142
**✅ NOTE:** Playing cards may be duplicated; it is as if each card is drawn from a freshly shuffled deck.
141143

144+
### Low & High
142145
Sequences of random integers may be generated. By default, `--count` is 16, `--low` is 0, and `--high` is 9.
143146

144147
`low` < `high` < `256`
@@ -159,6 +162,8 @@ $ seedtool --out ints --count 8 --low 1 --high 100
159162
76 15 25 57 99 41 4 95
160163
```
161164

165+
### BIP39
166+
162167
BIP39 can be used as an output format. The default `--count` is 16 bytes (128 bits, 12 words), but may be any multiple of 2 in [12,32].
163168

164169
```
@@ -177,6 +182,8 @@ $ seedtool --out bip39 --count 32
177182
mind knock evoke recycle payment snack pear party mean rubber open work rug trophy federal connect indicate security release three buzz buddy motion game
178183
```
179184

185+
### SSKRs
186+
180187
SSKR can be used as an output format. By default `--count` is 16 bytes (128 bits, 20 words), but may be any multiple of 2 in [16-32]. By default a single 1-of-1 share is generated. This is the same as running `seedtool --out sskr --group-threshold 1 --group 1-of-1`.
181188

182189
```
@@ -240,6 +247,8 @@ tuna acid epic gyro into knob brag cusp aqua slot film each horn cash sets hang
240247

241248
When the `--in` option is used, seedtool takes one or more arguments and uses them to construct the seed. If no arguments are given on the command line, it reads input from stdin and uses what it reads to construct the seed. In the examples below, the end of input to stdin is marked by `^D` on its own line.
242249

250+
### Hex & Bytewords
251+
243252
When the input format is `hex` or Bytewords (`btw`, `btwu`, `btwm`), the construction is the identity function (passthrough.)
244253

245254
```
@@ -262,6 +271,8 @@ dindcstidedrwsvsfeztlswlhfwytpolmossrkhl
262271
279b18d0282aefe845fb83e956eed8a6
263272
```
264273

274+
### Other Inputs
275+
265276
For the other input formats, each "unit" of the input (bit, digit, card, etc.) is converted to a byte and placed in an array. The SHA256 is then taken of the resulting array, yielding a deterministic seed. This seed is then used to generate a cryptographic seed of `count` bytes.
266277

267278
```
@@ -346,6 +357,8 @@ $ seedtool --in ints 71 22 95 6 23 65 27 10 67 16
346357
a38385ba7a67b7f5882b37f75b43c2df
347358
```
348359

360+
### Piping Output & Input
361+
349362
Output of one call to seedtool can be piped into another.
350363

351364
```
@@ -367,6 +380,8 @@ $ cat dice.asc
367380
4435442555226432
368381
```
369382

383+
### Count Options
384+
370385
If a smaller or larger seed is desired, the `--count` option specifies how many bytes it contains.
371386

372387
```
@@ -392,6 +407,8 @@ $ seedtool --in cards --count 20 6c2c3hthacts6d4hkhtd2d7c6c3sqs6h
392407
731e0a4c76189b2b55f4c705ccbb0105d3ee72c0
393408
```
394409

410+
### Inputs for BIP39 & SSKR
411+
395412
`bip39` and `sskr` output formats can be combined with the `random` (default) input format. If the `--count N` option is used with the `hex` or Bytewords (`btw`, `btwu`, `btwm`) input formats, it results in a seed of `N` bytes being generated and used.
396413

397414
```
@@ -613,7 +630,7 @@ $ seedtool --in sskr "tuna acid epic gyro brag aqua able able able hill code dut
613630
5d1c30bbc6f3cfd070067b63c851ffe7
614631
```
615632

616-
Seedtool also provides the `--deterministic S` option, which takes a string `S`, produces the SHA256 hash of that string, and then uses that to seed it's own cryptography-quality random number generator it uses for the rest of its run. This means that seeds generated by seedtool with the same `--deterministic` input will yield the same results.
633+
Seedtool also provides the `--deterministic S` option, which takes a string `S`, produces the SHA256 hash of that string, and then uses that to seed its own cryptography-quality random number generator, which it uses for the rest of its run. This means that seeds generated by seedtool with the same `--deterministic` input will yield the same results.
617634

618635
```
619636
#
@@ -797,7 +814,7 @@ UR:CRYPTO-SEED/OEADGDHHGTPKFXLGHHLBPYMHLFRYHLPLSSRKPKAOTPIECFFDENTNJNWNPF
797814

798815
`seedqrcode.png`:
799816

800-
![](manual-images/seedqrcode.png)
817+
![](../manual-images/seedqrcode.png)
801818

802819
The payload of a UR is [CBOR](https://tools.ietf.org/html/rfc7049) encoded as [Bytewords](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-012-bytewords.md). If you wish to examine the CBOR encoding, you can use seedtool to decode the Bytewords payload of a UR. In this example we use the seed above, but only decode the part after the slash as Bytewords.
803820

Docs/Usage.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# 🌱 Seedtool Usage Examples
2+
3+
## Basic Information
4+
5+
### Display usage and help information
6+
7+
```
8+
$ seedtool --help
9+
```
10+
11+
## Seed Generation
12+
13+
### Generate a cryptographically-strong 16-byte seed
14+
15+
```
16+
$ seedtool
17+
8935a8068526d84da555cdb741a3b8a8
18+
```
19+
20+
### Generate a seed using entropy provided as coin flips
21+
22+
```
23+
$ seedtool --in bits 1110110001110111
24+
8d933e43b1bc8f2e3fc27adc98ad4534
25+
```
26+
27+
### Generate a 32-byte seed using entropy provided as cards drawn from a deck of playing cards
28+
29+
```
30+
$ seedtool --count 32 --in cards 6c9s8c7c9c4cah6c2sjs7d5c2s4c4dqs
31+
7df301924511326d7350be14c9e7176d98e945f9ad0ed034726ad4ee0de59c25
32+
```
33+
34+
## BIP-39 Mnemonics
35+
36+
### Encode a 16-byte seed as BIP-39
37+
38+
```
39+
$ seedtool --in hex --out bip39 8935a8068526d84da555cdb741a3b8a8
40+
matrix pull accuse apart horn chat next rifle resemble artist until eye
41+
```
42+
43+
### Decode BIP-39 mnemonics to hex
44+
45+
```
46+
$ seedtool --in bip39 "matrix pull accuse apart horn chat next rifle resemble artist until eye"
47+
8935a8068526d84da555cdb741a3b8a8
48+
```
49+
50+
## Bytewords
51+
52+
### Decode Bytewords to hex
53+
54+
```
55+
$ seedtool --in btw "deli need cats taxi dice door webs vows free zest legs wall half waxy trip oval memo sets rock hill"
56+
279b18d0282aefe845fb83e956eed8a6
57+
```
58+
59+
## SSKR
60+
61+
### Generate a 16-byte seed and encode it using SSKR as 3 shares, 2 of which are required for recovery
62+
63+
```
64+
$ seedtool --out sskr --group 2-of-3
65+
tuna acid epic gyro edge twin able acid able yoga nail wand keno paid ruin jazz keys acid time film pool skew flew luck ruby song owls soap obey
66+
tuna acid epic gyro edge twin able acid acid yell omit mild webs warm epic flew liar view fuel deli fund glow skew dull knob claw gray surf wand
67+
tuna acid epic gyro edge twin able acid also visa wave bulb hope drum quad duty need tied vast barn kick task gray tent crux owls easy jolt toil
68+
```
69+
70+
### Recover a SSKR-encoded seed using 2 of the 3 shares
71+
72+
```
73+
$ seedtool --in sskr
74+
tuna acid epic gyro edge twin able acid able yoga nail wand keno paid ruin jazz keys acid time film pool skew flew luck ruby song owls soap obey
75+
tuna acid epic gyro edge twin able acid also visa wave bulb hope drum quad duty need tied vast barn kick task gray tent crux owls easy jolt toil
76+
^D
77+
8a7e9c3c0d783371d80e1192e5f6217d
78+
```
79+
80+
## UR
81+
82+
### Generate a seed, encode it as UR, transform it to upper case, display it on the console, and encode it to a QR Code in the file "seedqrcode.png"
83+
84+
```
85+
$ seedtool --ur | tr [:lower:] [:upper:] | tee /dev/tty | qrencode -o seedqrcode.png -l L
86+
UR:CRYPTO-SEED/OEADGDHHGTPKFXLGHHLBPYMHLFRYHLPLSSRKPKAOTPIECFFDENTNJNWNPF
87+
```
88+
89+
![](../manual-images/seedqrcode.png)
90+
91+
### Generate a 64-byte seed using a deterministic random number generator and encode it as a multi-part UR with a maximum fragment size of 20 bytes
92+
93+
```
94+
$ seedtool --deterministic=TEST --count 64 --ur=20
95+
ur:crypto-seed/1-4/ltadaacsgecyuywdrnesguoeadhdfznteelblrcygldwvarflojtcywyjytpfsmdidpk
96+
ur:crypto-seed/2-4/ltaoaacsgecyuywdrnesgudkfwprylienshnjnpluypmamtkmybsjkspvseeehwnpdbb
97+
ur:crypto-seed/3-4/ltaxaacsgecyuywdrnesgusawmrltdlplgkplfbkqzztglfeoyaegsnedtronnfgpsas
98+
ur:crypto-seed/4-4/ltaaaacsgecyuywdrnesguwsdpgtimmwzspfqdjkhshyaotpiecffdemaeaedmnsoxhf
99+
```
100+
101+
### Same as above, but generate 5 additional parts using fountain codes
102+
103+
```
104+
$ seedtool --deterministic=TEST --count 64 --ur=20 --parts 5
105+
ur:crypto-seed/1-4/ltadaacsgecyuywdrnesguoeadhdfznteelblrcygldwvarflojtcywyjytpfsmdidpk
106+
ur:crypto-seed/2-4/ltaoaacsgecyuywdrnesgudkfwprylienshnjnpluypmamtkmybsjkspvseeehwnpdbb
107+
ur:crypto-seed/3-4/ltaxaacsgecyuywdrnesgusawmrltdlplgkplfbkqzztglfeoyaegsnedtronnfgpsas
108+
ur:crypto-seed/4-4/ltaaaacsgecyuywdrnesguwsdpgtimmwzspfqdjkhshyaotpiecffdemaeaedmnsoxhf
109+
ur:crypto-seed/5-4/ltahaacsgecyuywdrnesguwsdpgtimmwzspfqdjkhshyaotpiecffdemaeaegtndkijp
110+
ur:crypto-seed/6-4/ltamaacsgecyuywdrnesguoeadhdfznteelblrcygldwvarflojtcywyjytptkwfjech
111+
ur:crypto-seed/7-4/ltataacsgecyuywdrnesgusbjlzontwtiytiueutrdwfaachwmcmfrzovseerfsefmdp
112+
ur:crypto-seed/8-4/ltayaacsgecyuywdrnesguhnwdwsmocwrhbkambezstspdytdtjthfjshlhnbdpygmao
113+
ur:crypto-seed/9-4/ltasaacsgecyuywdrnesgusawmrltdlplgkplfbkqzztglfeoyaegsnedtroynmduyvl
114+
```
115+
116+
### Recover the seed from UR using a subset of the generated parts
117+
118+
```
119+
$ seedtool --in ur
120+
ur:crypto-seed/2-4/ltaoaacsgecyuywdrnesgudkfwprylienshnjnpluypmamtkmybsjkspvseeehwnpdbb
121+
ur:crypto-seed/4-4/ltaaaacsgecyuywdrnesguwsdpgtimmwzspfqdjkhshyaotpiecffdemaeaedmnsoxhf
122+
ur:crypto-seed/6-4/ltamaacsgecyuywdrnesguoeadhdfznteelblrcygldwvarflojtcywyjytptkwfjech
123+
ur:crypto-seed/8-4/ltayaacsgecyuywdrnesguhnwdwsmocwrhbkambezstspdytdtjthfjshlhnbdpygmao
124+
^D
125+
9d347f841a4e2ce6bc886e1aee74d82442b2f7649c606daedbad06cf8f0f73c8e834c2ebb7d2868d75820ab4fb4e45a1004c9f29b8ef2d4d6a94fab0b373615e
126+
```
127+

0 commit comments

Comments
 (0)