#

seed

(8 articles)

Inheritance and 2/3 seed storage

I wanted to write my system for bitcoin inheritance and seed storage that will likely outlive me - the reason why is recently bitkey (squares hardware wallet) announced their inheritance system which is a vast improvement but still has a single point of failure square and the app they maintain though this is still a good thing and will improve the ecosystem and raise awareness there is a cheaper method that is just a secure but doesn’t have a single point of failure. ## 2/3 seed storage 2/3 seed storage is actually a pretty simple way of splitting up a key into three parts, if you have one part it’s useless, if you have any two parts it’s complete - if one piece is destroyed it doesn’t matter (demo below) | A<br/> | B<br/> | C<br/> | |-----|-----|-----| | 1. apple<br/> | 2. zipper<br/> | 3. dog<br/> | | 4. tree<br/> | 5. car<br/> | 6. bus<br/> | | 7. banana<br/> | 8. motorbike<br/> | 9. dune<br/> | | 10. frank<br/> | 11. foundation<br/> | 12. meditation<br/> | | 13. whiteboard<br/> | 14. laptop<br/> | 15. books<br/> | | 16. perfume<br/> | 17. computer<br/> | 18. stone<br/> | | 19. brick<br/> | 20. spreadsheet<br/> | 21. bird<br/> | | 22. blog<br/> | 23. leaves<br/> | 24. grass<br/> | This is a seed phrase split up into three parts (a,b,c) - now you can create your 3 parts (1) | A<br/> | B<br/> | | |-----|-----|-----| | 1. apple<br/> | 2. zipper<br/> | | | 4. tree<br/> | 5. car<br/> | | | 7. banana<br/> | 8. motorbike<br/> | | | 10. frank<br/> | 11. foundation<br/> | | | 13. whiteboard<br/> | 14. laptop<br/> | | | 16. perfume<br/> | 17. computer<br/> | | | 19. brick<br/> | 20. spreadsheet<br/> | | | 22. blog<br/> | 23. leaves<br/> | | (2) | | B<br/> | C<br/> | |-----|-----|-----| | | 2. zipper<br/> | 3. dog<br/> | | | 5. car<br/> | 6. bus<br/> | | | 8. motorbike<br/> | 9. dune<br/> | | | 11. foundation<br/> | 12. meditation<br/> | | | 14. laptop<br/> | 15. books<br/> | | | 17. computer<br/> | 18. stone<br/> | | | 20. spreadsheet<br/> | 21. bird<br/> | | | 23. leaves<br/> | 24. grass<br/> | (3) | A<br/> | | C<br/> | |-----|-----|-----| | 1. apple<br/> | | 3. dog<br/> | | 4. tree<br/> | | 6. bus<br/> | | 7. banana<br/> | | 9. dune<br/> | | 10. frank<br/> | | 12. meditation<br/> | | 13. whiteboard<br/> | | 15. books<br/> | | 16. perfume<br/> | | 18. stone<br/> | | 19. brick<br/> | | 21. bird<br/> | | 22. blog<br/> | | 24. grass<br/> | Now you have your parts, you need at least 2/3 for it to be useful. ## distribution Distribution is pretty simple, keep one part, give a part to whomever you want to be able to claim your bitcoin upon death, give a part to someone you trust (along with instructions to post it to the claimant upon your death). ## failure For this to fail either 1. Two out of three parts would have to be destroyed 2. The trusted party would have to not post it AND either your part or the claimants would have to be destroyed 3. The trusted party cannot figure out how to use a seed phrase (by default you should include instructions i.e NEVER SHARE THE SEED, transfer to a recommended wallet from bitcoin.org then transfer to an exchange and sell)

La fabbrica magica

