|
| 1 | +# Seedtool Manual |
| 2 | + |
| 3 | +*Copyright © 2020 by Blockchain Commons, LLC* |
| 4 | + |
| 5 | +*Licensed under the "BSD-2-Clause Plus Patent License"* |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +The following is a draft design document. Comments requested. |
| 10 | + |
| 11 | +There is no mention below of password functionality for BIP39 and SLIP39 production. The current design allows for later inclusion of this feature via a `--password` option. |
| 12 | + |
| 13 | +## General Functionality |
| 14 | + |
| 15 | +Supports help. |
| 16 | + |
| 17 | +``` |
| 18 | +$ seedtool --help |
| 19 | +<help text here> |
| 20 | +``` |
| 21 | + |
| 22 | +Supports version number. |
| 23 | + |
| 24 | +``` |
| 25 | +$ seedtool --version |
| 26 | +1.0 |
| 27 | +``` |
| 28 | + |
| 29 | +## Generating Random Seeds |
| 30 | + |
| 31 | +When run by itself, seedtool generates 32 random bytes (256 bits) and displays them as hex. This is the same as running `seedtool --out hex`. |
| 32 | + |
| 33 | +``` |
| 34 | +$ seedtool |
| 35 | +866b4a995209b20a87a4b32d7436363923cf99accd8f2a0b8b1dacf3f41113d9 |
| 36 | +``` |
| 37 | + |
| 38 | +An output format `--out` and count `--count` may be specified. The default count is 32. |
| 39 | + |
| 40 | +Playing cards may be duplicated; it is as if each card is drawn from a freshly shuffled deck. |
| 41 | + |
| 42 | +``` |
| 43 | +$ seedtool --out hex |
| 44 | +3d1d142cd016cf8a393a1b477891c5e594fb7c9479b175a0db653067d6de0b17 |
| 45 | +
|
| 46 | +$ seedtool --out bits |
| 47 | +00100010011111110100010100010000 |
| 48 | +
|
| 49 | +$ seedtool --out cards |
| 50 | +5s4hth3s6s4s4hjdtdtdjckc7d5std6d5d4hqhkh4cks4h4sas5c6c2d6h2s2h2c |
| 51 | +
|
| 52 | +$ seedtool --out dice |
| 53 | +23431546432642433535135232426424 |
| 54 | +
|
| 55 | +$ seedtool --out base6 |
| 56 | +14135001101503150040353141454122 |
| 57 | +
|
| 58 | +$ seedtool --out base10 |
| 59 | +73127665663823895387159704567613 |
| 60 | +
|
| 61 | +$ seedtool --out cards --count 10 |
| 62 | +8hqd9h4sksjc3c7h7c6s |
| 63 | +``` |
| 64 | + |
| 65 | +Sequences of random integers may be generated. By default, `--count` is 32, `--low` is 0, and `--high` is 9. |
| 66 | + |
| 67 | +`low` < `high` < `256` |
| 68 | + |
| 69 | +``` |
| 70 | +$ seedtool --out ints |
| 71 | +8 6 4 1 2 0 5 1 4 7 0 7 8 0 3 3 0 6 8 3 4 1 0 4 5 4 0 4 7 6 4 4 |
| 72 | +
|
| 73 | +$ seedtool --out ints --count 10 --low 1 --high 100 |
| 74 | +71 22 95 6 23 65 27 10 67 16 |
| 75 | +``` |
| 76 | + |
| 77 | +BIP39 can be used as an output format. The default `--count` is 32 bytes (256 bits, 24 words), but may be any multiple of 4 in [4,32]. |
| 78 | + |
| 79 | +``` |
| 80 | +$ seedtool --out bip39 |
| 81 | +stay puzzle motion ocean hotel drive market fiber voyage group swift fossil rebuild car favorite priority head slim capital digital loud body fetch document |
| 82 | +
|
| 83 | +$ seedtool --out bip39 --count 16 |
| 84 | +version tray choice heart door fabric sea buffalo chapter soda symbol garlic |
| 85 | +``` |
| 86 | + |
| 87 | +SLIP39 can be used as an output format. By default `--count` is 32 bytes (256 bits, 33 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 slip39 --group-threshold 1 --group 1-of-1`. |
| 88 | + |
| 89 | +``` |
| 90 | +$ seedtool --out slip39 |
| 91 | +usher deal academic academic airline scene pickup makeup obesity eclipse ticket cinema therapy escape jury scroll credit easel failure costume manager theater branch swimming loan main losing move wolf snapshot frost decision acid |
| 92 | +
|
| 93 | +$ seedtool --out slip39 --count 16 |
| 94 | +formal husband academic academic devote client fangs carve acid maximum shelter trouble cubic firefly adapt grin shrimp therapy wits mayor |
| 95 | +``` |
| 96 | + |
| 97 | +n-of-m SLIP39 shares can be generated by specifing one or more groups. |
| 98 | + |
| 99 | +``` |
| 100 | +$ seedtool --out slip39 --count 16 --group 2-of-3 |
| 101 | +bucket stay academic acid cover shaft lilac blue oral buyer prisoner ultimate material raisin deadline forecast very damage writing blimp |
| 102 | +bucket stay academic agency client traffic brother literary custody index piece sweater dragon fiber forbid pickup upstairs teaspoon fake cover |
| 103 | +bucket stay academic always deliver lying space decent reject salary sniff manual pile herd predator activity desktop declare vexed sweater |
| 104 | +``` |
| 105 | + |
| 106 | +Multiple groups and a group threshold may be specified. If omitted, the default `--group-threshold` is 1. |
| 107 | + |
| 108 | +The first two words of a set of SLIP39 shares are the same across all the shares. Each group within a set of SLIP39 shares has the same third word. |
| 109 | + |
| 110 | +``` |
| 111 | +$ seedtool --out slip39 --count 16 --group-threshold 2 --group 2-of-3 --group 3-of-5 --group 3-of-5 |
| 112 | +timely deal acrobat leaf artwork blessing subject mixture kitchen soldier depict practice hunting railroad enforce belong edge mansion lyrics surprise |
| 113 | +timely deal acrobat lily armed kidney gesture paid evoke crucial scene forecast magazine favorite omit username alpha axis trust rhyme |
| 114 | +timely deal acrobat lungs arena season pleasure nuclear observe duration stilt webcam tidy huge nuclear grin sled network mouse voting |
| 115 | +timely deal beard learn branch maximum desktop welcome sheriff gray pickup depart husband describe domain buyer trash mandate dress trust |
| 116 | +timely deal beard lips auction garden argue pacific bulge salt retailer forbid deny escape ecology harvest argue music process fumes |
| 117 | +timely deal beard luxury both album problem anxiety rich wolf industry industry thorn threaten enemy verify type aviation aspect weapon |
| 118 | +timely deal beard march acrobat training music hospital holiday forward hunting carbon phrase nylon dress lizard anatomy bike ordinary exact |
| 119 | +timely deal beard method again party shrimp sprinkle terminal faint legs romp fluff easel video cards alpha surprise style duckling |
| 120 | +timely deal ceramic learn brave rhythm family election headset genre ladle cards eclipse gray liberty public raisin warmth romp crisis |
| 121 | +timely deal ceramic lips amount walnut bumpy headset mobile eraser necklace yoga relate promise hour depict standard fatal purple debris |
| 122 | +timely deal ceramic luxury agree exceed grownup cards soul trouble seafood voice guitar safari royal skunk union railroad friendly eraser |
| 123 | +timely deal ceramic march blind answer cylinder dilemma crazy ruler chubby body midst amazing cubic explain march careful deadline failure |
| 124 | +timely deal ceramic method beyond penalty cards image testify detailed kitchen thank column merchant spark ecology garden genius gasoline pile |
| 125 | +``` |
| 126 | + |
| 127 | +## Generating Seeds from Provided Entropy |
| 128 | + |
| 129 | +When the `--in` option is used, seedtool takes input from stdin and uses it to construct the seed. In the examples below, the end of input to stdin is marked by `^D` on its own line. |
| 130 | + |
| 131 | +When the input format is `hex`, the construction is the identity function (passthrough.) |
| 132 | + |
| 133 | +``` |
| 134 | +$ seedtool --in hex |
| 135 | +3d1d142cd016cf8a393a1b477891c5e594fb7c9479b175a0db653067d6de0b17 |
| 136 | +^D |
| 137 | +3d1d142cd016cf8a393a1b477891c5e594fb7c9479b175a0db653067d6de0b17 |
| 138 | +``` |
| 139 | + |
| 140 | +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. |
| 141 | + |
| 142 | +``` |
| 143 | +$ seedtool --in bits |
| 144 | +00100010011111110100010100010000 |
| 145 | +^D |
| 146 | +f5ed0d7a8731424f5a5596dae07c4ced7b7ea9430f2ab1d407b3c5c8fe789fb8 |
| 147 | +
|
| 148 | +$ seedtool --in cards |
| 149 | +5s4hth3s6s4s4hjdtdtdjckc7d5std6d5d4hqhkh4cks4h4sas5c6c2d6h2s2h2c |
| 150 | +^D |
| 151 | +1046e7b5a12a8c662599d094c939351c18e20ccde8dedd2b72d0494db8c2d4dd |
| 152 | +
|
| 153 | +$ seedtool --in dice |
| 154 | +23431546432642433535135232426424 |
| 155 | +^D |
| 156 | +aea2cd642bbe2f950eb77f9c508408028e20473a9fe3b11db003ca55f5ef1358 |
| 157 | +
|
| 158 | +$ seedtool --in base6 |
| 159 | +14135001101503150040353141454122 |
| 160 | +^D |
| 161 | +063aadc267da52aeeda80d77feded8a11885641a56a4312db9e106c57b875de2 |
| 162 | +
|
| 163 | +$ seedtool --in base10 |
| 164 | +73127665663823895387159704567613 |
| 165 | +^D |
| 166 | +ae6c78b68370757230102ce26d7dd40740886a4ff6dc9bd122c914695ecbdc5f |
| 167 | +
|
| 168 | +$ seedtool --in ints |
| 169 | +71 22 95 6 23 65 27 10 67 16 |
| 170 | +^D |
| 171 | +e98f4b80aa0eac6aac1a2086eb931f1404d8f2d193a5d6bb6cfae68161fd3da4 |
| 172 | +``` |
| 173 | + |
| 174 | +If a smaller seed is desired, the `--count` option can specify that the SHA256 be truncated to a fewer number of bytes. |
| 175 | + |
| 176 | +``` |
| 177 | +$ seedtool --in bits --count 16 |
| 178 | +00100010011111110100010100010000 |
| 179 | +^D |
| 180 | +f5ed0d7a8731424f5a5596dae07c4ced |
| 181 | +
|
| 182 | +$ seedtool --in cards --count 16 |
| 183 | +5s4hth3s6s4s4hjdtdtdjckc7d5std6d5d4hqhkh4cks4h4sas5c6c2d6h2s2h2c |
| 184 | +^D |
| 185 | +1046e7b5a12a8c662599d094c939351c |
| 186 | +``` |
| 187 | + |
| 188 | +BIP39 and SLIP39 output formats can be combined with various other input formats. If the `--count N` option is used with the `hex` input format, it results in only the first `N` bytes of the input being used. If the `--count N` option is used with other input formats, it results in only the first `N` bytes of the SHA256 (computed as described above) to be used. |
| 189 | + |
| 190 | +``` |
| 191 | +$ seedtool --in hex --out bip39 |
| 192 | +65d68e2855c2dd7b246de65997b016c3209b78782c8305cc30d75af681dc48bd |
| 193 | +^D |
| 194 | +clay notable jeans deliver mass nut claim rib double trick will awful ability lonely toss cloth myth heart box just fat disease prefer stool |
| 195 | +
|
| 196 | +$ seedtool --in dice --count 16 --out slip39 --group 2-of-3 |
| 197 | +54242562454251545633432454422543 |
| 198 | +^D |
| 199 | +traffic branch academic acid adapt zero erode similar review platform curly knit trend usher distance escape pants machine nylon imply |
| 200 | +traffic branch academic agency best downtown very keyboard story brave famous spelling diminish observe remove corner ticket laden justice capture |
| 201 | +traffic branch academic always climate heat dismiss pencil deny snapshot research legend moment clothes filter memory crucial worthy argue mountain |
| 202 | +``` |
| 203 | + |
| 204 | +BIP39 and SLIP39 can be used as input formats, in which case the original seed is output. Note that the seed returned is *not* the original entropy that was used to create the seed (like dice rolls) but the SHA256 (or part thereof) that was originally used to create the BIP39 words or SLIP39 shares. |
| 205 | + |
| 206 | +``` |
| 207 | +$ seedtool --in bip39 |
| 208 | +clay notable jeans deliver mass nut claim rib double trick will awful ability lonely toss cloth myth heart box just fat disease prefer stool |
| 209 | +^D |
| 210 | +65d68e2855c2dd7b246de65997b016c3209b78782c8305cc30d75af681dc48bd |
| 211 | +
|
| 212 | +$ seedtool --in slip39 |
| 213 | +traffic branch academic acid adapt zero erode similar review platform curly knit trend usher distance escape pants machine nylon imply |
| 214 | +traffic branch academic always climate heat dismiss pencil deny snapshot research legend moment clothes filter memory crucial worthy argue mountain |
| 215 | +^D |
| 216 | +ae752acc827ea8c02c6cc2f57370a50f |
| 217 | +``` |
| 218 | + |
| 219 | +## Deterministic Randomness |
| 220 | +Normally seedtool uses a cryptographically-strong random number generator provided by the operating system. This is also used when constructing SLIP39 shares, so the same entropy input will yield the different shares each time. |
| 221 | + |
| 222 | +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. |
| 223 | + |
| 224 | +In the example below, seedtool is run with a `--deterministic test` twice, producing the same results. In the third run the string is `test2`, producing different, yet still deterministic results. |
| 225 | + |
| 226 | +``` |
| 227 | +$ seedtool --deterministic test |
| 228 | +3b1e91644fd5475251f55d3ba98d3956bd7c73ce478afb5ce047682a4417e292 |
| 229 | +
|
| 230 | +$ seedtool --deterministic test |
| 231 | +3b1e91644fd5475251f55d3ba98d3956bd7c73ce478afb5ce047682a4417e292 |
| 232 | +
|
| 233 | +$ seedtool --deterministic test2 |
| 234 | +68b275e740cb5f89bb5444694aaa2dbc82ab6aa4d9869b3995cb6aa3c622e6d1 |
| 235 | +``` |
| 236 | + |
| 237 | +In this example, the same entropy is used twice in producing a SLIP39 share, which would normally result in two different shares being produced. But by providing `--deterministic test`, the same results are produced. In the third run, there is no `--deterministic` option, so different, truly randomized shares are produced even though the input entropy is the same. |
| 238 | + |
| 239 | +``` |
| 240 | +$ seedtool --deterministic test --in dice --count 16 --out slip39 --group 2-of-3 |
| 241 | +5253423623323232 |
| 242 | +^D |
| 243 | +peaceful traffic academic acid artwork else mixed twice standard fishing railroad safari herald ceramic training famous axle mandate lyrics aunt |
| 244 | +peaceful traffic academic agency carbon sprinkle echo secret slow market idea intend counter home pajamas silver flash edge slow upgrade |
| 245 | +peaceful traffic academic always critical jury depend beyond clock weapon dynamic practice threaten river isolate husky funding welcome have priority |
| 246 | +
|
| 247 | +$ seedtool --deterministic test --in dice --count 16 --out slip39 --group 2-of-3 |
| 248 | +5253423623323232 |
| 249 | +^D |
| 250 | +peaceful traffic academic acid artwork else mixed twice standard fishing railroad safari herald ceramic training famous axle mandate lyrics aunt |
| 251 | +peaceful traffic academic agency carbon sprinkle echo secret slow market idea intend counter home pajamas silver flash edge slow upgrade |
| 252 | +peaceful traffic academic always critical jury depend beyond clock weapon dynamic practice threaten river isolate husky funding welcome have priority |
| 253 | +
|
| 254 | +$ seedtool --in dice --count 16 --out slip39 --group 2-of-3 |
| 255 | +5253423623323232 |
| 256 | +^D |
| 257 | +distance isolate academic acid campus upgrade much luck grin material voting forward pencil union worthy demand decent armed switch equation |
| 258 | +distance isolate academic agency alto payment tension river script prevent lair solution agree remind destroy learn earth industry oral bishop |
| 259 | +distance isolate academic always costume fiber behavior flame pancake slice luxury flea gesture ecology herd flavor daisy voting wavy cradle |
| 260 | +``` |
0 commit comments