Note: You are viewing this blog post without the intended style information, which may result in formatting issues.

Note: This post was written quite some time ago, but originally not published because I never could convince myself that the order insensitivity was actually useful. Publishing it now due to yet another person asking about it.

At DEFCON 22, Dan Kaminsky and I talked a little bit about something I built which he dubbed "Storybits ". Storybits can reversibly transform short strings of binary data into a series of words designed to produce a mental image. Order of the words does not matter, and many typos can be corrected automatically. I already had working code at the time of that talk, but since then it's just been sitting around on my computer. People have been asking about it, so I put it up on GitHub, though it's still a hacky prototype. I've thrown together a demo and written a bit about how it works.

Human brains have enormous storage capacity, but they work very differently from computers. Let's try a little experiment. I'm going to pick a random number between 0 and 213 and give you both the binary representation of that number and the word at that position in a list of common English words. I got "1101000110000" and "radius"? Which is easier to remember? They both represent the same information, but memorizing the binary would take some real effort, whereas a single word is no problem. Our memory works on "chunks" not bits.

While we've got lots of long term memory, deliberately storing anything specific in it can be a challenge. Often people use mnemonics, such as "Please Excuse My Dear Aunt Sally", to transform complicated information into a form that is easier to memorize and recall. Most often this is used to memorize lists of things, but it is possible to generalize the technique to other kinds of data.

When information is encrypted, a large number known as a key is used. The security of a key is based on the number of operations (work) that an attacker would need to do to find the correct key. For anything even remotely secure, this value is so large that it's meaningless to most people. For convenience, a log 2 scale (bits) is used to talk about key security. Doubling the strength of a key adds one bit, increasing it a thousandfold adds about ten bits. For most threat models, 96 bits should be good enough . We can use a trick called key stretching to make guessing up to about a million times slower, bringing that down to 76 bits. In human terms, this would be a random sequence of 23 decimal digits, 17 letters or 7 words (from a list of about 2000).

Many mnemonic systems have been proposed and generating syntactically valid sentences is a really good idea, but implementation is far from trivial. Storybits is my iteration of that. Rather than actual sentences, it generates a series of adjective, noun, verb tuples. Building good wordlists for such a system is fairly tricky. I gathered up lists of common English words split up by type of speech, then filtered out words that were too long, too short or too similar . Finally, Dan and I manually removed words that were semantically similar to other words, had high potential to combine offensively with other words or were hard to spell. We stopped somewhat arbitrarily at 256 words per list. Combined with some clever algorithms, we get a mnemonic passphrase system that handles typos and allows the words to be entered in any order.

How it works Encoding Start with an integer x in the range [0, m) — cracking the encoded output will take the same amount of work as guessing x. Example: Select m = 220 and randomly choose x = 901713. Run a parameter search to find the smallest number of tuples that can represent m. The result will depend on the number wordlists in use and how many words each contains. The algorithms work with any number of wordlists of arbitrary size, but any given word cannot appear in multiple lists. Example: Use three wordlists containing 11, 13 and 7 words respectively. The notation n C k refers to the number of ways k items can be chosen from a list of n items . 11 C 1 × 13 C 1 × 7 C 1 = 1001 < m

11 C 2 × 13 C 2 × 7 C 2 = 90090 < m

11 C 3 × 13 C 3 × 7 C 3 = 1651650 ≥ m So three tuples of are needed, nine words total. Break down x into smaller ones, each corresponding to a combination of words from one of the wordlists. Example: t = x = 901713

11 C 3 = 165; c 1 = t mod 165 = 153; t = t div 165 = 5464

13 C 3 = 286; c 2 = t mod 286 = 104; t = t div 286 = 20

7 C 3 = 35; c 3 = t mod 35 = 20; t = t div 35 = 0 So c = (153, 104, 20). Convert the combination number for each wordlist into a set of positions using a combinatorial number system. Example: t = c 1 = 153

11 C 3 = 165 > t

10 C 3 = 120 ≤ t; p 1 = 10; t = t − 120 = 33

9 C 2 = 36 > t

8 C 2 = 28 ≤ t; p 2 = 8; t = t − 28 = 5

6 C 1 = 6 > t

5 C 1 = 5 ≤ t; p 3 = 5; t = t − 5 = 0 So p = (10, 8, 5) for this wordlist. Words taken based on those computed positions are grouped into tuples. A canonical string representation of those word tuples is returned as the output passphrase. Decoding Start with a typed passphrase. The typed passphrase is converted to lowercase and any character that's not a letter or space is removed. Wherever possible typos are corrected and missing spaces are restored. The words are converted into sets of positions for each wordlist using lookup tables. These tables also have alternate spellings and verb tenses for many words. The sets of positions are turned back into a number for each wordlist by reversing the combinatorial encoding. Those numbers are combined back into the original integer. Efficiency The number of bits represented by w words from a set of n wordlists W 1 …W n respectively containing |W i | words, where w is an integer multiple of n, can be computed as follows: In other words, take the sum of the binary logarithms of the number of possible ways to choose w ÷ n words from each wordlist, rounding down. With the wordlists used in this demo, we get the following values: Words 3 6 9 12 15 21 30 36 51 60 90 141 288 369 Bits 24 44 64 82 99 130 173 200 260 293 389 516 720 754 Notice that as the number of words increases we get diminishing returns on the number of bits represented — this is the price of order insensitivity.

Demo Try generating a random passphrase (this demo encodes 80 bits), then re-type it in the passphrase box with typos and/or words out of order. The error correction algorithms need to precompute some data structures to work effectively, which is done in the background since it takes a few seconds. There will be a message in the box at the bottom of the form when it's done. It can be used with limited error correction almost immediately. It's pretty tolerant of sloppy typing. Full error correction can turn "amswe3rforbadcablenachoxacidrusticvfetchdjacketstuffopenhackyriot" back into "macho acid answering rustic cable fetching stuffy jacket forbidding wacky riot opening". Hex Input Passphrase Corrected Normalized Hex Output