Bitcoin and Cryptocurrencies CS198.1x BerkeleyX edX course notes
Last Updated: August 14, 2018 by Pepe Sandoval
If you find the information in this page useful and want to show your support, you can make a donation
Use PayPal
This will help me to create more stuff and fix the existent content... or probably your money will be used to buy beer
The Bitcoin Blockchain is a data structure that stores a permanent history of all transactions to ever occur in the history of bitcoin, its and append-only ledger so things CANNOT be deleted once added
The Bitcoin network validates transactions ans stores the entire transaction history
Bitcoin solves inconsistent transaction and double spending attack problems by using the blockchain and consensus protocol (PoW)
Service | Banks | Bitcoin |
---|---|---|
Manage accounts (Identity) | Verify our identity so only we can use the funds, to do this they ask us for identification | Give user autonomously created identities |
Transfer money (Transactions) | Send and receive money for us | Transactions are peer-to-peer |
Record management (Record Keeping) | Keep track of our balance | Each node keeps it's own ledger and the transactions are validated by the entire network |
Trust (Consensus) | Put trust in the banks "professionals" and that the banks are under regulations of government | Provides trust through a protocol that incentivizes actors to be honest |
Public key != BTC Address
: The BTC address is derived from your public key but NOT identical2^160
possible addresses so the probability that 2 people get the same address is very, very, very, very, small; considered impossibleGovernance is the mechanism by which a protocol makes changes to itself, but no such mechanism was encoded into the Bitcoin protocol.
Ethereum was developed as a platform to execute peer-to-peer smart contracts and applications
Tamper-evident: means that if the information is manipulated we can easily know about this manipulation
We need to generate unique identifiers (standardized randomness) for the meaningful data and associated these two to ensure integrity of our information
x'
such that H(x) == H(x')
y
and x
such that H(x) == H(y)
The consequence of these properties is the Avalanche Effect which means a small change in input can produce significant differences in the output
Bitcoin uses SHA-256^2
(SHA-256 squared) which means SHA-256 is used twice in a row
< 2^64
bits and produces a 256 bits
fixed size outputblockID
(also called Block Header
) is the Hash of all the fields of the block header concatenated -> BlockId = H(prevBlockHash || merkleRoot || nonce ...)
Nonce: Proof of Work is done with Bitcoin's partial preimage hash puzzle.
H(BlockHeader) < target
Timestamp:
A Bitcoin Transaction Contains the following fields:
scriptSig
).In Bitcoin senders specific a locking script in the output of the transaction, recipients provide an unlocking script in the input whenever they want to redeem their bitcoin
Wallet forms: Smartphone Apps, Online Web-wallets (Hosted on websites), HW wallets, Paper-Wallets (literal pieces of papers with your private key printed on it) etc.
Simple Payment Verification (SPV) is a method for verifying if a particular transactions are including in a block without downloading the entire block, just by downloading the block headers (these header include all the transactions so a Merkle Proof of Inclusion can be used). Clients using this method are called thin clients
A miner must:
Create a block with its metadata. This means generating the Merkel Root and all the other components of a block
Find the PoW, this means finding a valid Nonce. A valid nonce in this case is a nonce which makes the hash of the block header less than some target value
Broadcast your block, other miners validated the block and broadcast the block once more
All Proof-of-Work really is at its base, a random lottery
Confirmations refer to the number of blocks mined on top of a block containing some particular transaction
The Bitcoin network is peer to peer, so the way that messages get sent around the network is through a gossip protocol (also called flooding)
Bitcoin is special because is a system that allows us to:
Bitcoin's intended purpose is solely to allow the transaction of bitcoins, its native asset. "It’s a global payment system"
Ethereum is a smart contract blockchain platform, a distributed world computer. It's native asset ether(ETH) exists to fund computation and to align incentives.
Smart contracts in Ethereum are like autonomous agents that live inside of the Ethereum network. Smart contracts react to the external world when they are poked by transactions, which call specific functions.
Ethereum's main goal is to enable distributed and trustless computation
Ethereum is redundantly parallel so contract executions are redundantly replicated across all nodes which makes it expensive
Smart contracts in Ethereum are usually written in a high level programming language.
Smart contracts are compiled to Ethereum Virtual Machine (EVM) code, this is the code that is executed by every node in Ethereum, then nodes come to consensus on the new state of the network by using PoW
Miners in Ethereum competitively create blocks by executing EVM code and searching for a solution to a mining puzzle.
Gas is what fuels the execution of a given contract, every EVM op-code requires gas in order to execute so every contract requires "gas" which "fuels" contract execution
startgas
which is the max quantity of gas is willing to consume and the gasprice
which is the fee in ETH the contract is willing to pay per unit gasEVM execution and Gas process
startgas * gasprice
(represents the amount of ether paid for a computation) is subtracted from the sender who is the one invoking the contract by sending a transaction.startgas * gasprice
is not refundedThe Internet focuses much more on information exchange, while blockchain focuses on value exchange. When thinking about a blockchain use case, ask yourself whether it leverages some value exchange, particularly that which cannot be handled by a single authority. Blockchain’s innovation was not to enable distributed information sharing, but distributed record-keeping and decentralized exchange of value.
Blockchains allow us to solve coordination failures, allow us to create a system which incentivizes individuals to operate according to our expectations.
If you find the information in this page useful and want to show your support, you can make a donation
Use PayPal
This will help me to create more stuff and fix the existent content... or probably your money will be used to buy beer