> innèsto s. m. [der. di innestare]. – 1. In agraria: a. Operazione con cui si fa concrescere sopra una pianta (detta portainnesto o soggetto) una parte di un altro della stessa specie o di specie differenti (detto nesto o oggetto), **al fine di formare un nuovo individuo più pregiato o più produttivo o più giovane**: fare, operare, praticare un innesto. Le collaborazioni sono di una potenza micidiale. Quelle che si sviluppano nello spazio #Bitcoin ancora di più. Non è più una collaborazione, è un #innesto: rami di alberi diversi, destinati da soli a dare grandi frutti, si fondono per **donare ad un intero ecosistema sapori ancora più deliziosi**. Contributi e suggerimenti vanno e vengono alla velocità della luce, col sorriso, senza sacrificio e sempre con la volontà di migliorarsi e crescere. Lo spazio #Bitcoin è una fabbrica magica, che accoglie minuscoli semini(*) da chiunque voglia partecipare, volontariamente, alla crescita della cultura Bitcoin. Ma li trasforma in un **incanto**. In solitaria i semini sarebbero destinati comunque a grandi cose e questo è già, di per sé, meraviglioso. La fabbrica magica, invece, li fa germogliare, fiorire e fruttare in maniera ancora più potente. Quando la magia è totale, avviene l’*innesto*, **la generazione di una nuova creatura più pregiata**. Sta succedendo davanti ai miei occhi. Sono onorata di poter assistere a questo mini miracolo della vita e, manco a dirlo, felice di farne parte. Non è solo cambiare atteggiamento, smussare frizioni e rigidità o correggere la propria visione, è proprio ampliare sé stessi accogliendo gli altri. Grazie nostr:npub1uhj92lnwh8rrhhuvulfqstk4g0ayx0zx35wj2d62jueqheknkxks5m4zj6 nostr:npub1au23c73cpaq2whtazjf6cdrmvam6nkd4lg928nwmgl78374kn29sq9t53j nostr:npub1awnu9vg352863e7tqlc6urlw7jgdf8vf00tmr76uuhflp4nnn68sjmnnl3 e nostr:npub1lrurmgmlfl4u72258fc4q5ke7tr82kw5xct5vchdmzr9uhmx6j4qn3t72a (1) Semini, non #seed [non chiamatelo seed, si dice mnemonica (cit.)] Siccome in italiano la parola **seme** porta alla mente anche *giochini di parole fiat*, se siete qui per perculare fate pure. -> H.F.S.P. 🤣

Seed Phrase สร้างยังไง ?

**Disclaimer** : บทความนี้เกิดขึ้นจากการที่ผมสงสัยว่า seed phrase ที่เราจด ๆ กันไว้เนี่ย มันสร้างมาได้ยังไง ผมจึงเข้าไปอ่าน [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) ที่ว่าด้วยเรื่องการสร้าง seed phrase (mnemonic code) สำหรับนำมาสร้าง seed และได้เขียนสรุปความเข้าใจของผมเพื่อเรียบเรียงความรู้ในหัวเก็บไว้ เผื่อว่าจะเป็นประโยชน์กับคนที่เกิดความสงสัยเหมือนกันกับผม ถ้าผมเข้าใจผิดตรงไหนสามารถบอกกันได้เลยนะครับ ## ทำไมต้องมี BIP-39 ? BIP-39 เกิดขึ้นเพราะว่ามนุษย์นั้นสามารถจดหรือจำคำได้ง่ายกว่าจดหรือจำข้อมูลในรูปเลขฐานสอง (binary) หรือเลขฐานสิบหก (hexadecimal) จึงมีคนเสนอให้สร้าง mnemonic code หรือที่เราเรียกกันว่า seed phrase ขึ้นมา ซึ่งจะประกอบไปด้วย 2 ส่วนคือ การสร้าง seed phrase และการแปลง seed phrase ให้การเป็น seed ที่สามารถนำไปใช้ในการสร้าง private key และ public key ต่อได้ ## Seed Phrase สร้างยังไง ? seed phrase นั้นต้องสร้างขึ้นจากข้อมูลทางคอมพิวเตอร์ที่เค้าเรียกว่า **entropy** ที่มี**จำนวน bits หารด้วย 32 ลงตัว**และมี**จำนวน bits อยู่ระหว่าง 128 - 256 bits** ยิ่ง entropy มีจำนวน bits มากก็จะทำให้มีความปลอดภัยมากขึ้นแต่ก็จะมีจำนวนคำมากขึ้นเช่นกัน ซึ่งการสร้าง seed phrase นั้นมีขั้นตอนดังนี้ #### Step - 1 สุ่ม entropy ที่มีจำนวน bits อยู่ระหว่าง 128 - 256 bits และจำนวน bits ต้องหารด้วย 32 ลงตัว ซึ่งหลังจากนี้จะแทนจำนวน bits นี้ด้วยคำว่า ENT ตัวอย่าง entropy ที่มี ENT เท่ากับ 128 bits `00110010010101010111100101001011001101100100101001000100001100010111001101110100001110010011011101000101011010100101000101010011` #### Step - 2 คำนวณหา checksum bits ที่มีจำนวน bits เท่ากับค่า ENT หารด้วย 32 โดยการ hash entropy ด้วย SHA256 algorithm และนำผลลัพธ์มาตัดเอาแค่ส่วนหัวตามจำนวน bits ที่ต้องการ ผมนำ entropy จาก step ก่อนหน้ามาทำ `sha256_hashing(entropy)` ได้ผลลัพธ์ออกมาเป็น `01100111.........` และจะได้ (128 / 32) = 4 bits แรกคือ `0110` ซึ่งหลังจากนี้จะแทนความยาวของ checksum bits ด้วยคำว่า CS #### Step - 3 นำ checksum bits ที่ได้มาต่อท้าย entropy จะได้เป็นกลุ่มของ bits ที่มีความยาวเท่ากับ ENT + CS ผมนำ 4 bits แรกจาก step ก่อนหน้ามาต่อท้าย entropy ที่มี 128 bits ดังนี้ `"00110010010101010111100101001011001101100100101001000100001100010111001101110100001110010011011101000101011010100101000101010011" + "0110"` #### Step - 4 นำกลุ่มของ bits มาแบ่งเป็นกลุ่มย่อย กลุ่มละ 11 bits จะทำให้ได้กลุ่มทั้งหมดจำนวน (ENT + CS) / 11 กลุ่ม ซึ่งถ้า entropy มีจำนวน 128 bits ก็จะแบ่งกลุ่มได้ (128 + 4) / 11 = 12 กลุ่ม ผมแบ่งกลุ่มได้ตามนี้ `00110010010 10101011110 01010010110 01101100100 10100100010 00011000101` `11001101110 10000111001 00110111010 00101011010 10010100010 10100110110` #### Step - 5 นำกลุ่มย่อยแต่ละกลุ่มมาแปลงเป็นเลขฐานสิบซึ่งจะมีค่าตั้งแต่ 0 - 2047 และสามารถนำไปเทียบกับ wordlist ที่กำหนดไว้ใน BIP-39 ตาม index จะได้ผลลัพธ์เป็น seed phrase ที่สามารถนำไปสร้าง seed ต่อไปได้ ผม map เลขฐานสิบกับ wordlist ได้เป็น seed phrase ตามนี้ `00110010010 => 402 = crane` `10101011110 => 1374 = profit` `01010010110 => 662 = fan` `01101100100 => 868 = hold` `10100100010 => 1314 = picture` `00011000101 => 197 = board` `11001101110 => 1646 = soccer` `10000111001 => 1081 = mango` `00110111010 => 442 = dance` `00101011010 => 346 = clip` `10010100010 => 1186 = nephew` `10100110110 => 1334 = plug` ## Wordlist wordlist ที่ BIP-39 กำหนดขึ้นมานั้นมีลักษณะดังนี้ - เลือกกลุ่มคำที่สามารถพิมพ์แค่ 4 ตัวอักษรก็สามารถระบุได้ว่าเป็นคำไหน - เลี่ยงคำที่มีหน้าตาคล้าย ๆ กัน เช่นใน wordlist จะมีคำว่า build แต่ไม่มีคำว่า built เพราะอาจจะทำให้สับสนได้ - เรียงลำดับคำตามตัวอักษรเพื่อจะได้หาได้ง่าย - ตัวอักษรในคำสามารถประกอบด้วยภาษาอะไรก็ได้แต่ว่าต้องอยู่ในรูปของ UTF-8 encoding แต่ผมว่าเป็นภาษาอังกฤษน่าจะจำง่ายที่สุด ## จำนวน bits ของ entropy และจำนวน word ที่ได้ entropy **128 bits** จะมี **4 bits** checksum ได้เป็น seed phrase **12 word** entropy **160 bits** จะมี **5 bits** checksum ได้เป็น seed phrase **15 word** entropy **192 bits** จะมี **6 bits** checksum ได้เป็น seed phrase **18 word** entropy **224 bits** จะมี **7 bits** checksum ได้เป็น seed phrase **21 word** entropy **256 bits** จะมี **8 bits** checksum ได้เป็น seed phrase **24 word**

