Documentation

QedShare.Encoding.Wordlist

BIP-39 English word list #

The 2048 words of the BIP-39 English word list, used by the word form of shares (README: Share format). Word number i stands for the 11-bit value i.

Checked here by Lean: the list has 2048 entries, no word appears twice (words_injective), no two words share their first 4 letters, lookup of a listed word gives its position (lookup_getElem), and a typed prefix of 4 or more letters fits at most one word (prefix_unique).

Not BIP-39. qedshare only borrows the word list. A qedshare word share is not a BIP-39 mnemonic and must never be used as a wallet seed phrase.

Source: https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt (SHA-256 2f5eed53a4727b4bf8880d8f3f199efc90e58503646d9ff8eff3a2ed3b24dbda), from BIP-39 by Marek Palatinus, Pavol Rusnak, Aaron Voisine and Sean Bowe, licensed under the MIT License:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The 2048 BIP-39 English words, in the official order: word number i encodes the 11-bit value i.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    words has exactly 2048 entries, one per 11-bit value.

    A letter's value: a ↦ 1, …, z ↦ 26 (a character's code mod 32).

    Equations
    Instances For

      The first n letters of w as a base-32 number, padded on the right with zeros to n letters. For lowercase words, comparing these numbers compares the words alphabetically, but the proofs below never need that: they only use that equal words get equal numbers.

      Equations
      Instances For

        true when every number is smaller than the next one.

        Equations
        Instances For

          The words' codes strictly increase along the list (checked by decide).

          The codes of the 4-letter prefixes strictly increase too, so no two words share their first four letters (checked by decide).

          Distinct words #

          theorem QedShare.Wordlist.lt_of_increasing {l : List Nat} :
          increasing l = true → ∀ {i j : Nat} (hij : i < j) (hj : j < l.length), l[i] < l[j]

          In a list accepted by increasing, an earlier element is smaller than a later one.

          theorem QedShare.Wordlist.eq_of_codeN_eq {n : Nat} (hinc : increasing (List.map (codeN n) words.toList) = true) {i j : Nat} (hi : i < words.size) (hj : j < words.size) (h : codeN n words[i] = codeN n words[j]) :
          i = j

          If the codeN n values of the words strictly increase, two positions whose words have the same code are the same position.

          theorem QedShare.Wordlist.words_injective {i j : Nat} (hi : i < words.size) (hj : j < words.size) (h : words[i] = words[j]) :
          i = j

          No word appears twice: different positions hold different words.

          Looking words up #

          The position of a word given exactly (lowercase), or none.

          Equations
          Instances For

            Looking up word number i gives back i.

            Forgiving lookup for typed-in words #

            People copy word shares by hand, so lookup also accepts upper case and abbreviations: any prefix of at least 4 letters of a word (BIP-39 words are identified by their first 4 letters). The exact match is tried first, so lookup of a listed word is always that word's position (lookup_getElem), and a prefix can never match two words (prefix_unique).

            Position of the first word that starts with the letters u, if u has at least 4 letters.

            Equations
            Instances For

              Position of a typed-in word: exact match, else its lowercase form, else a unique prefix of at least 4 letters.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Looking up word number i gives back i.

                theorem QedShare.Wordlist.take4_of_prefix {w v : List Char} (hw : 4 ≤ w.length) (h : w <+: v) :

                If w has at least 4 letters and is a prefix of word v, then v starts with the same 4 letters as w.

                theorem QedShare.Wordlist.prefix_unique {u : String} (hu : 4 ≤ u.length) {i j : Nat} (hi : i < words.size) (hj : j < words.size) (hpi : u.toList <+: words[i].toList) (hpj : u.toList <+: words[j].toList) :
                i = j

                A typed-in prefix of at least 4 letters fits at most one word.

                Every word is non-empty and made only of the letters a–z (character codes 97–122), checked by decide. (Stated with List.all: the kernel evaluates Array.all, which uses well-founded recursion, far more slowly.)

                A letter a–z is not whitespace.

                Every word is non-empty and contains no whitespace, so words joined with spaces can be split apart again.