Wallets on Blockchain
Created On 09. Jul 2020
Updated: 2021-05-02 00:00:05.060144000 +0000
Created By: acidghost
In blockchain, wallets are not as they are in our traditional enviroment. All what the wallets contain are keys, not actual money.
The transactions are signed with such keys, that prove they own the transaction outputs that are registered in the blockchain.
In different types of wallets, keys are generated differently. One is nondeterministic and the other deterministic. Nondeterministic have their keys generated from random numbers, and in the deterministic all keys come from one, the seed. The nondeterministic wallets are poor practice, because keys have to be properly backed up, which is annoying.
The seed in the deterministic wallets are generated with a one-hash function. The seed can backup all keys alone, and it allows diverse of other implementations outside the wallet.
To have a good wallet, you will want to check the following points:
• 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
Some of the wallets that complete these standards and are available publicly are: Breadwallet, Copay, Multibit HD, Mycelium, Keepkey, Ledger,
and Trezor.
Mnemonic words
The mnemonic words from seed are enough to recreate the wallet and all keys. Mnemonic words are defined by the BIP-39 and are presented to the user. Users don't choose the words, because humans are poor sources of randomness, which is necessary for secure generation of keys.
The numerical variety of possible wallets with BIP-39 gets to 2^512.
You can play online with a BIP-39 generator here https://iancoleman.io/bip39/
However, for proper integration you would want to check something like bitcoinjs-bip39, libbitcoin-mnemonic or python-mnemonic.
Keys
A wallet contains collection of key pairs, which have private and public.
The private key is generated from entropy. The public key is generated from the private one with elliptic curve multiplication. From the public key a bitcoin address is generated with a one-way hash function. The entropy is created randomly from 128 to 256 inputs. The curve multiplication is generated the following way, K = k * G, where K is public key, k is private, and G is the generator point. Bitcoin uses a elliptic curve that are defined in secp256k1, which looks like y^2 = (x^3 + 7) over (Fp). At one point, on this site will be more information on elliptic curve in cryptos.
Seed
The seed is generated with a key-stretching function that uses a mnemonic and a salt. The salt is added to add more security to the result, and it is a constant 'mnemonic' concatenated with an optional passphrase chosen by user. The mnemonic and salt are hashed in 2048 rounds with the HMAC-SHA512 algorithm. The final value is 512 bit long.
Section: Blockchain
Back