Wallets are essential tools that enable users to manage their blockchain accounts, securely store their assets, and sign transactions to make changes to the blockchain state.
In this post, we’ll cover what a wallet is, how wallets are made, and how they use elliptic curve cryptography to generate and secure private-public key pairs, derive seed phrases, and facilitate secure blockchain interactions.
A wallet is an application that lets you view and interact with your blockchain account(s); these accounts enable you to submit transactions to perform actions such as sending tokens or interacting with smart contracts.
Each account on the blockchain is made up of a cryptographic key pair; a set of 2-keys that are linked to each other. In the context of blockchains, this kind of account is typically called an Externally Owned Account (EOA), and consists of a public key and a private key:
This key pair has a powerful feature, called a trapdoor function; meaning it’s:
Wallets are used to sign messages or transactions using the wallet’s private key to be sent to a blockchain.
Wallets provide a way to know what messages or transactions a wallet has agreed to; since the public key of the transaction sender can be recovered from the transaction signature. This is essential to prevent fake/malicious transactions from being accepted on the blockchain.
For example, Jarrod could submit a transaction claiming that Abril sent him 5 ETH even if she never agreed to this transaction. However, since the blockchain verifies the signature of each transaction, it will quickly reject the transaction as the recovered address from the signature does not match the “sender” of the transaction (i.e. Abril).
Blockchains like Ethereum use ECDSA (Elliptic Curve Digital Signature Algorithm) to check if the public key recovered from the transaction signature matches the public key of the person who sent the transaction to the network.
To create a wallet, you need to create a public-private key pair. However, the values of this key pair need to follow a few rules for it to work on a blockchain.
This 3-step process is the core flow of how accounts are generated on the blockchain.
Next, we’ll dive into how a public key is derived using an elliptic curve and a private key. But before that, we’ll answer a few other questions you might have about wallets, such as:
While it is possible to generate a random 64-hex value like we just demonstrated, usually, private keys are generated using specific standards that originated from Bitcoin. These standards enable users to remember a seed phrase, which is a 12-24-word phrase that can be used to create any number of new accounts associated with it.
This allows users to remember a single set of words to access all of their accounts; each with an individual public-private key pair. Any number of new private keys can be derived from a single seed phrase using a specific key derivation function (KDF).
So, let’s first cover how seed phrases are generated via random entropy and how private keys can be derived from a seed phrase, before finally revisiting how public keys are derived from private keys.
When you first install a wallet application, typically, it will ask you to write down and safely store a seed phrase somewhere; usually a 12 or 24-word combination. You can see an example list of possible English words here, which you’ll notice is 2048 words in length (we’ll revisit that number shortly).
This idea of storing mnemonic seed phrases was introduced in 2013 with a BIP (Bitcoin Improvement Proposal); BIP-39. This proposal provides a standardized way of generating random entropy and translating it into a series of easy-to-remember words.
First, we need to make sure our seed phrase is randomly generated, after all, we don’t want someone else accidentally getting into our wallet and access to our funds.
To do this, a random number is generated using CSPRNG (Cryptographically secure pseudorandom number generator), which you can do in your browser:
This random number is called entropy. This entropy is used to create the set of words that form a seed phrase. In our case, 128 bits maps to 12 words, but it is also possible to use other lengths, such as:
So, how do we use these bits to create a seed phrase? What’s the relationship between bits and words? First, a checksum for the entropy is created and appended to the 128 bits; this is a 4-bit hash of the entropy created to ensure its integrity.
So, now we have 128 bits of entropy + 4 bits of the checksum, to make a total of 132 bits. Next, the 132 bits are converted into binary; specifically, they are split up into chunks of 11 bits.
We now have a set of 12 binary numbers, each of which is 11 bits in length. Hint: we have 12 numbers, and our seed phrase is going to be 12 words!
Recall that we have 2048 words in our list and that 2048 was chosen because 2048 is 2^11, since there are 2048 different possible binary numbers you can make with 11 bits.
Now we just need to convert these binary numbers into words from our word list. This is performed by using the binary number as an index to look up a word in the word list. i.e. If the binary number is 10, we use the 9th word in the list (since we start at index 0), for example:
Repeat this 12 times, one for each 11-bit number to form a seed phrase containing 12 words.
By generating a random entropy value, splitting it up into chunks of binary, and using those binary values as an index to look up words in a word list, we end up at a random seed phrase.
Your immediate reaction to this might be: “If it’s only 2048 possible words, can’t someone guess my seed phrase?” Well, technically yes, but it’s really… really, unlikely. How unlikely you ask?
Imagine we forget about the random 128-bit generation step, and just manually select 12 words from the list. Each time we select a word, we’re selecting one option in a pool of 2048 words.
So, we can say that for someone else to also guess this same sequence of words, they need to correctly guess the same word as us with a 1/2048 chance, 12 times in a row. Right now, you’re probably thinking, “ok that doesn’t sound that hard…”, right?” But, let’s play this out:
This is 2048 x 2048 x 2048 … 12 times. Or, 2048^12. Which is… an absurdly large number. Roughly, 5 septillion, or 5 quadrillion billions. That’s unfathomable for us to comprehend, but let’s try…
Imagine you started guessing right now, using an insanely powerful computer that can guess 1 trillion seed phrases per second. It would take this machine 159 trillion years to guess one seed phrase. Or, (depending on what you believe), roughly 11,000 times longer than the current age of the universe.
Are 24-word seed phrases better than 12?
Some wallets opt for 128 bits (12 words), but more modern wallets ask you to remember 24 words for your seed phrase! Which is again, ridiculously big.
Now we have a 12-word seed phrase, how does it get used to create private keys for accounts? To do this, we need to convert our seed phrase into a binary seed that can be used to generate wallets. This process involves the following steps:
This process (called the key derivation function), outputs a 64-byte hash value, called the binary seed, using another algorithm called HMAC-SHA512 as the pseudo-random function.
The outputted 64-byte hash value can be used to generate accounts using logic that originated from other Bitcoin standards; namely BIP-32 and optionally, an extension of BIP-32, BIP-44.
BIP-32 introduces hierarchical deterministic (HD) wallets; where many wallets can be derived from a single seed, and more wallets can be derived from those wallets, creating a “tree” of wallets.
BIP-44 provides a standardized way to create a hierarchy for wallet structures from a single binary seed by implementing a specific derivation path following the structure: m / purpose’ / coin_type’ / account’ / change / address_index:
Not all wallets use BIP-44, but it is a common way to standardize how accounts are derived from a binary seed.
As we mentioned earlier, private keys are 64 hex characters, which is 32 bytes. And, we just generated a 64-byte binary seed through the PBKDF2 process - so how do we use this 64-byte hash value to create private keys?
First, the hash is split into two halves, each 32 bytes in size:
Now we understand what private keys look like, how they’re randomly generated, and how multiple keys can be derived from a single seed phrase. Next, let’s explore how public keys are derived from private keys.
Using elliptic curve cryptography (ECC), we can figure out the public key for a given private key. There are different kinds of elliptic curves, but the one used by both Bitcoin and Ethereum is called secp256k1.
The specification for this elliptic curve includes a base point, G, that is used as the starting point for us to create other points on the curve. From this starting point, we “move around” the curve a certain number of times (determined by our private key), in a specific way. The point on the curve at which we end up when we stop this process will be our public key.
The way we “move around” the curve is called scalar multiplication. When working with elliptic curves, a scalar refers to a number used to scale a point on the curve. We take base point G and apply the scalar number to it to reach a new point on the curve by “stretching out” that point.
The scalar number we apply to the base point is our private key; put simply, we take our starting point G, and scalarly multiply it by our private key to reach our public key.
In reality, since the curve is defined over the prime field ℤp, it looks more like a bunch of scattered dots… but still has the same properties of the elliptic curve.
At the end of this scalar multiplication process (bouncing around <private key> number of times), we’ll end up at a new point on the curve, which is our public key. You can imagine this process looks something like this:
Public keys, as the name suggests, can be shared publicly with anyone. They’re useful for:
Wallets are an essential component of blockchains that use elliptic curve cryptography to allow users to submit transactions and sign messages from their accounts.
However, some blockchains like Abstract also support new kinds of wallets, called smart contract accounts, that provide more features and enable stronger security, recovery mechanisms, and more.
This article is reprinted from [https://abs.xyz/blog], Forward the Original Title‘What is a Wallet?’, All copyrights belong to the original author [ Jarrod Watts ]. If there are objections to this reprint, please contact the Gate Learn team, and they will handle it promptly.
Liability Disclaimer: The views and opinions expressed in this article are solely those of the author and do not constitute any investment advice.
Translations of the article into other languages are done by the Gate Learn team. Unless mentioned, copying, distributing, or plagiarizing the translated articles is prohibited.
Wallets are essential tools that enable users to manage their blockchain accounts, securely store their assets, and sign transactions to make changes to the blockchain state.
In this post, we’ll cover what a wallet is, how wallets are made, and how they use elliptic curve cryptography to generate and secure private-public key pairs, derive seed phrases, and facilitate secure blockchain interactions.
A wallet is an application that lets you view and interact with your blockchain account(s); these accounts enable you to submit transactions to perform actions such as sending tokens or interacting with smart contracts.
Each account on the blockchain is made up of a cryptographic key pair; a set of 2-keys that are linked to each other. In the context of blockchains, this kind of account is typically called an Externally Owned Account (EOA), and consists of a public key and a private key:
This key pair has a powerful feature, called a trapdoor function; meaning it’s:
Wallets are used to sign messages or transactions using the wallet’s private key to be sent to a blockchain.
Wallets provide a way to know what messages or transactions a wallet has agreed to; since the public key of the transaction sender can be recovered from the transaction signature. This is essential to prevent fake/malicious transactions from being accepted on the blockchain.
For example, Jarrod could submit a transaction claiming that Abril sent him 5 ETH even if she never agreed to this transaction. However, since the blockchain verifies the signature of each transaction, it will quickly reject the transaction as the recovered address from the signature does not match the “sender” of the transaction (i.e. Abril).
Blockchains like Ethereum use ECDSA (Elliptic Curve Digital Signature Algorithm) to check if the public key recovered from the transaction signature matches the public key of the person who sent the transaction to the network.
To create a wallet, you need to create a public-private key pair. However, the values of this key pair need to follow a few rules for it to work on a blockchain.
This 3-step process is the core flow of how accounts are generated on the blockchain.
Next, we’ll dive into how a public key is derived using an elliptic curve and a private key. But before that, we’ll answer a few other questions you might have about wallets, such as:
While it is possible to generate a random 64-hex value like we just demonstrated, usually, private keys are generated using specific standards that originated from Bitcoin. These standards enable users to remember a seed phrase, which is a 12-24-word phrase that can be used to create any number of new accounts associated with it.
This allows users to remember a single set of words to access all of their accounts; each with an individual public-private key pair. Any number of new private keys can be derived from a single seed phrase using a specific key derivation function (KDF).
So, let’s first cover how seed phrases are generated via random entropy and how private keys can be derived from a seed phrase, before finally revisiting how public keys are derived from private keys.
When you first install a wallet application, typically, it will ask you to write down and safely store a seed phrase somewhere; usually a 12 or 24-word combination. You can see an example list of possible English words here, which you’ll notice is 2048 words in length (we’ll revisit that number shortly).
This idea of storing mnemonic seed phrases was introduced in 2013 with a BIP (Bitcoin Improvement Proposal); BIP-39. This proposal provides a standardized way of generating random entropy and translating it into a series of easy-to-remember words.
First, we need to make sure our seed phrase is randomly generated, after all, we don’t want someone else accidentally getting into our wallet and access to our funds.
To do this, a random number is generated using CSPRNG (Cryptographically secure pseudorandom number generator), which you can do in your browser:
This random number is called entropy. This entropy is used to create the set of words that form a seed phrase. In our case, 128 bits maps to 12 words, but it is also possible to use other lengths, such as:
So, how do we use these bits to create a seed phrase? What’s the relationship between bits and words? First, a checksum for the entropy is created and appended to the 128 bits; this is a 4-bit hash of the entropy created to ensure its integrity.
So, now we have 128 bits of entropy + 4 bits of the checksum, to make a total of 132 bits. Next, the 132 bits are converted into binary; specifically, they are split up into chunks of 11 bits.
We now have a set of 12 binary numbers, each of which is 11 bits in length. Hint: we have 12 numbers, and our seed phrase is going to be 12 words!
Recall that we have 2048 words in our list and that 2048 was chosen because 2048 is 2^11, since there are 2048 different possible binary numbers you can make with 11 bits.
Now we just need to convert these binary numbers into words from our word list. This is performed by using the binary number as an index to look up a word in the word list. i.e. If the binary number is 10, we use the 9th word in the list (since we start at index 0), for example:
Repeat this 12 times, one for each 11-bit number to form a seed phrase containing 12 words.
By generating a random entropy value, splitting it up into chunks of binary, and using those binary values as an index to look up words in a word list, we end up at a random seed phrase.
Your immediate reaction to this might be: “If it’s only 2048 possible words, can’t someone guess my seed phrase?” Well, technically yes, but it’s really… really, unlikely. How unlikely you ask?
Imagine we forget about the random 128-bit generation step, and just manually select 12 words from the list. Each time we select a word, we’re selecting one option in a pool of 2048 words.
So, we can say that for someone else to also guess this same sequence of words, they need to correctly guess the same word as us with a 1/2048 chance, 12 times in a row. Right now, you’re probably thinking, “ok that doesn’t sound that hard…”, right?” But, let’s play this out:
This is 2048 x 2048 x 2048 … 12 times. Or, 2048^12. Which is… an absurdly large number. Roughly, 5 septillion, or 5 quadrillion billions. That’s unfathomable for us to comprehend, but let’s try…
Imagine you started guessing right now, using an insanely powerful computer that can guess 1 trillion seed phrases per second. It would take this machine 159 trillion years to guess one seed phrase. Or, (depending on what you believe), roughly 11,000 times longer than the current age of the universe.
Are 24-word seed phrases better than 12?
Some wallets opt for 128 bits (12 words), but more modern wallets ask you to remember 24 words for your seed phrase! Which is again, ridiculously big.
Now we have a 12-word seed phrase, how does it get used to create private keys for accounts? To do this, we need to convert our seed phrase into a binary seed that can be used to generate wallets. This process involves the following steps:
This process (called the key derivation function), outputs a 64-byte hash value, called the binary seed, using another algorithm called HMAC-SHA512 as the pseudo-random function.
The outputted 64-byte hash value can be used to generate accounts using logic that originated from other Bitcoin standards; namely BIP-32 and optionally, an extension of BIP-32, BIP-44.
BIP-32 introduces hierarchical deterministic (HD) wallets; where many wallets can be derived from a single seed, and more wallets can be derived from those wallets, creating a “tree” of wallets.
BIP-44 provides a standardized way to create a hierarchy for wallet structures from a single binary seed by implementing a specific derivation path following the structure: m / purpose’ / coin_type’ / account’ / change / address_index:
Not all wallets use BIP-44, but it is a common way to standardize how accounts are derived from a binary seed.
As we mentioned earlier, private keys are 64 hex characters, which is 32 bytes. And, we just generated a 64-byte binary seed through the PBKDF2 process - so how do we use this 64-byte hash value to create private keys?
First, the hash is split into two halves, each 32 bytes in size:
Now we understand what private keys look like, how they’re randomly generated, and how multiple keys can be derived from a single seed phrase. Next, let’s explore how public keys are derived from private keys.
Using elliptic curve cryptography (ECC), we can figure out the public key for a given private key. There are different kinds of elliptic curves, but the one used by both Bitcoin and Ethereum is called secp256k1.
The specification for this elliptic curve includes a base point, G, that is used as the starting point for us to create other points on the curve. From this starting point, we “move around” the curve a certain number of times (determined by our private key), in a specific way. The point on the curve at which we end up when we stop this process will be our public key.
The way we “move around” the curve is called scalar multiplication. When working with elliptic curves, a scalar refers to a number used to scale a point on the curve. We take base point G and apply the scalar number to it to reach a new point on the curve by “stretching out” that point.
The scalar number we apply to the base point is our private key; put simply, we take our starting point G, and scalarly multiply it by our private key to reach our public key.
In reality, since the curve is defined over the prime field ℤp, it looks more like a bunch of scattered dots… but still has the same properties of the elliptic curve.
At the end of this scalar multiplication process (bouncing around <private key> number of times), we’ll end up at a new point on the curve, which is our public key. You can imagine this process looks something like this:
Public keys, as the name suggests, can be shared publicly with anyone. They’re useful for:
Wallets are an essential component of blockchains that use elliptic curve cryptography to allow users to submit transactions and sign messages from their accounts.
However, some blockchains like Abstract also support new kinds of wallets, called smart contract accounts, that provide more features and enable stronger security, recovery mechanisms, and more.
This article is reprinted from [https://abs.xyz/blog], Forward the Original Title‘What is a Wallet?’, All copyrights belong to the original author [ Jarrod Watts ]. If there are objections to this reprint, please contact the Gate Learn team, and they will handle it promptly.
Liability Disclaimer: The views and opinions expressed in this article are solely those of the author and do not constitute any investment advice.
Translations of the article into other languages are done by the Gate Learn team. Unless mentioned, copying, distributing, or plagiarizing the translated articles is prohibited.