β νμ€ μ€λͺ
- BIP-39λ λλͺ¨λ 문ꡬ(mnemonic phrase)μ μ νμ ν¨μ€νλ μ΄μ¦(passphrase)λ₯Ό μ¬μ©νμ¬ **512λΉνΈ μλ(seed)**λ₯Ό μμ±ν©λλ€.
- μ§κ° 볡ꡬ μ μ¬μ©νλ “λ¨μ΄ 리μ€νΈ”λ μ΄ λ¨κ³μ ν΄λΉν©λλ€.
π§© wallet-core λ΄λΆ λμ
- νμΌ:
HDWallet.cpp
cppCopyEditHDWallet::HDWallet(const std::string& mnemonic, const std::string& passphrase) {
const auto seed = mnemonicToSeed(mnemonic, passphrase);
this->seed = Data(seed.begin(), seed.end());
}
- λ΄λΆ ν¨μ
mnemonicToSeed
λTrezor-crypto
λΌμ΄λΈλ¬λ¦¬ μ¬μ©:
cppCopyEditmnemonic_to_seed(mnemonic.c_str(), passphrase.c_str(), seed, nullptr);
π§ BIP-44: κ³μΈ΅μ ν€ νμ (HD Wallet)
β νμ€ μ€λͺ
- κ²½λ‘ κ΅¬μ‘°:
m / purpose' / coin_type' / account' / change / address_index
- BIP-44λ λͺ©μ (Purpose) =
44'
λ₯Ό κ³ μ νλ©°, λ€μν μ½μΈμ μ§μνκΈ° μν coin_type νλλ₯Ό ν¬ν¨ν©λλ€.
μ: μ΄λ리μ μ£Όμ: m/44'/60'/0'/0/0
π§© wallet-core λ΄λΆ λμ
- νμΌ:
DerivationPath.cpp
λ°Coin.cpp
cppCopyEditauto path = DerivationPath("m/44'/60'/0'/0/0");
PrivateKey privKey = hdWallet.getKey(path);
auto pubKey = privKey.getPublicKey(TWPublicKeyTypeSECP256k1);
auto address = Ethereum::Address(pubKey);
getKey(path)
λ μλλ₯Ό κΈ°λ°μΌλ‘ HMAC-SHA512 νμμ ν΅ν΄ private keyλ₯Ό μ λν©λλ€.
π BIP-84: Native SegWit (λΉνΈμ½μΈ μ μ©)
β νμ€ μ€λͺ
- κ²½λ‘ κ΅¬μ‘°:
m/84'/0'/0'/0/0
- Bech32 (bc1…) μ£Όμ ν¬λ§·μ μμ±νλ©°, λΉνΈμ½μΈμ μΈκ·Έμ(segwit) κΈ°λ₯μ μ΅λν νμ©νλ λ°©μ.
π§© wallet-core λ΄λΆ λμ
- λΉνΈμ½μΈ κ³μ΄ μ½μΈμ
Coin.cpp
μ coinType λ³defaultDerivationPath
μ μκ° μμ΅λλ€:
cppCopyEdit// BIP84 - Native Segwit
if (coin == TWCoinTypeBitcoin) {
return DerivationPath("m/84'/0'/0'/0/0");
}
- μ€μ μ£Όμ μμ±μ λ€μμ²λΌ μ²λ¦¬:
cppCopyEditauto privKey = wallet.getKey(coin, derivationPath);
auto pubKey = privKey.getPublicKey(TWPublicKeyTypeSECP256k1);
auto addr = Bitcoin::Bech32Address(pubKey, HRP); // bc1q...
π ν΅μ¬ κ΄λ ¨ νμΌ μ 리
κΈ°λ₯ | κ²½λ‘ | μ€λͺ |
---|---|---|
BIP-39 μλ μμ± | HDWallet.cpp , TrezorCrypto/mnemonic.c | λλͺ¨λ β μλ |
BIP-44 κ²½λ‘ νμ± | DerivationPath.cpp | κ²½λ‘ λ¬Έμμ΄ β μ«μ λ°°μ΄ |
ν€ νμ (44, 84 곡ν΅) | HDWallet::getKey(...) | μλ β private key |
μ£Όμ μμ± | Coin.cpp , Bitcoin/Address.* , Ethereum/Address.* | pubkey β address |
μ½μΈλ³ κ²½λ‘ μ§μ | Coin.cpp | BIP-44 vs BIP-84 λ± μ μ© |
π§ μμ½ νλ¦λ
csharpCopyEdit[Mnemonic (BIP-39)]
β
[Seed: 512bit]
β
[DerivationPath (BIP-44/84)]
β
[Private Key]
β
[Public Key]
β
[Address: Coin-specific format]
λ΅κΈ λ¨κΈ°κΈ°