Blockchain 101
Distributed System
- Distributed systems are a computing paradigm whereby two or more nodes work with each other in a coordinated fashion to achieve a common outcome. It is modeled in such a way that end users see it as a single logical platform. For example, Google’s search engine is based on a large distributed system, but to a user, it looks like a single, coherent platform.
Blockchain defined
- Layman’s definition: Blockchain is an ever-growing, secure, shared record keeping system in which each user of the data holds a copy of the records, which can only be updated if all parties involved in a transaction agree to update.
- Technical definition: Blockchain is a peer-to-peer, distributed ledger that is cryptographically-secure, append-only, immutable (extremely hard to change), and updateable only via consensus or agreement among peers.
- Peer to Peer: This means that there is no central controller in the network, and all participants talk to each other directly. This property allows for cash transactions to be exchanged directly among the peers without a third-party involvement, such as by a bank.
- Distributed ledger: ledger is spread across the network among all peers in the network, and each peer holds a copy of the complete ledger.
- Cryptographically-secure: Cryptography technology is used
- Append-only: that data can only be added to the blockchain in time-ordered sequential order.
- Updateable via consensus:
Generic elements of a blockchain
- Address: Addresses are unique identifiers used in a blockchain transaction to denote senders and recipients. An address is usually a public key or derived from a public key
- Transaction: A transaction is the fundamental unit of a blockchain. A transaction represents a transfer of value from one address to another.
- Block: A block is composed of multiple transactions and other elements, such as the previous block hash (hash pointer), timestamp, and nonce.
- Peer-to-peer network: As the name implies, a peer-to-peer network is a network topology wherein all peers can communicate with each other and send and receive messages.
- Scripting or programming language: Scripts or programs perform various operations on a transaction in order to facilitate various functions.
Benefits and limitations of blockchain
- Benefits
- Decentrailzation
- Transperancy and trust
- Immutability
- High Availability
- Highly Secure
- Simplification of current paradigms
- Faster dealing
- Cost Saving
- Limitation
- Scalability
- Adaptability
- Regulations
- Relatively immature technology
- Privacy
Types of blockchain
- Public Blockchain
- Private Blockchain
- Semiprivate Blockchain
- Sidechain
Introducing Bitcoin
- Bitcoin is the first application of blockchain technology
- The name of the Bitcoin inventor Satoshi Nakamoto is believed to be a pseudonym, as the true identity of Bitcoin inventor is unknown.
- Bitcoin is built on decades of cryptographic research such as the research in Merkle trees, hash functions, public key cryptography, and digital signatures. Moreover, ideas such as BitGold, B-money, hashcash, and cryptographic time stamping provided the foundations for bitcoin invention.
- All these technologies are cleverly combined in Bitcoin to create the world’s first decentralized currency.
Bitcoin definition
- it’s a protocol, a digital currency, and a platform. It is a combination of peer-to-peer network, protocols, software that facilitate the creation and usage of the digital currency named bitcoin. Nodes in this peer-to-peer network talk to each other using the Bitcoin protocol.
- Decentralization of currency was made possible for the first time with the invention of bitcoin. Moreover, the double spending problem was solved in an elegant and ingenious way in bitcoin
- The double spending problem is resolved in Bitcoin by using a distributed ledger (blockchain) where every transaction is recorded permanently and by implementing transaction validation and confirmation mechanism. This process will be explained later in the chapter where we introduce the concept of mining.
Main Components of Bitcoin
- “Digital keys
- Addresses
- Transactions
- Blockchain
- Miners
- The Bitcoin network
- Wallets (client software)
Sending a payment to someone
“
- Transaction starts with a sender signing the transaction with their private key
- Transaction is serialized so that it can be transmitted over the network
- Transaction is broadcasted to the network
- Miners listening for the transactions picks up the transaction
- Transaction are verified for their validity by the miners
- Transaction are added to the candidate/proposed block for mining
- Once mined, the result is broadcasted to all nodes on the Bitcoin network
Keys in Bitcoin
- Private Keys
- Private keys are required to be kept safe and normally resides only on the owner’s side. Private keys are used to digitally sign the transactions proving the ownership of the bitcoins.
- Private keys are fundamentally 256-bit numbers randomly chosen in the range”
- Public Keys
- Public keys exist on the blockchain and all network participants can see it.
- Public keys are derived from private keys due to their special mathematical relationship with the private keys
- A public key is 256-bits in length. Public keys can be represented in an uncompressed or compressed format. Public keys are fundamentally x and y coordinates on an elliptic curve.
Addresses in Bitcoin
- A bitcoin address is created by taking the corresponding public key of a private key and hashing it twice, first with the SHA-256 algorithm and then with RIPEMD-160.
- The bitcoin addresses are 26-35 characters long and begin with digit 1 or 3.
Transactions
-
Transactions can be as simple as just sending some bitcoins to a bitcoin address, or it can be quite complex depending on the requirements.
-
Each transaction is composed of at least one input and output. Inputs can be thought of as coins being spent that have been created in a previous transaction and outputs as coins being created.
-
If a transaction is minting new coins, then there is no input and therefore no signature is needed.
-
If a transaction is to send coins to some other user (a bitcoin address), then it needs to be signed by the sender with their private key and a reference is also required to the previous transaction in order to show the origin of the coins.
-
“The following steps describe the transaction life cycle:
- A user/sender sends a transaction using wallet software or some other interface.
- The wallet software signs the transaction using the sender’s private key.
- The transaction is broadcasted to the Bitcoin network using a flooding algorithm.
- Mining nodes (miners) who are listening for the transactions verify and include this transaction in the next block to be mined. Just before the transaction are placed in the block they are placed in a special memory buffer called transaction pool. The purpose of the transaction pool is explained in the next section.
- Mining starts, which is a process by which the blockchain is secured and new coins are generated as a reward for the miners who spend appropriate computational resources. This concept is explained in more detail later in this chapter.
- Once a miner solves the PoW problem it broadcasts the newly mined block to the network. PoW is explained in detail later in this chapter.
- The nodes verify the block and propagate the block further, and confirmations start to generate.
- Finally, the confirmations start to appear in the receiver’s wallet and after approximately three confirmations, the transaction is considered finalized and confirmed. However[…]”
-
Transaction fee : Transaction fees are charged by the miners. The fee charged is dependent upon the size and weight of the transaction. Transaction fees are calculated by subtracting the sum of the inputs and the sum of the outputs.
-
Transaction pools :Also known as memory pools, these pools are basically created in local memory (computer RAM) by nodes in order to maintain a temporary list of transactions that are not yet confirmed in a block. Transactions are included in a block after passing verification and based on their priority.