A one-way function is a function
Some examples used in practice are multiplication/factoring and hash functions.
Bitcoin uses Proof-of-Work (PoW) as its consensus mechanism. This is effectively a repeating lottery. Nodes compete to win the right to publish a block of transactions that will be executed. We'll come back to what this block is, but for now, we'll show that we can build consensus on this list of blocks.
Each block needs to have a nonce
The pointer to the previous block is the hash of the previous block. This way, it ensures that no one can hoard nonces.
Let's say there are two parties, Alice and Bob. Alice wants to send Bob a message
How do we achieve this? There are symmetric key encryption schemes where both Alice and Bob have the same secret key (e.g. Caesar cipher), but they would have to meet up in person first.
However, it would be ideal if we could not require them to meet in person.
Public-private key encryption solves this by requiring the receiving party to generate a keypair. One part is to be published publically (public key), and one part is meant to always stay secret.
At a high level, the public key is used for encryption, and the secret key is used for decryption. Additionally, one can use their keys to sign messages.
A public-private key encryption scheme is defined by a pair of functions
where
Further, Alice can additionally sign messages. These act as an endorsement of sorts, anyone can verify that Alice signed the message.
Specifically, sign and verify are two functions that as defined as follows
So we know how we can build consensus on a list of blocks, but how do we know for sure that the transactions are valid? That is, if a transaction is Alice sending Bob 1 BTC, how do we know that it is indeed Alice sending it?
Accounts on Bitcoin are effectively keypairs generated for a public-private key scheme. When Alice wants to send Bob some amount of Bitcoin, she signs a message stating who she's sending it to and the amount.
Ethereum follows the same overall structure, but instead of a ledger, the state is now the memory of a virtual machine. This means that Ethereum is essentially a shared computer. Think of it as a PC at the public library. Transactions can now either be transfers of ETH or executions of programs.