จาก Seed Phrase สู่ Binary Seed

## การสร้าง Seed จาก Seed Phrase ในการสร้าง Binary Seed นั้นจะใช้ function ชื่อว่า [PBKDF2](https://cryptobook.nakov.com/mac-and-key-derivation/pbkdf2) ซึ่งหน้าตาจะเป็นแบบนี้ ` pbkdf2(password, salt, iterations-count, hash-function, derived-key-len) ` แต่ละ parameters จะแทนค่าตามนี้ - `password` คือ mnemonic sentence หรือ seed phrase (encoded in UTF-8) ยกตัวอย่างเช่น `craneprofitfanholdpictureboardsoccermangodanceclipnephewplug` - `salt` คือ คำว่า "mnemonic" + passphrase (encoded in UTF-8) หรือ ถ้าไม่มี passphrase ก็จะเป็นแค่คำว่า "mnemonic" คำเดียว ยกตัวอย่างเช่น กรณีมี passphrase ก็คือ `mnemonichelloworld` หรือ กรณีไม่มี passphrase ก็คือ `mnemonic` - `iterations-count` คือ 2048 - `hash-function` คือ HMAC-SHA512 - `derived-key-len` คือ 512 bits หรือ 64 bytes ค่า binary ที่ได้ออกมาจาก function จะมีความยาวตาม `derived-key-len` ก็คือ 512 bits ซึ่งสามารถนำค่านี้ไปสร้าง deterministic wallets ตาม [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) ได้