├── .vscode └── extensions.json ├── src ├── fonts │ ├── SpaceMono-Bold.ttf │ ├── SpaceGrotesk-Bold.ttf │ ├── SpaceGrotesk-Light.ttf │ ├── SpaceMono-Italic.ttf │ ├── SpaceMono-Regular.ttf │ ├── SpaceGrotesk-Medium.ttf │ ├── SpaceGrotesk-Regular.ttf │ ├── SpaceMono-BoldItalic.ttf │ ├── SpaceGrotesk-SemiBold.ttf │ ├── SpaceGrotesk-VariableFont_wght.ttf │ └── OFL.txt ├── shim.js ├── main.js ├── util.js ├── wallet.js └── App.svelte ├── .gitignore ├── LICENSE.md ├── vite.config.js ├── jsconfig.json ├── package.json ├── README.md └── index.html /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["svelte.svelte-vscode"] 3 | } 4 | -------------------------------------------------------------------------------- /src/fonts/SpaceMono-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceMono-Bold.ttf -------------------------------------------------------------------------------- /src/shim.js: -------------------------------------------------------------------------------- 1 | export let Buffer = require("buffer").Buffer; 2 | export let process = require("process/browser"); 3 | -------------------------------------------------------------------------------- /src/fonts/SpaceGrotesk-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceGrotesk-Bold.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceGrotesk-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceGrotesk-Light.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceMono-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceMono-Italic.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceMono-Regular.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceGrotesk-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceGrotesk-Medium.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceGrotesk-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceGrotesk-Regular.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceMono-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceMono-BoldItalic.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceGrotesk-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceGrotesk-SemiBold.ttf -------------------------------------------------------------------------------- /src/fonts/SpaceGrotesk-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/seed-poem-tool/HEAD/src/fonts/SpaceGrotesk-VariableFont_wght.ttf -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import attachFastClick from "fastclick"; 2 | import App from "./App.svelte"; 3 | 4 | attachFastClick(document.body); 5 | 6 | const app = new App({ 7 | target: document.body, 8 | }); 9 | 10 | export default app; 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | 26 | src/node-pos.js 27 | src/random-poem.js 28 | src/data/haiku-best-patterns.txt 29 | src/data/pos.json -------------------------------------------------------------------------------- /src/util.js: -------------------------------------------------------------------------------- 1 | export function pick(array) { 2 | return array[Math.floor(Math.random() * array.length)]; 3 | } 4 | 5 | export const normalize = (poem) => 6 | poem 7 | .toLowerCase() 8 | .replace(/[\-\–\—\,\!\:\?]/g, " ") 9 | .replace(/\s+/g, " ") 10 | .trim(); 11 | export const split = (poem) => normalize(poem).split(/\s/g); 12 | export const validText = (poem) => /^[a-z\s\,\-\–\—\!\:\?]+$/gi.test(poem); 13 | export const isSpace = (c) => /[\,\-\–\—\!\:\?\s]/.test(c); 14 | export const isChar = (c) => /[a-z]/.test(c); 15 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2022 Matt DesLauriers 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import { svelte } from "@sveltejs/vite-plugin-svelte"; 3 | import inject from "@rollup/plugin-inject"; 4 | 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [svelte()], 8 | resolve: { 9 | alias: { 10 | // "readable-stream": "vite-compatible-readable-stream", 11 | process: "process/browser", 12 | stream: "stream-browserify", 13 | zlib: "browserify-zlib", 14 | util: "util", 15 | // web3: path.resolve(__dirname, "./node_modules/web3/dist/web3.min.js"), 16 | }, 17 | }, 18 | define: { 19 | global: "window", 20 | // "process.env": {}, 21 | }, 22 | // optimizeDeps: { 23 | // esbuildOptions: { 24 | // define: { 25 | // global: 'globalThis', 26 | // }, 27 | // inject: ['./src/buffer-shim.js'], 28 | // // plugins: [esbuildCommonjs(['crypto-browserify'])], 29 | // }, 30 | // }, 31 | build: { 32 | commonjsOptions: { 33 | transformMixedEsModules: true, 34 | }, 35 | rollupOptions: {}, 36 | }, 37 | }); 38 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "target": "esnext", 5 | "module": "esnext", 6 | /** 7 | * svelte-preprocess cannot figure out whether you have 8 | * a value or a type, so tell TypeScript to enforce using 9 | * `import type` instead of `import` for Types. 10 | */ 11 | "importsNotUsedAsValues": "error", 12 | "isolatedModules": true, 13 | "resolveJsonModule": true, 14 | /** 15 | * To have warnings / errors of the Svelte compiler at the 16 | * correct position, enable source maps by default. 17 | */ 18 | "sourceMap": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "forceConsistentCasingInFileNames": true, 22 | "baseUrl": ".", 23 | /** 24 | * Typecheck JS in `.svelte` and `.js` files by default. 25 | * Disable this if you'd like to use dynamic types. 26 | */ 27 | "checkJs": true 28 | }, 29 | /** 30 | * Use global.d.ts instead of compilerOptions.types 31 | * to avoid limiting type declarations. 32 | */ 33 | "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] 34 | } 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "seed-poem-tool", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "description": "", 7 | "main": "index.js", 8 | "license": "MIT", 9 | "author": { 10 | "name": "Matt DesLauriers", 11 | "email": "dave.des@gmail.com", 12 | "url": "https://github.com/mattdesl" 13 | }, 14 | "scripts": { 15 | "dev": "vite", 16 | "build": "vite build", 17 | "preview": "vite preview", 18 | "bundle-util": "esbuild src/wallet.js --bundle --format=esm --define:global=window --inject:src/shim.js --outfile=src/util/wallet.bundled.js" 19 | }, 20 | "dependencies": { 21 | "@ethersproject/wallet": "^5.6.0", 22 | "@rollup/plugin-inject": "^4.0.4", 23 | "bip39-light": "^1.0.7", 24 | "browserify-zlib": "^0.2.0", 25 | "bs58check": "^2.1.2", 26 | "buffer": "^6.0.3", 27 | "canvas-sketch": "^0.7.5", 28 | "canvas-sketch-util": "^1.10.0", 29 | "eases": "^1.0.8", 30 | "esbuild": "^0.14.48", 31 | "euclidean-distance": "^1.0.0", 32 | "events": "^3.3.0", 33 | "fastclick": "^1.0.6", 34 | "gl-matrix": "^3.4.3", 35 | "libsodium-wrappers-sumo": "^0.7.9", 36 | "path-browserify": "^1.0.1", 37 | "pathfinding": "^0.4.18", 38 | "pos-tag": "^2.2.2", 39 | "process": "^0.11.10", 40 | "stream-browserify": "^3.0.0", 41 | "vite-plugin-singlefile": "^0.6.3" 42 | }, 43 | "browser": { 44 | "path": "path-browserify", 45 | "crypto": "crypto-browserify", 46 | "stream": "stream-browserify" 47 | }, 48 | "devDependencies": { 49 | "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", 50 | "canvas-sketch-cli": "^1.11.15", 51 | "svelte": "^3.44.0", 52 | "vite": "^2.9.12" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/wallet.js: -------------------------------------------------------------------------------- 1 | import sodium from "libsodium-wrappers-sumo"; 2 | import bs58check from "bs58check"; 3 | 4 | import Bip39 from "bip39-light"; 5 | 6 | import { 7 | mnemonicToSeed, 8 | generateMnemonic, 9 | validateMnemonic, 10 | } from "bip39-light"; 11 | 12 | import { Wallet } from "@ethersproject/wallet"; 13 | 14 | export const defaultPath = "m/44'/60'/0'/0/0"; 15 | export const wordlists = Bip39.wordlists; 16 | 17 | const prefix = { 18 | tz1: new Uint8Array([6, 161, 159]), 19 | edsk: new Uint8Array([43, 246, 78, 7]), 20 | edpk: new Uint8Array([13, 15, 37, 217]), 21 | }; 22 | 23 | const b58cencode = function (payload, prefixArg) { 24 | var n = new Uint8Array(prefixArg.length + payload.length); 25 | n.set(prefixArg); 26 | n.set(payload, prefixArg.length); 27 | return bs58check.encode(Buffer.from(n)); 28 | }; 29 | 30 | export async function createEthereumWallet( 31 | phrase = generateMnemonic(256), 32 | path = defaultPath 33 | ) { 34 | const w = Wallet.fromMnemonic(phrase, path); 35 | return { 36 | mnemonic: phrase, 37 | privateKey: w.privateKey, 38 | publicKey: w.publicKey, 39 | address: w.address, 40 | }; 41 | } 42 | 43 | export async function createTezosWallet(mnemonic = generateMnemonic(160)) { 44 | await sodium.ready; 45 | const s = mnemonicToSeed(mnemonic).slice(0, 32); 46 | const kp = sodium.crypto_sign_seed_keypair(new Uint8Array(s)); 47 | return { 48 | mnemonic, 49 | privateKey: b58cencode(kp.privateKey, prefix.edsk), 50 | publicKey: b58cencode(kp.publicKey, prefix.edpk), 51 | address: b58cencode( 52 | sodium.crypto_generichash(20, kp.publicKey), 53 | prefix.tz1 54 | ), 55 | }; 56 | } 57 | 58 | export { validateMnemonic, generateMnemonic }; 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # seed-poem-tool 2 | 3 | This is a frontend tool to help you craft valid _seed poems_. 4 | 5 | A seed poem is a small 12 to 24 word poem that is also a valid [BIP-39 mnemonic](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase, and therefore provides the reader full access to a cryptocurrency wallet. 6 | 7 | Each word in the poem must be present in the [fixed list of 2048 words](https://github.com/bitcoin/bips/blob/34d211aa93931fa9edb6daee98499c68c7ac0b60/bip-0039/english.txt), and the final word must be a checksum of the entropy of all preceding words. 8 | 9 | _Note:_ This is an experiment in constrained poetry, and not a secure method to store private keys. 10 | 11 | ### live demo 12 | 13 | :sparkles: 14 | 15 | You can see a live version of the app here: 16 | 17 | https://seed-poem-tool.netlify.app/ 18 | 19 | ### default poem 20 | 21 | The default poem for the app is a 12-word haiku that is also a valid seed phrase: 22 | 23 | ```sh 24 | caught under bamboo breeze 25 | gentle summer melody 26 | another moment someone will remember 27 | ``` 28 | 29 | This encodes to the Tezos wallet [tz1Poffo6xjvjBnPUrdUxWvJ76rhN6W39ZZf](https://tzkt.io/tz1Poffo6xjvjBnPUrdUxWvJ76rhN6W39ZZf/operations/) which was used temporarily to store _\[tap\]_—a visual poem, cryptographic puzzle, and non-fungible token. You can read more about it [in this thread](https://twitter.com/mattdesl/status/1540001119237275649). 30 | 31 | ### dev 32 | 33 | To develop the site: 34 | 35 | ```sh 36 | npm i 37 | npm run dev 38 | ``` 39 | 40 | ### build 41 | 42 | To build the site: 43 | 44 | ```sh 45 | npm run build 46 | ``` 47 | 48 | Note the `wallet.js` has to be pre-build using `esbuild` due to a Vite bug with readable-stream. You can do this with the following: 49 | 50 | ```sh 51 | npm run bundle-util 52 | ``` 53 | 54 | If you run into an error with `"path"` module you may need to make sure that `node_modules/libsodium-sumo/package.json` includes the following section before bundling this utility: 55 | 56 | ```js 57 | "browser": { 58 | "fs": false, 59 | "path": "path-browserify" 60 | } 61 | ``` 62 | 63 | (Yes, it's clunky...) 64 | 65 | # License 66 | 67 | The code here is MIT, see [LICENSE.md](./LICENSE.md). Some third-party dependencies and fonts have been included under the `src/` folder that may carry different licenses. 68 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | seed-poem-tool 7 | 13 | 14 | 15 | 20 | 48 | 49 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/fonts/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /src/App.svelte: -------------------------------------------------------------------------------- 1 | 385 | 386 |
387 |

seed poem editor

388 |
389 |

created by mattdesl

390 |
391 | 392 |

393 | A seed poem is a small 12 to 24 word poem that is also a valid 394 | 396 | BIP-39 mnemonic seed phrase, and therefore provides the reader full access to a cryptocurrency wallet. 397 |

398 | 399 |

Each word in the poem must be present in the 400 | fixed list of 2048 words, and the final word must be a checksum of the entropy of all preceding words.

401 | 402 |

Note: This is an experiment in constrained poetry, and not a secure method to store private keys.

403 | 404 |
405 |