MasteringEthereum Wallet - modolee/blockchain GitHub Wiki
์ง๊ฐ(Wallet)
- ์ด๋๋ฆฌ์์์ "์ง๊ฐ"์ด๋ผ๋ ๋จ์ด๋ ์กฐ๊ธ์ฉ ๋ค๋ฅด๊ฒ ์ฌ์ฉ๋๋ค.
- ์์ ๊ณ์ธต์์ ๋ดค์ ๋ ์ด๋๋ฆฌ์์ ๋ํ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธํฐํ์ด์ค ์ญํ ์ ํ๋ ์์ฉ ์ํํธ์จ์ด์ด๋ค.
- ์ง๊ฐ์ ์ฌ์ฉ์ ์์ฐ์ ์ ์ด๊ถ์ ํต์ , ํค์ ์ฃผ์ ๊ด๋ฆฌ, ์์ฐ ์ถ์ ๊ทธ๋ฆฌ๊ณ ํธ๋์ญ์ ์ ์์ฑ๊ณผ ์๋ช ์ ํ๋ค.
- ๋ช ๋ช ์ด๋๋ฆฌ์ ์ง๊ฐ์ ์ปจํธ๋ํธ(์ : ERC20 ํ ํฐ)์ ์ํธ์์ฉ์ ํ ์ ์๋ค.
- ๋ ์ข๊ฒ ํ๋ก๊ทธ๋๋จธ์ ๊ด์ ์์ ๋ดค์ ๋ ์ง๊ฐ์ ์ฌ์ฉ์์ ํค๋ฅผ ์ ์ฅํ๊ณ ๊ด๋ฆฌํ๋๋ฐ ์ฌ์ฉ๋๋ ์์คํ ์ ์๋ฏธํ๋ค.
- ๋ชจ๋ ์ง๊ฐ์ ํค ๊ด๋ฆฌ ์ปดํฌ๋ํธ๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, ๋ช ๋ช ์ง๊ฐ๋ค์ ๊ทธ๊ฒ ์ ๋ถ์ธ ๊ฒฝ์ฐ๋ ์๋ค.
- ์ด๋๋ฆฌ์ ๊ธฐ๋ฐ์ DApp๊ณผ์ ์ธํฐํ์ด์ค๋ก ์ฌ์ฉ๋๋ ๋ธ๋ผ์ฐ์ ์ ์ผ๋ถ๋ก ์ง๊ฐ์ด ์ฌ์ฉ๋๊ธฐ๋ ํ๋ค.
- ์ง๊ฐ์ด๋ผ๋ ๋จ์ด์ ๋ํ ๋ช ํํ ์ ์๋ ์๋ค.
- ์ฌ๊ธฐ์์๋ ๊ฐ์ธ ํค ๋ค์ ๋ณด๊ดํจ ๊ทธ๋ฆฌ๊ณ ์ด ํค ๋ค์ ๊ด๋ฆฌํ๋ ์์คํ ์ด๋ผ๊ณ ์ ์ํ๊ณ ์งํํ๊ฒ ๋ค.
์ง๊ฐ ๊ธฐ์ ์ค๋ฒ๋ทฐ
์ง๊ฐ ์ค๊ณ ์ ๊ณ ๋ ค์ฌํญ
- ์ง๊ฐ ์ค๊ณ ์ ๊ณ ๋ คํด์ผ ๋ ์ค์ํ ์ ์ค ํ๋๋ ํธ์์ฑ๊ณผ ํ๋ผ์ด๋ฒ์์ ๊ท ํ์ด๋ค.
- ๊ฐ์ฅ ํธ๋ฆฌํ ์ด๋๋ฆฌ์ ์ง๊ฐ์ ํ๋์ ๊ฐ์ธ ํค์ ์ฃผ์๋ฅผ ๊ฐ์ง๊ณ ๋งค๋ฒ ์ฌ์ฌ์ฉํ๋ ๊ฒ์ด๋ค. ํ์ง๋ง ์ด๊ฒ์ ๋๊ตฌ๋ ์ฝ๊ฒ ๋น์ ์ ๋ชจ๋ ํธ๋์ญ์ ์ ์ถ์ ํ๊ณ ์ฐ๊ด ์ง์ ์ ์๊ธฐ ๋๋ฌธ์ ํ๋ผ์ด๋ฒ์์ ๋งค์ฐ ์ทจ์ฝํ๋ค
- ๋งค ํธ๋์ญ์ ๋ง๋ค ์๋ก์ด ํค๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ํ๋ผ์ด๋ฒ์์ ๊ฐ์ฅ ์ข๊ธด ํ์ง๋ง, ๊ด๋ฆฌ๊ฐ ๋งค์ฐ ์ด๋ ค์์ง๋ค.
- ์ฌ๋ฐ๋ฅธ ํ๊ท ์ ์ด๋ฃจ๊ฒ ํ๋ ๊ฒ์ ๋งค์ฐ ์ด๋ ต์ง๋ง, ์ข์ ์ง๊ฐ ์ค๊ณ๋ฅผ ์ํด์ ์ค์ํ๋ค.
์ง๊ฐ์ ๋ํ ์คํด
- ์ด๋๋ฆฌ์์ ๋ํ ์คํด ์ค ํ๋๋ ์ด๋๋ฆฌ์ ์ง๊ฐ์ด ์ด๋๋ ํ ํฐ์ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ์ด๋ค.
- ๋งค์ฐ ์๊ฒฉํ ๋งํ์๋ฉด ์ง๊ฐ์ ๋จ์ง ํค๋ง ๊ฐ์ง๊ณ ์๊ณ , ์ด๋๋ ๋ค๋ฅธ ํ ํฐ๋ค์ ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋ก๋์ด ์๋ค.
- ์ฌ์ฉ์๋ ์์ ์ ์ง๊ฐ์ ์๋ ํค๋ฅผ ์ด์ฉํด์ ์๋ช ํ ํธ๋์ญ์ ์ ํตํด์ ์ด๋๋ฆฌ์ ๋คํธ์ํฌ์ ์๋ ํ ํฐ์ ์ ์ดํ๋ค.
- ์ด๋ค ์๋ฏธ์์ ์ง๊ฐ์ ์ด์ ๊ณ ๋ฆฌ์ด๋ค. ํ์ง๋ง ์ง๊ฐ์ ๋ณด๊ด ๋ ํค๊ฐ ์ด๋๋ ํ ํฐ์ ๋ค๋ฅธ ์ฌ๋๋ค์๊ฒ ์ ๋ฌํ๋๋ฐ ์ฌ์ฉ๋๊ธฐ ๋๋ฌธ์ ๊ตฌ๋ถ์ ๋ฌด์๋ฏธํ๋ค.
- ์ค์ํ ๊ฒ์ ๊ธฐ์กด ๋ฑ
ํน์ ์ค์ ์ง์ค ๋ฐฉ์์์ ๋ธ๋ก์ฒด์ธ ํ๋ซํผ์ ํ์ค์ํ ๋ ์์คํ
์ผ๋ก ์ฌ๊ณ ๋ฐฉ์์ผ๋ก ๋ฐ๊พธ๋ ๊ฒ์ด๋ค.
- ๊ธฐ์กด ๋ฑ ํน ์์คํ : ์์ ๊ณผ ์ํ๋ง ์์ ์ ๊ณ์ข ์๊ณ ๋ฅผ ํ์ธํ ์ ์๊ณ , ์๊ธ ์ด์ฒด๋ฅผ ์ํ ๊ฒฝ์ฐ ์ํ๋ง ํ์ (๋ฉ๋)์ํค๋ฉด ๋๋ค.
- ๋ธ๋ก์ฒด์ธ ํ๋ซํผ : ๊ณ์ ์ ์ฃผ์ธ์ ์ ์๋ ์์ง๋ง, ๋๊ตฌ๋ ๊ณ์ ์ ์ด๋ ์์ก์ ํ์ธํ ์ ์๋ค. ๊ทธ๋ฆฌ๊ณ ์์ ์๊ฐ ์๊ธ ์ด์ฒด๋ฅผ ์ํ ๊ฒฝ์ฐ ๋ชจ๋์๊ฒ ํ์ (๋ฉ๋)์์ผ์ผ ํ๋ค.
- ์ค์ ๋ก ๋ธ๋ก์ฒด์ธ ํ๋ซํผ์์๋ ์ง๊ฐ ์์ด ๊ณ์ข ์๊ณ ํ์ธ์ด ๊ฐ๋ฅํ๋ค. ๊ทธ๋ฆฌ๊ณ ์ฌ์ฉํ๊ณ ์๋ ์ง๊ฐ์ด ๋ง์์ ๋ค์ง ์์ ๊ฒฝ์ฐ ๋ค๋ฅธ ์ง๊ฐ์ผ๋ก ์ฎ๊ฒจ๊ฐ ์ ์๋ค.
์ง๊ฐ์ ์ข ๋ฅ
- ์ง๊ฐ์ 2๊ฐ์ง ๊ธฐ์กด ์ข ๋ฅ๊ฐ ์๋๋ฐ, ํค ๊ฐ์ ์ฐ๊ด์ฑ์ด ์๋๋ ์๋๋์ ๋ฐ๋ผ์ ๋๋๋ค.
- ์ฒซ๋ฒ์งธ ์ข ๋ฅ๋ ๋น๊ฒฐ์ ์ ์ง๊ฐ์ผ๋ก, ๊ฐ๊ฐ์ ํค๊ฐ ๋ ๋ฆฝ์ ์ผ๋ก ์๋ก ๋ค๋ฅธ ๋์์์ ์์ฑ๋๋ค. ์ด๋ฐ ์ง๊ฐ์ JBOK(Just a Bunch of Keys) ์ง๊ฐ์ด๋ผ๊ณ ๋ ํ๋ค.
- ๋๋ฒ์งธ ์ข ๋ฅ๋ ๊ฒฐ์ ์ ์ง๊ฐ์ผ๋ก, ๋ชจ๋ ํค๊ฐ ์๋๋ผ๊ณ ์๋ ค์ง ํ๋์ ๋ง์คํฐ ํค์์ ์ ๋๋์ด ๋์จ๋ค. ๋ชจ๋ ํค๊ฐ ์๋ก ์ฐ๊ด๋์ด ์์ผ๋ฉฐ ์๋ณธ ์๋๊ฐ ์๋ ๊ฒฝ์ฐ ๋ณต๊ตฌ๊ฐ ๊ฐ๋ฅํ๋ค. ํค ์ ๋ ๋ฐฉ๋ฒ์ ์ฌ๋ฌ๊ฐ์ง๊ฐ ์๋๋ฐ, ๊ฐ์ฅ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ Hierarchical Deterministic Wallets(BIP-32/BIP-44)์ ์ค๋ช ๋์ด ์๋ ํธ๋ฆฌ์ ๋น์ทํ ๋ฐฉ๋ฒ์ด๋ค.
๊ฒฐ์ ์ ์ง๊ฐ์ ๋ณต๊ตฌ
- ๋ฐ์ดํฐ ์์ค ์ฌ๊ณ (์ : ์ ํ๋ฅผ ๋๋ ๋นํ๊ฑฐ๋ ํ์ฅ์ค์ ๋จ์ด๋จ๋ฆผ)์ ๋๋นํด์ ๊ฒฐ์ ์ ์ง๊ฐ์ ๋ณด๋ค ์์ ํ๊ฒ ์ ์งํ๋ ค๋ฉด, ๋จ์ด ๋ชฉ๋ก(์์ด ๋๋ ๋ค๋ฅธ ์ธ์ด)์ผ๋ก ๋ ์๋(๋๋ชจ๋ ์ฝ๋)๋ฅผ ์ ์ด๋๊ณ ์ฌ๊ณ ๊ฐ ๋ฐ์ํ์ ๋ ์ฌ์ฉํ๋ผ.
- ๋ณต๊ตฌ ๋จ์ด ๋ชฉ๋ก์ ๋งค์ฐ ์ ๊ฒฝ์จ์ ๋ค๋ค์ผ ํ๋ค. ์ปดํจํฐ๋ ์ค๋งํธํฐ์ ํ์ผ ํํ๋ก ์ ์ฅํ์ง ๋ง๊ณ , ์ข ์ด์ ์ ์ด์ ์์ ํ ๊ณณ์ ๋ณด๊ดํ๋ผ.
๋น ๊ฒฐ์ ์ [Nondeterministic(Random)] ์ง๊ฐ
- ์ฒซ๋ฒ์งธ ์ด๋๋ฆฌ์ ์ง๊ฐ(์ด๋๋ฆฌ์ ํ๋ฆฌ์ธ์ผ์ ์ํด ๋ง๋ค์ด์ง)์๋, ๋๋คํ๊ฒ ์์ฑ ๋ ํ๋์ ๊ฐ์ธ ํค๊ฐ ์ ์ฅ ๋ ๊ฐ๊ฐ์ ์ง๊ฐ ํ์ผ์ด ์ ์ฅ๋์๋ค.
- ์ด๋ฌํ "๊ตฌ์" ์ง๊ฐ์ ์ฌ๋ฌ๋ฉด์์ ๋ค๋จ์ด์ง๊ธฐ ๋๋ฌธ์ ๊ฒฐ์ ์ ์ง๊ฐ์ผ๋ก ๋์ฒด๋๊ณ ์๋ค.
- ์๋ฅผ ๋ค์ด ํ๋ผ์ด๋ฒ์๋ฅผ ๊ทน๋ํํ๊ธฐ ์ํด ์๊ธ์ ๋ฐ์ ๋ ๋ง๋ค ์๋ก์ด ์ฃผ์๋ฅผ ์ฌ์ฉํ๋ค๊ณ ํ์. ๋ง์ ์๊ธ์ ๋ค๋ฃจ๊ฒ ๋๋ฉด ํค๊ฐ ์ ์ ๋์ด๋๊ณ ์ฃผ๊ธฐ์ ์ผ๋ก ๋ฐฑ์ ์ ํด์ผ ํ๋ค. ๋ง์ฝ์ ๋ฐ์ดํฐ ๋ฐฑ์ ์ ์ ์์ค๋๋ค๋ฉด ์๊ธ๊ณผ ์ค๋งํธ ์ปจํธ๋ํธ์ ๋ํ ์ ์ด๊ถ์ ์๊ฒ ๋๋ค.
- ๋ง์ ์ด๋๋ฆฌ์ ํด๋ผ์ด์ธํธ๋ ํค ์คํ ์ด ํ์ผ(์ถ๊ฐ ๋ณด์์ ์ํด์ ๋น๋ฐ๋ฒํธ๋ก ์ํธํ ๋ ํ๋์ ๊ฐ์ธ ํค๊ฐ ํฌํจ ๋ JSON์ผ๋ก ์ธ์ฝ๋ฉ ๋ ํ์ผ)์ ์ด์ฉํ๋ค.
- JSON ํ์ผ ๋ด์ฉ
{
"address": "001d3f1ef827552ae1114027bd3ecf1f086ba0f9",
"crypto": {
"cipher": "aes-128-ctr",
"ciphertext":
"233a9f4d236ed0c13394b504b6da5df02587c8bf1ad8946f6f2b58f055507ece",
"cipherparams": {
"iv": "d10c6ec5bae81b6cb9144de81037fa15"
},
"kdf": "scrypt",
"kdfparams": {
"dklen": 32,
"n": 262144,
"p": 1,
"r": 8,
"salt":
"99d37a47c7c9429c66976f643f386a61b78b97f3246adca89abe4245d2788407"
},
"mac": "594c8df1c8ee0ded8255a50caf07e8c12061fd859f4b7c76ab704b17c957e842"
},
"id": "4fcb2ba4-ccdb-424f-89d5-26cce304bf9c",
"version": 3
}
- ํค ์คํ ์ด ํ์์ brute-force, dictionary, rainbow table ๊ณต๊ฒฉ์ผ๋ก ๋ถํฐ ๋ฐฉ์ดํ๊ธฐ ์ํด key derivation function(KDF) ์ ์ฌ์ฉํ๋ค.
- ์ฝ๊ฒ ๋งํด์ ๊ฐ์ธ ํค๋ฅผ ๋น๋ฐ๋ฒํธ(passphrase)๋ก ์ง์ ์ํธํํ์ง ์๋ ๋์ ๋น๋ฐ๋ฒํธ๋ฅผ ๋ฐ๋ณต์ ์ผ๋ก ํด์ฑํ์ฌ stretched ๋น๋ฐ๋ฒํธ๋ฅผ ์ฌ์ฉํ๋ค.
- ํด์ฑ์ 262,144๋ฒ ๋ฐ๋ณตํ๋ค. JSON ํ์ผ์
crypto.kdfparams.n
ํ๋ผ๋ฏธํฐ์์ ํ์ธํ ์ ์๋ค. - brute-force๋ก ๋น๋ฐ๋ฒํธ๋ฅผ ์์๋ด๋ ค๋ ๊ณต๊ฒฉ์๋ ๋งค ๋ฒ 262,144๋ฒ์ ํด์ฑ์ ํด์ผํ๋๋ฐ, ์ถฉ๋ถํ ๋ณต์กํ๊ณ ๊ธด ๋น๋ฐ๋ฒํธ์ ๋ํด์ ๊ณต๊ฒฉ์ด ๋ถ๊ฐ๋ฅ ํ๋๋ก ๊ณต๊ฒฉ ์๋๋ฅผ ๋ฆ์ถ๋ค.
๋น๊ฒฐ์ ์ ์ง๊ฐ์ ๋จ์ํ ํ ์คํธ ์ด ์ธ์๋ ์ฌ์ฉํ๋ ๊ฒ์ ๊ถ์ฅํ์ง ์๋๋ค. ๋ฐฑ์ ์ด ๋๋ฌด ์ฑ๊ฐ์๊ณ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์ํฉ์ ์ฌ์ฉ๋๋ค. ๋์ ์ฐ์ ํ์ค๊ธฐ๋ฐ์ ๋ฐฑ์ ์ฉ์ผ๋ก ๋๋ชจ๋ ์๋๊ฐ ์๋ HD ์ง๊ฐ์ ์ฌ์ฉํ์ฌ๋ผ.
๊ฒฐ์ ์ [Deterministic(Seeded)] ์ง๊ฐ
- ๊ฒฐ์ ์ (Deterministic or "seeded") ์ง๊ฐ์ ํ๋์ ๋ง์คํฐ ํค(๋๋ ์๋)์์ ์ ๋(ํ์)๋ ๋ชจ๋ ๊ฐ์ธ ํค๋ฅผ ํฌํจํ๊ณ ์๋ค.
- ์๋๋ ๋๋คํ๊ฒ ์์ฑ ๋ ์ซ์๋ก ์ธ๋ฑ์ค ๋ฒํธ ๋๋ "์ฒด์ธ ์ฝ๋"์ ๊ฐ์ ๋ค๋ฅธ ๋ฐ์ดํฐ์ ์กฐํฉ๋์ด ๊ฐ์ธ ํค๋ฅผ ์ ๋ํ๋ค.
- ๊ฒฐ์ ์ ์ง๊ฐ ์์ฑ ์์ ํ๋์ ๋ฐฑ์ ์ผ๋ก๋ ์ถฉ๋ถํ ๋ชจ๋ ์ ๋ ๋ ํค๋ฅผ ๋ณต๊ตฌํ ์ ์์ด์, ์ง๊ฐ์ ๋ชจ๋ ์๊ธ๊ณผ ์ค๋งํธ ์ปจํธ๋ํธ๋ฅผ ๋ณดํธํ๋๋ฐ ์ถฉ๋ถํ๋ค.
- ์๋๋ก ์ง๊ฐ ์ํฌํธ, ์ต์คํฌํธ๋ฅผ ํ ์ ์์ด์ ์ฝ๊ฒ ๋ค๋ฅธ ์ง๊ฐ ๊ฐ์ ํค ์ด๋์ด ํ์ฉ๋๋ค.
- ์ด๋ฌํ ์ค๊ณ๋ ์ ์ฒด ์ง๊ฐ์ ์ ๊ทผ์ ์๋ ํ๋๋ง ํ์ํ๋ฏ๋ก, ์๋ ๋ณด์์ ๊ฐ์ฅ ์ค์ํ๊ฒ ๋ง๋ญ๋๋ค. ๋ฐ๋๋ก ๋จ์ผ ๋ฐ์ดํฐ์๋ง ๋ณด์ ๋ ธ๋ ฅ์ ์ง์ค์ํฌ ์ ์์ด ์ด์ ์ผ๋ก ๋ณผ ์ ์๋ค.
๊ณ์ธต ๊ฒฐ์ ์ [HD(Hierarchical Deterministic)] ์ง๊ฐ (BIP-32/BIP-44)
- ๊ฒฐ์ ์ ์ง๊ฐ์ ๋จ์ผ ์๋์์ ๋ง์ ํค๋ฅผ ์ฝ๊ฒ ์ ๋ํ๊ธฐ ์ํด ๋ง๋ค์ด์ก๋ค.
- ํ์ฌ ๊ฐ์ฅ ์ง๋ณดํ ํํ์ ๊ฒฐ์ ์ ์ง๊ฐ์ ๊ณ์ธต ๊ฒฐ์ ์ (HD) ์ง๊ฐ์ด๋ค. (๋นํธ์ฝ์ธ์ BIP-32 ํ์ค์ ์ ์)
- HD ์ง๊ฐ์ ํธ๋ฆฌ ๊ตฌ์กฐ(๋ถ๋ชจ ํค๊ฐ ์ฐ์ ๋ ์์ ํค๋ฅผ ์ ๋ํ ์ ์๊ณ , ๊ฐ๊ฐ์ ์์ ํค๋ ์์ ํค๋ฅผ ์ ๋ํ ์ ์์)์ ์ ๋ ๋ ํค๋ฅผ ํฌํจํ๊ณ ์๋ค.
- HD ์ง๊ฐ์ ๋จ์ํ ๊ฒฐ์ ์ ์ง๊ฐ๋ณด๋ค ๋ช ๊ฐ์ง ์ฅ์ ์ด ์๋ค.
- ์ฒซ์งธ, ํธ๋ฆฌ ๊ตฌ์กฐ๋ ์ถ๊ฐ์ ์ธ ์กฐ์ง์ ์๋ฏธ๋ฅผ ๋ํ๋ด๋๋ฐ ์ฌ์ฉํ ์ ์๋ค. ํน์ ์๋ธ ํค์ ๋ธ๋์น๋ ์ ๊ธ์ ์ํด ์ฌ์ฉํ๊ณ , ๋ค๋ฅธ ๋ธ๋์น๋ ์ถ๊ธ์ ์๋ ๋ฐ๊ธฐ ์ํด ์ฌ์ฉํ ์ ์๋ค. ํค ๋ธ๋์น๋ ๊ธฐ์ ์ค์ ์๋ ์ฌ์ฉํ ์ ์๋ค. ๋ถ์, ์ํ์ฌ, ํน์ ๊ธฐ๋ฅ ๋๋ ํ๊ณ ์นดํ ๊ณ ๋ฆฌ๋ฅผ ๋ค๋ฅธ ๋ธ๋์น๋ก ํ ๋นํ ์ ์๋ค.
- ๋์งธ, ์ฌ์ฉ์๊ฐ ๊ฐ์ธ ํค์ ์ ๊ทผํ์ง ์๊ณ ๋, ์ฐ์ ๋ ๊ณต๊ฐ ํค๋ฅผ ์์ฑํ ์ ์๋ค๋ ๊ฒ์ด๋ค. ์๊ธ์ ์ฌ์ฉํ ์ ์๋ ๊ฐ์ธ ํค๋ฅผ ์ง๊ฐ์ด ๊ฐ์ง๊ณ ์์ง ์๊ธฐ ๋๋ฌธ์, HD ์ง๊ฐ์ ์์ ํ์ง ์์ ์๋ฒ๋ ๊ฐ์ ์ ์ฉ ๋๋ ์์ ์ ์ฉ์ผ๋ก ์ฌ์ฉํ ์ ์๋ค.
์๋์ ๋๋ชจ๋ ์ฝ๋ (BIP-39)
- ๊ฐ์ธ ํค์ ์์ ํ ๋ฐฑ์ ๊ณผ ๋ณต๊ตฌ๋ฅผ ์ํ ์ธ์ฝ๋ฉ ๋ฐฉ๋ฒ์ ์ฌ๋ฌ๊ฐ์ง๊ฐ ์๋ค. ํ์ฌ ๊ฐ์ฅ ์ ํธํ๋ ๋ฐฉ๋ฒ์ ์ฐ์ ๋ ๋จ์ด๋ฅผ ์ด์ฉํ๋ ๊ฒ์ผ๋ก, ์ฌ๋ฐ๋ฅธ ์์๋ก ๋จ์ด๋ฅผ ์ ๋ ฅํ๋ฉด ๊ฐ์ธ ํค๋ฅผ ๋ค์ ๋ง๋ค ์ ์๋ค.
- ์ด๊ฒ์ ๋๋ชจ๋์ด๋ผ๊ณ ๋ถ๋ฅด๋ฉฐ, BIP-39์์ ํ์คํ ๋์๋ค.
- ์์ฆ ๋ง์ ์ด๋๋ฆฌ์ ์ง๊ฐ(๋ค๋ฅธ ์ํธํํ ์ง๊ฐ๋ ๋ง์ฐฌ๊ฐ์ง๋ก)์์ ์ด ํ์ค์ ์ฌ์ฉํ๋ค. ํธํ ๊ฐ๋ฅํ ๋๋ชจ๋์ ์ฌ์ฉํ์ฌ ๋ฐฑ์ ๊ณผ ๋ณต๊ตฌ๋ฅผ ์ํด ์ํฌํธ, ์ต์คํฌํธ ๊ฐ๋ฅํ๋ค.
- ์ ์ด ๋ฐฉ๋ฒ์ด ๋๋ฆฌ ์ฌ์ฉ๋์ง ์๋์ง๋ฅผ ์์ ๋ฅผ ํตํด ์์๋ณด์.
๊ฒฐ์ ์ ์ง๊ฐ์ ์ฌ์ฉ๋๋ ์๋
- 16์ง์ ํํ FCCF1AB3329FD5DA3DA9577511F8F137
- ๋๋ชจ๋ ๋จ์ด 12๊ฐ wolf juice proud gown wool unfair wall cliff insect more detail hub
- ์ค์ ๋ก ๋์ด ๋ 16์ง์๋ฅผ ๋ฐ์ ์ธ ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ ํ๋ฅ ์ ํ์ฉํ ์ ์์ ์ ๋๋ก ๋๋ค.
- ๋ฐ๋๋ก ์๋ ค์ง ๋จ์ด๋ค์ ๋ชฉ๋ก์ ๋ค๋ฃจ๋ ๊ฒ์ ์ฝ๋ค. ์๋ํ๋ฉด ๋จ์ด(ํนํ ์๋จ์ด) ์ฐ๊ธฐ๋ ๋ง์ด ๋ฐ๋ณต ํด๋ดค๊ธฐ ๋๋ฌธ์ด๋ค. ๋ง์ฝ ์ค์๋ก "inzect"๊ฐ ๊ธฐ๋ก๋์๋ค๋ฉด, ์ง๊ฐ ๋ณต๊ตฌ๋ฅผ ์ํด์๋ "inzect"๋ ์ ํจํ์ง ์์ ๋จ์ด์ด๊ณ ๋์ "insect"๋ฅผ ์ฌ์ฉํด์ผ ๋๋ค๋ ๊ฒ์ ๋น ๋ฅด๊ฒ ํ๋จํ ์ ์๋ค.
์ง๊ฐ์ ์ข์ ์
- ์ํธํํ ์ง๊ฐ ๊ธฐ์ ์ด ์ฑ์ํด์ง๋ฉด์ ํญ ๋๊ฒ ํธํ ๊ฐ๋ฅํ๊ณ , ์ฌ์ฉํ๊ธฐ ์ฌ์ฐ๋ฉฐ, ์์ ํ๊ณ ์ ์ฐํ๊ฒ ๋ง๋๋ ์ฐ์ ํ์ค๋ค์ด ๋ฑ์ฅํ๋ค.
- ์ด๋ฐ ํ์ค๋ค์ ์ง๊ฐ์ด ํ๋์ ๋๋ชจ๋์์ ๋ค์ค์ ๋ค๋ฅธ ์ข ๋ฅ์ ์ํธํํ ํค๋ฅผ ์ ๋ํ๋ ๊ฒ์ ํ์ฉํ๋ค.
- ์ผ๋ฐ์ ์ธ ํ์ค๋ค
- Mnemonic code words, based on BIP-39
- HD wallets, based on BIP-32
- Multipurpose HD wallet structure, based on BIP-43
- Multicurrency and multiaccount wallets, based on BIP-44
- ํฅํ ์ด๋ฐ ํ์ค์ ๋ณ๊ฒฝ๋๊ฑฐ๋ ํ๊ธฐ ๋ ์ ์์ง๋ง, ํ์ฌ๋ ๋๋ถ๋ถ์ ๋ธ๋ก์ฒด์ธ ํ๋ซํผ๊ณผ ๊ทธ๋ค์ ์ํธํํ๋ฅผ ์ํ de facto ์ง๊ฐ ํ์ค์ผ๋ก์ ์ฌ์ฉ๋๋ ์ฐ๋ ๊ธฐ์ ์งํฉ์ฒด์ด๋ค.
- ์ด ํ์ค์ ๊ด๋ฒ์ํ ์ํํธ์จ์ด, ํ๋์จ์ด ์ง๊ฐ์ ์ฌ์ฉ๋์ด ์๋ก ์ฐ๋ํ ์ ์๊ฒ ๋ง๋ค์๋ค. ์ฌ์ฉ์๋ ์ด ์ง๊ฐ ์ค ํ๋์์ ๋๋ชจ๋์ ์์ฑํ๊ณ , ๋ค๋ฅธ ์ง๊ฐ์์ ์ํฌํธํ ์ ์์ผ๋ฉฐ, ๋ชจ๋ ํค์ ์ฃผ์๋ฅผ ๋ณต๊ตฌํ ์ ์๋ค.
- ์ด๋ฌํ ํ์ค์ ์ง์ํ๋ ์ง๊ฐ์ ์
- ์ํํธ์จ์ด : Jaxx, MetaMask, MyCrypto, MyEhterWallet(MEW)
- ํ๋์จ์ด : Keepkey, Ledger, Trezor
๋๋ชจ๋ ์ฝ๋ ๋จ์ด (BIP-39)
- ๋๋ชจ๋ ์ฝ๋ ๋จ์ด๋ ๊ฒฐ์ ์ ์ง๊ฐ์ ์ ๋ํ๊ธฐ ์ํ ์๋๋ก ์ฌ์ฉ๋๋ ๋์๋ฅผ ์ธ์ฝ๋ฉํ ๋จ์ด ๋์ด์ด๋ค. ์ด ๋์ด ๋ ๋จ์ด๋ค์ ์๋๋ฅผ ๋ค์ ๋ง๋ค ์ ์๊ณ , ๊ทธ๊ฒ์ผ๋ก ์ง๊ฐ๊ณผ ๋ชจ๋ ์ ๋(ํ์) ๋ ํค๋ค์ ๋ค์ ๋ง๋ค ์ ์๋ค.
- ๋๋ชจ๋ ๋จ์ด๋ฅผ ์ฌ์ฉํ๋ ๊ฒฐ์ ์ ์ง๊ฐ์ ๊ตฌํํ ์ง๊ฐ ์ดํ๋ฆฌ์ผ์ด์ ์ ์ง๊ฐ์ ์ฒ์ ๋ง๋ค ๋ 12๊ฐ์์ 24๊ฐ์ ๋์ด ๋ ๋จ์ด๋ค์ ๋ณด์ฌ์ค๋ค. ์ด ๋จ์ด๋ค์ ๋์ด์ด ์ง๊ฐ ๋ฐฑ์ ์ด๊ณ ๊ฐ๊ฑฐ๋ ํธํ๋๋ ์ง๊ฐ ์ดํ๋ฆฌ์ผ์ด์ ์์ ๋ชจ๋ ํค๋ฅผ ๋ณต๊ตฌํ๊ณ ๋ค์ ๋ง๋๋๋ฐ ์ฌ์ฉ๋๋ค.
NOTE ์ข ์ข ๋๋ชจ๋ ๋จ์ด์ "๋ธ๋ ์ธ์ง๊ฐ(brainwallet)"๋ฅผ ํท๊ฐ๋ คํ๋๋ฐ, ์ด ๋๊ฐ์ง๋ ๊ฐ์ ๊ฒ์ด ์๋๋ค. ๊ฐ์ฅ ํฐ ์ฐจ์ด์ ์ ๋ธ๋ ์ธ์ง๊ฐ์ ์ฌ์ฉ์๊ฐ ์ ํํ ๋จ์ด๋ค๋ก ๊ตฌ์ฑ๋๊ณ , ๋๋ชจ๋ ๋จ์ด๋ ์ง๊ฐ์ด ๋๋ํ๊ฒ ์์ฑํ ๋จ์ด๋ฅผ ์ฌ์ฉ์ํํ ๋ณด์ฌ์ค๋ค. ์ด ์ค์ํ ์ฐจ์ด์ ์ด ๋๋ชจ๋ ๋จ์ด๋ฅผ ๋ณด๋ค ๋ ์์ ํ๊ฒ ํ๋๋ฐ, ์๋ํ๋ฉด ์ฌ๋์ ๋งค์ฐ ์ข์ง ์์ ๋์ ์์ฑ ์์ค์ด๊ธฐ ๋๋ฌธ์ด๋ค.
- BIP-39์ ์ ์ ๋ ๋๋ชจ๋ ์ฝ๋์ ์๋ ์์ฑ์ 9๋จ๊ณ์ ๊ฑธ์ณ ์ค๋ช ํ๋ คํ๋ค. ๋ช ํํ๊ฒ ํ๊ธฐ ์ํด 1 ~ 6 ๋จ๊ณ๋ ๋๋ชจ๋ ์ฝ๋ ์์ฑ์ด๊ณ , 7 ~ 9 ๋จ๊ณ๋ ๋๋ชจ๋์์ ์๋ ์ถ์ถ์ด๋ค.
์๋ ๋ถํฐ๋ ํ๊ธ๋ก ๋ณ์ญ์ด ํ์ํจ
๋๋ชจ๋ ์ฝ๋ ์์ฑํ๊ธฐ
- Create a cryptographically random sequence S of 128 to 256 bits.
- Create a checksum of S by taking the first length-of-S รท 32 bits of the SHA-256 hash of S.
- Add the checksum to the end of the random sequence S.
- Divide the sequence-and-checksum concatenation into sections of 11 bits.
- Map each 11-bit value to a word from the predefined dictionary of 2,048 words.
- Create the mnemonic code from the sequence of words, maintaining the order.
์ํธ๋กํผ์ ๋ฐ๋ฅธ ๋๋ชจ๋ ๊ธธ์ด ํ ๋งํฌ
๋๋ชจ๋์์ ์๋ ์ถ์ถ
- The entropy is then used to derive a longer (512-bit) seed through the use of the key-stretching function PBKDF2.
- The key-stretching function takes two parameters: the mnemonic and a salt. The purpose of a salt in a key-stretching function is to make it difficult to build a lookup table enabling a brute-force attack.
- The first parameter to the PBKDF2 key-stretching function is the mnemonic produced in step 6.
- The second parameter to the PBKDF2 key-stretching function is a salt. The salt is composed of the string constant "mnemonic" concatenated with an optional user-supplied passphrase.
- PBKDF2 stretches the mnemonic and salt parameters using 2,048 rounds of hashing with the HMAC-SHA512 algorithm, producing a 512-bit value as its final output. That 512-bit value is the seed.
- show some examples of mnemonic codes and the seeds they produce.
- mnemonic_128_no_pass, mnemonic_128_w_pass, mnemonic_256_no_pass
BIP-39์ ์ ํ์ ๋น๋ฐ๋ฒํธ(passphrase)
- The BIP-39 standard allows the use of an optional passphrase in the derivation of the seed. If no passphrase is used, the mnemonic is stretched with a salt consisting of the constant string "mnemonic", producing a specific 512-bit seed from any given mnemonic. If a passphrase is used, the stretching function produces a different seed from that same mnemonic. In fact, given a single mnemonic, every possible passphrase leads to a different seed.
- The optional passphrase creates two important features:
- A second factor (something memorized) that makes a mnemonic useless on its own, protecting mnemonic backups from compromise by a thief.
- A form of plausible deniability or "duress wallet," where a chosen passphrase leads to a wallet with a small amount of funds, used to distract an attacker from the "real" wallet that contains the majority of funds.
- However, it is important to note that the use of a passphrase also introduces the risk of loss:
- If the wallet owner is incapacitated or dead and no one else knows the passphrase, the seed is useless and all the funds stored in the wallet are lost forever.
- Conversely, if the owner backs up the passphrase in the same place as the seed, it defeats the purpose of a second factor.
๋๋ชจ๋ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ ๊ณณ
- python-mnemonic : The reference implementation of the standard by the SatoshiLabs team that proposed BIP-39, in Python
- ConsenSys/eth-lightwallet : Lightweight JS Ethereum wallet for nodes and browser (with BIP-39)
- npm/bip39 : JavaScript implementation of Bitcoin BIP-39: Mnemonic code for generating deterministic keys
- Mnemonic Code Converter
์๋๋ก ๋ถํฐ HD ์ง๊ฐ ๋ง๋ค๊ธฐ
- HD wallets are created from a single root seed, which is a 128-, 256-, or 512-bit random number. Most commonly, this seed is generated from a mnemonic as detailed in the previous section.
- Every key in the HD wallet is deterministically derived from this root seed, which makes it possible to recreate the entire HD wallet from that seed in any compatible HD wallet. This makes it easy to export, back up, restore, and import HD wallets containing thousands or even millions of keys by transferring just the mnemonic from which the root seed is derived.
HD ์ง๊ฐ (BIP-32)๊ณผ ํจ์ค(Paths) (BIP-43/44)
ํ์ฅ๋(extended) ๊ณต๊ฐ ํค์ ๊ฐ์ธ ํค
- In BIP-32 terminology, keys can be "extended.โ With the right mathematical operations, these extended "parent" keys can be used to derive "child" keys, thus producing the hierarchy of keys and addresses described earlier.
- Extending a key involves taking the key itself and appending a special chain code to it. A chain code is a 256-bit binary string that is mixed with each key to produce child keys.
- If the key is a private key, it becomes an extended private key distinguished by the prefix
xprv
:xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8i...
- An extended public key is distinguished by the prefix
xpub
:xpub661MyMwAqRbcEnKbXcCqD2GT1di5zQxVqoHPAgHNe8dv5JP8gWmDproS6kFHJnLZd23tWevhdn
- A very useful characteristic of HD wallets is the ability to derive child public keys from parent public keys, without having the private keys. This gives us two ways to derive a child public key: either directly from the child private key, or from the parent public key.
- ์์ ๋ ๊ฐ์ง
- One common application of this method is to install an extended public key on a web server that serves an ecommerce application.
- Another common application of this solution is for cold-storage or hardware wallets. In that scenario, the extended private key can be stored in a hardware wallet, while the extended public key can be kept online.
Hardened child key derivation
- Extended key์ ๋จ์ : the xpub contains the chain code (used to derive child public keys from the parent public key), if a child private key is known, or somehow leaked, it can be used with the chain code to derive all the other child private keys. A single leaked child private key, together with a parent chain code, reveals all the private keys of all the children.
- HD wallets use an alternative derivation function called hardened derivation, which "breaks" the relationship between parent public key and child chain code. The hardened derivation function uses the parent private key to derive the child chain code, instead of the parent public key. This creates a "firewall" in the parent/child sequence, with a chain code that cannot be used to compromise a parent or sibling private key.
Index numbers for normal and hardened derivation
- It is clearly desirable to be able to derive more than one child key from a given parent key. To manage this, an index number is used.
- To easily distinguish between keys derived through the normal (unhardened) derivation function versus keys derived through hardened derivation, this index number is split into two ranges.
- Index numbers between 0 and 2^31โ1 (0x0 to 0x7FFFFFFF) are used only for normal derivation.
- Index numbers between 2^31 and 2^32โ1 (0x80000000 to 0xFFFFFFFF) are used only for hardened derivation.
- first normal child key :
0
- first hardened child key :
0'
- first hardened child key :
1'
- When you see an HD wallet index
i'
: 2^31 + i
HD wallet key identifier (path)
- Keys in an HD wallet are identified using a "path" naming convention, with each level of the tree separated by a slash (/) character.
- Private keys derived from the master private key start with m. Public keys derived from the master public key start with M.
- Therefore, the first child private key of the master private key is m/0. The first child public key is M/0. The second grandchild of the first child is m/0/1, and so on.
- The "ancestry" of a key is read from right to left, until you reach the master key from which it was derived. For example, identifier m/x/y/z describes the key that is the z-th child of key m/x/y, which is the y-th child of key m/x, which is the x-th child of m.
- HD Wallet path examples
Navigating the HD wallet tree structure
- The HD wallet tree structure is tremendously flexible. The flip side of this is that it also allows for unbounded complexity: each parent extended key can have 4 billion children: 2 billion normal children and 2 billion hardened children. Each of those children can have another 4 billion children, and so on. The tree can be as deep as you want, with a potentially infinite number of generations. With all that potential, it can become quite difficult to navigate these very large trees.
- Based on BIP-43, an HD wallet should use only one level-1 branch of the tree, with the index number defining the purpose of the wallet by identifying the structure and namespace of the rest of the tree. More specifically, an HD wallet using only branch m/i'/... is intended to signify a specific purpose and that purpose is identified by index number i.
- BIP-44 proposes a multicurrency multiaccount structure signified by setting the "purpose" number to 44'. All HD wallets following the BIP-44 structure are identified by the fact that they only use one branch of the tree: m/44'/*.
- BIP-44 specifies the structure as consisting of five predefined tree levels:
m / purpose' / coin_type' / account' / change / address_index
- first level : purpose' is always set to
44'
- second level : coin_type'. specifies the type of cryptocurrency coin, allowing for multicurrency HD wallets where each currency has its own subtree under the second level. SLIP0044
- third level : account'. which allows users to subdivide their wallets into separate logical subaccounts for accounting or organizational purposes. For example, an HD wallet might contain two Ethereum "accounts": m/44'/60'/0' and m/44'/60'/1'. Each account is the root of its own subtree.
- fourth level : change. an HD wallet has two subtrees: one for creating receiving addresses and one for creating change addresses. Only the "receive" path is used in Ethereum, as there is no necessity for a change address like there is in Bitcoin.
- Note that whereas the previous levels used hardened derivation, this level uses normal derivation. This is to allow the account level of the tree to export extended public keys for use in a nonsecured environment. Usable addresses are derived by the HD wallet as children of the fourth level, making the fifth level of the tree the address_index.
BIP-44 HD Wallet structure examples M/44'/60'/0'/0/2 : The third receiving public key for the primary Ethereum account M/44'/0'/3'/1/14 : The 15th change-address public key for the 4th Bitcoin account m/44'/2'/0'/0/1 : The second private key in the Litecoin main account, for signing transactions
๊ฒฐ๋ก
Wallets are the foundation of any user-facing blockchain application. They allow users to manage collections of keys and addresses. Wallets also allow users to demonstrate their ownership of ether, and authorize transactions, by applying digital signatures