2

I am currently having a hard time finding actual reliable concrete sources for an answer to the question what information exactly is stored on the ledger and what is not.

Specifically, Ethereum knows Externally Owned Accounts (EOAs) and Contract Accounts. Now: When I create a new account, what is stored where and when?

As far as I understand, I create my account as a "wallet" locally (e.g. using geth account new). Within this wallet, all information needed (i.e. my keypair etc) is stored locally.

Still, if I am to send Ether from my account to another, I will need to sign the respective transaction using my private key. Accordingly, any miner will need to verify said transaction's signature using my public key (as stated in the yellow paper in Section 6), which hence needs to be published somehow.

The Ethereum yellow paper states that an account's state is "not stored on the blockchain" but is stored in the "state database", which is (as far as I understand) computed by every node from the history of transactions. Still, I cant find any mention of where an account's associated keypair is stored. Can't be only in my local wallet...

Hence the question(s): - How is a wallets public key published in the Ethereum network? - How do I retrieve the public key for an account? - What data for an account is actually written to the ledger and when?

Can anyone point me to the solution of this?

2

How is a wallets public key published in the Ethereum network?

It isn't. For an EOA, the address is computed as the last 20 bytes of the keccak256 hash of the public key. The public key itself is not stored anywhere on the blockchain. The private key is stored in your keystore (or ledger, or trezor, or whatever device).

How do I retrieve the public key for an account?

If you have the private key, you can compute the public key, naturally. If you wish to compute the public key for some random address, you can only do so if that address has made an outgoing transaction.

ECDSA signatures contain enough information to allow what is known as "public key recovery". When a transaction is signed, nodes will look at the signature and compute the public key. That public key can then be used to get the "from" address, since the address is derived from the public key.

What data for an account is actually written to the ledger and when?

As you mentioned, ethereum uses a state database system. In a very simplistic form, this can be thought of as a key-value system, where the address is the key, and the value is an addresses balance (in reality, the value includes things such as nonce, balance, code).

When you create a new account locally, nothing is transmitted or saved onto the blockchain. When your account receives its first ether transfer, the state databases is updated. A new key is added using the recipient address (your address) and the balance is incremented by the amount received.

At this point, your address exists in the state db, but the public key is still not computable without your private key.

When you spend that ether, you sign a transaction with your private key. This signature is embedded in the transaction data, and is used to generate your public key during the tx validation process. The public key then leads back to your address, and the state database is updated to deduct the sent amount from your balance, and add it to the balance of the recipient.

  • Thank you very much for this clarification! This was great help! – Xenonite Aug 10 '18 at 14:03
1

Accordingly, any miner will need to verify said transaction's signature using my public key (as stated in the yellow paper in Section 6), which hence needs to be published somehow.

The trick is that the public key (and thus the address) can be recovered from the signature. So you sign a transaction with your private key, and all nodes use that signature to find what address it corresponds to. Then they make the appropriate state changes for that address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.