Crypto-Atlas
Crypto Fundamentals
Hash Functions
A hash function converts arbitrary input data into a fixed-size digest.
1 | "hello" |
Important properties:
- The same input always produces the same hash.
- A tiny input change produces a very different hash.
- Recovering the original input from the hash should be computationally infeasible.
- Finding two different inputs with the same hash should be extremely difficult.
Blockchains use hashes for transaction IDs, block linking, Merkle trees, and data integrity.
Public / Private Keys
Public/private key pairs come from asymmetric cryptography.
1 | Private Key |
In blockchain systems, keys are mainly used for digital signatures rather than encrypting transaction data.
1 | Private Key → sign |
The private key must remain secret. Whoever controls it can authorize transactions from the corresponding account.
Digital Signatures
A digital signature proves that a transaction or message was authorized by the holder of a private key without exposing that key.
1 | Transaction |
Other participants can cryptographically verify the signature.
1 | Transaction |
Digital signatures provide authorization and authenticity, not secrecy: transaction data itself is generally public.
Addresses
An address is a public on-chain identifier derived from cryptographic key material.
Conceptually:
1 | Private Key |
An address is not the same as a public key.
It is mainly used as an identifier:
1 | address → account |
For example:
1 | from: 0xAlice... |
The address itself normally does not perform cryptographic authorization; keys and signatures do.
An address also does not necessarily represent one unique human. One person can control many addresses, and an address may represent a smart contract rather than a user.
Wallets
A wallet manages cryptographic keys and signs blockchain operations.
It does not literally store cryptocurrency.
1 | Blockchain |
The wallet is therefore mainly an interface for controlling blockchain accounts.
Seed Phrases
A seed phrase is a human-readable backup from which a wallet can derive many private keys and addresses.
1 | Seed Phrase |
One seed phrase may control many accounts.
Anyone who obtains the seed phrase can usually recreate the wallet and control those accounts.
Merkle Trees
A Merkle tree combines many pieces of data into a single root hash.
For four transactions:
1 | Merkle Root |
Where:
1 | H1 = hash(Tx1) |
The Merkle root acts as a compact cryptographic commitment to the entire dataset.
A major benefit is that a node can prove that one item belongs to a large dataset without sending the entire dataset.
1 | Tx2 |
If the calculated root matches the expected root, the transaction’s inclusion can be verified.
Transactions
A transaction is a cryptographically signed instruction submitted to a blockchain.
It may represent actions such as:
- transferring assets;
- calling application logic;
- changing blockchain state.
Typical flow:
1 | create transaction |
A valid signature proves authorization, but transaction validity may also depend on protocol rules and current blockchain state.
Blockchain Basics
Blocks
A block contains a batch of transactions plus protocol metadata.
Conceptually:
1 | Block |
Blocks form an ordered blockchain history:
1 | Block 100 |
Each block is cryptographically connected to earlier blockchain data, making historical modification detectable.
Nodes
A node is a computer running blockchain software and participating in the peer-to-peer network.
Nodes may:
- receive transactions;
- validate transactions;
- receive and validate blocks;
- maintain blockchain state;
- communicate with other nodes;
- expose blockchain data through APIs.
1 | Application |
A node does not blindly trust a newly received block.
It can independently verify:
1 | receive block |
This independent verification is one of the key properties of blockchain systems.
Mempool
A mempool is a node’s temporary collection of valid pending transactions that have not yet been included in a block.
1 | transaction submitted |
There is not necessarily one global mempool.
Because transactions propagate through a peer-to-peer network, different nodes can temporarily have slightly different pending transaction sets.
This is why an application may show:
1 | Pending... |
after a user has already submitted a transaction.
Block Producers
A block producer is the participant responsible for proposing the next block.
It typically:
1 | reads pending transactions |
The mechanism used to determine who becomes the block producer depends on the consensus system.
1 | Proof of Work → miner |
After a block is proposed, other nodes still independently validate it.
Consensus
Consensus is how independent participants converge on one canonical blockchain history without a central authority.
It needs to answer questions such as:
1 | Is this block valid? |
Consensus does not mean that nodes simply vote on whether each transaction looks acceptable.
First, each node can independently apply deterministic protocol rules:
1 | same previous state |
Consensus becomes especially important when multiple valid candidate blocks or chains temporarily exist.
1 | Block A |
The consensus protocol defines how the network eventually converges on one canonical history.
Proof of Work
Proof of Work (PoW) uses computational work to determine who can produce a valid block.
In Bitcoin, miners repeatedly try different values until the block hash satisfies the network’s difficulty requirement.
1 | candidate block |
This creates an important asymmetry:
1 | finding valid Proof of Work → expensive |
The successful miner can propose the block, but other nodes independently verify both the Proof of Work and the block contents before accepting it.
PoW therefore helps:
- select block producers;
- make block production costly;
- make rewriting blockchain history economically expensive.
1 | Block Producer = role |
Proof of Stake
Proof of Stake (PoS) uses economic stake rather than computational mining to secure the network.
Participants lock assets to become validators.
1 | stake assets |
Validators have economic value at risk.
1 | honest participation |
The important distinction is:
1 | PoW → security through computational cost |
Stake does not allow validators to arbitrarily decide whether transactions are valid. Transactions and blocks still need to follow deterministic protocol rules.
PoS Consensus
A simplified PoS flow looks like:
1 | validator selected to propose block |
Consensus therefore combines several ideas:
1 | validity rules |
Finality
A transaction being included in a block does not always mean it is immediately irreversible.
Typical lifecycle:
1 | submitted |
Finality means the protocol considers that part of blockchain history effectively irreversible under its security assumptions.
Applications may use different confirmation thresholds depending on risk.
1 | small UI update |
Transaction Fees
Blockchain computation and block space are limited resources, so transactions generally pay fees.
Fees serve several purposes:
- compensate network participants;
- prioritize access to limited block space;
- discourage spam and resource abuse.
The exact fee mechanism depends on the blockchain.
Ethereum-specific gas mechanics are covered separately in the Ethereum section.
On-Chain vs Off-Chain
On-chain operations are recorded, executed, or verified by the blockchain.
Examples:
1 | asset ownership |
On-chain operations inherit blockchain guarantees but tend to be slower and more expensive than traditional server/database operations.
Off-chain systems operate outside the blockchain.
Examples:
1 | backend APIs |
Most production Web3 applications combine both:
1 | Blockchain |
End-to-End Blockchain Flow
At a high level:
1 | User |
The major responsibilities are:
1 | Private Key / Signature |
Ethereum Basics
EOA vs Contract Accounts
Ethereum has two main account types:
- EOA (Externally Owned Account): controlled by a private key.
- Contract Account: controlled by smart contract code.
1 | EOA |
A contract account does not independently initiate transactions like an EOA. Its code runs when triggered by an external transaction or another contract.
EVM
The EVM (Ethereum Virtual Machine) is the execution environment that runs smart contract bytecode.
1 | Solidity source |
Ethereum nodes execute the same contract code with the same input and previous state, allowing them to independently verify the resulting state.
1 | same state |
This deterministic execution is a key part of Ethereum’s trust model.
Nonce
For an Ethereum EOA, the nonce is essentially the account’s transaction sequence number.
1 | nonce 0 |
It helps:
- preserve transaction ordering;
- prevent replaying the same signed transaction;
- identify the next valid transaction from an account.
1 | Alice current nonce = 5 |
Bitcoin does not use this account-level nonce model.
Bitcoin instead uses the UTXO model.
UTXO
UTXO stands for Unspent Transaction Output.
Bitcoin tracks spendable outputs rather than maintaining a simple account balance.
1 | Alice owns: |
To send 4 BTC:
1 | Inputs: |
The original UTXOs become spent, while the new outputs become new UTXOs.
1 | Ethereum |
Because a spent UTXO cannot be spent again, Bitcoin does not need Ethereum’s account nonce mechanism for replay prevention.
Gas
Gas measures the computational resources consumed by Ethereum operations.
Different EVM operations consume different amounts of gas.
1 | simple ETH transfer |
A simplified fee model is:
1 | transaction fee |
Gas serves two important purposes:
- users pay for limited blockchain computation and block space;
- contracts cannot execute unlimited computation for free.
Gas is not limited to smart contracts. Even a normal ETH transfer consumes gas.
Bitcoin also has transaction fees, but it does not use Ethereum-style gas accounting.
1 | Bitcoin fee |
Bitcoin primarily charges for block space, while Ethereum also explicitly meters computation.
Transactions ( Ethereum )
An Ethereum transaction is a signed instruction sent from an EOA.
It may:
- transfer ETH;
- call a smart contract;
- deploy a smart contract.
Conceptually:
1 | Transaction |
The sender is cryptographically derived/verified from the transaction signature rather than simply trusted from a user-provided from field.
For a contract call, the data field contains encoded information describing which function to execute and what arguments to pass.
1 | EOA |
Smart Contracts
A smart contract is deterministic code stored and executed on the blockchain.
It can be thought of as shared application logic whose execution can be independently verified by network participants.
1 | transaction |
The trust does not come from trusting one application server.
Instead, it comes from:
1 | shared contract code |
For example, an escrow contract could enforce:
1 | Buyer deposits ETH |
Every validating node applies the same rules.
Smart contracts can:
- store persistent state;
- transfer assets;
- enforce application rules;
- call other contracts;
- emit events.
Events / Logs
Smart contracts can emit events during execution.
1 | event Transfer( |
These become transaction logs:
1 | Smart Contract |
Events are commonly used for:
- token transfers;
- order creation;
- ownership changes;
- application indexing;
- notifications.
Events are especially useful because applications can observe what happened without repeatedly scanning all contract storage.
Storage / Memory / Calldata
Solidity uses different data locations depending on how long the data should live and how it is used.
Example:
1 | contract UserRegistry { |
Storage
storage is persistent blockchain state.
1 | string public ownerName; |
If:
1 | ownerName = "Alice"; |
then the value survives after the transaction finishes.
1 | Block N |
A useful analogy:
1 | storage ≈ database |
Changing storage is relatively expensive because the resulting state must be persisted by the blockchain.
Memory
memory contains temporary data used during one EVM execution.
1 | string memory temp = newName; |
1 | function starts |
A useful analogy:
1 | memory ≈ local variables / temporary RAM |
Calldata
calldata contains read-only input passed into an external contract call.
1 | function updateName( |
If a frontend calls:
1 | contract.updateName("Bob") |
the function selector and "Bob" are encoded into transaction/call data.
1 | Frontend |
A useful analogy:
1 | calldata ≈ request body / function arguments |
So the practical mental model is:
1 | Storage |
Ethereum Transaction Execution Flow
Putting everything together:
1 | EOA |
A useful summary:
1 | EOA |