Introduction to Blockchain

Introduction to Blockchain

Overview of Blockchain

  1. Blockchain is the distributed database of records of all transactions or digital events that have been executed and shared among participating Parties.

  2. Blockchain technology is the backbone of Bitcoin (Digital Cryptocurrency), and bitcoin is the most popular Cryptocurrency.

  3. Satoshi Nakamoto Published a White Paper on “Bitcoin: A peer-to-peer electronic cash system” in 2008.

  4. Blockchain Technology records transactions in Digital Ledger, which is distributed over the network thus making it incorruptible.

  5. Anything value like a car, assets, land, etc. can be recorded as a Transaction in Blockchain.

  6. By storing data in a peer-to-peer network of nodes, the blockchain is a decentralized network.

  7. When a Computer connects to the blockchain, a copy of blockchain data gets downloaded into the System and nodes come in sync with latest block of data on blockchain.

  8. Blockchain builds trust through following Five attributes - distributed ledger, Secure, Transparent, consensus based, flexible.

  9. Benefits of Blockchain - Time saving, cost saving, Higher security, collaboration, reliability.

  10. Blockchain cannot process transactions faster because it doesn’t use a centralized infrastructure and also because it uses 256-bit encryption

Public Ledger

  1. Public ledger is an open access network, anyone can join at anytime

  2. Public ledger is full decentralized and no single entity controls the blockchain network

  3. Bitcoin and ethereum blockchains are both considered as public ledgers

  4. Blockchain data is stored on a decentralized public ledger.

  5. The data on the ledger is stored in chunks called blocks, which are chained together using cryptography.

Bitcoin

  1. Satoshi Nakamoto introduced bitcoin on 31st October, 2008.

  2. Bitcoin is a cryptocurrency (virtual currency) that uses rules of cryptography for regulation and generation of units of currency.

  3. Bitcoin is a type of digital asset that can be sold, bought and transferred between two parties securely over the internet

  4. We can use bitcoin to buy products and services, as well as make payments and exchange values electronically

  5. When you send a bitcoin to someone or use bitcoin to buy anything, you don’t need to use a bank, a credit card, or any other third party, you can simply send bitcoin directly to another user over the internet securely

  6. Features : distributed network, decentralized ecosystem, transparent, P2P(peer-to-peer), Censorship resistant, Public, Permissionless

  7. Bitcoin wallet has two things - Public key and private key (The public key can be shared with anyone but the private key must be held by the owner. If the private key gets hacked or stolen then bitcoin gets lost)

  8. Many marketplaces like Bitcoin exchanges allow users to buy or sell bitcoins using different currencies. People on the bitcoin network compete among themselves to mine bitcoins using computers to solve complex maths puzzles. This is how bitcoins are created.

  9. To use bitcoin, wallets are required. cryptocurrency wallets contain private keys to the bitcoin, which need to be entered while conducting a transaction.

  10. Bitcoin uses the SHA-256 hashing algorithm to encrypt the data stored in the blocks on the blockchain.

  11. A Satoshi is the smallest unit of Bitcoin. A unit of Satoshi is equal to 0.00000001 bitcoin.

Smart Contracts

  1. smart contracts are simple programs stored on blockchain, that runs when predetermined conditions are met.

  2. A smart contract is just a digital contract with the security coding of the blockchain.

  3. There are some common smart contract platforms like ethereum, solana, Polkadot, hyperledger fabric, etc.

  4. Features of smart contract -

    • distributed - A smart contract is replicated and distributed by all the nodes connected to the network.

    • deterministic - Smart contracts can only perform functions for which they are designed only when the required conditions are met.

    • Immutable - Once deployed smart contract cannot be changed, it can only be removed.

    • Autonomy - The contract is made by you and shared between the parties. No intermediaries are involved.

    • Customizable - Smart contracts have the ability for modification or we can say customization before being launched to do what the user wants it to do.

    • Transparent - Smart contracts are always stored on a public distributed ledger called blockchain due to which the code is visible to everyone

  5. Applications of Smart contract - used in Real Estate, Vehicle Ownership, music industry, Government election, management, healthcare

  6. Challenges in Smart Contract - No regulations, difficult to implement, immutable, alignment

Block in a blockchain

  1. Blocks are data structures within the blockchain database, where transaction data in a cryptocurrency blockchain are permanently recorded.

  2. A block is a place in a blockchain where information is stored and encrypted.

  3. A block is thus a permanent store of records that, once written, cannot be altered or removed

  4. Types of Blocks -

    • Genesis Block → Genesis means ‘origin’, genesis block is the first block of a blockchain.

    • Valid Block - Valid blocks are all such blocks that have been mined and added to the blockchain.

    • Orphan Block - Orphan blocks are not part of the blockchain network.

Distributed consensus

Blockchain network rely on consensus algorithm to reach agreement among various distributed nodes.

A consensus mechanism such as POW or POS secures the network and prevents unauthorized users from validating bad transactions.

Public vs Private Blockchain

Public Blockchain (Permissionless)Private Blockchain (Permissioned)
Anyone can read, write and participate in Blockchain. Hence it is permissionless blockchain.read and write is done upon invitation or permission. Hence it is permissioned blockchain.
decentralizedmore centralized
low speed of transactionfast speed of transaction
A public blockchain is more secure due to decentralization and active participation.A private blockchain is more prone to hacks, risks, and data breaches/ manipulation.
A public blockchain consumes more energy than a private blockchain.Private blockchains consume a lot less energy and power.
Consensus algorithms - Proof of work, Proof of stake, Proof of burn, Proof of space.Consensus algorithms - Proof of Elapsed Time, Raft.
high energy consumptionlow energy consumption
Requires no trust among the membersMembers need to trust each other
E.g. Bitcoin, Ethereum, Monero, Zcash, Dash, Litecoin, Stellar, Steemit etc.E.g. R3 (Banks), EWF (Energy), B3i (Insurance), Corda.

Understanding cryptocurrency to blockchain

  1. Cryptocurrency is a type of digital asset which is used to exchange value between parties.

  2. Cryptocurrencies run on a distributed public ledger called blockchain, a record of all transactions updated and held by currency holders.

  3. It uses strong cryptography to secure financial transactions and control the creation of new units of that currency and verify the transfer of assets.

  4. Cryptocurrency does not exist physically.

  5. If you own cryptocurrency, you don’t own anything tangible. What you own is a key that allows you to move a record or a unit of measure from one person to another without a trusted third party.

  6. Some popular Cryptocurrencies include :

  • Bitcoin - Bitcoin was the first cryptocurrency and is still the most commonly traded

  • Ethereum - Ethereum is a blockchain platform with its own cryptocurrency, called Ether (ETH)

  • Litecoin - similar to bitcoin but has moved more quickly to develop new innovations

  • Solana - Solana is a decentralized computing platform that uses SOL to pay for transactions

Permissioned model of blockchain

  1. A permissioned blockchain is a distributed ledger that is not publicly accessible, only be accessed with permission.

  2. Permissioned blockchains provide an additional level of security over typical blockchain systems like Bitcoin, as they require an access control layer.

  3. The users can only perform specific actions granted to them by the ledger administrators and are require to identify themselves through certificates or digital means.

  4. Permissioned blockchains are becoming more common as businesses realize their benefits

  5. A blockchain can be built and accessed in multiple ways. Some blockchains need special permissions to read, access,and write information.

  6. Records are kept within the blockchain, of who is involved in transactions. This makes permissioned blockchains different from permissionless blockchain.

Security in Blockchain

  1. Blockchain security is a risk management technique that aims to secure transactions.

  2. It is usually implemented with the help of cybersecurity, authorized services, and ethical users.

  3. Blockchain attacks are cyber attacks that can be done by outside malicious users as well as users in the network.

  4. Some of the attacks include: Sybil Attack, Eclipse, 51% attack, Finney attack

  5. Practices for building secure blockchain solutions - use cold wallet, secure the internet, blockchain penetration testing, use permissioned blockchain

Hash Function

  1. A hash function is a mathematical function that takes an input string of any length and converts it into a fixed-length output string.

  2. The fixed length output value is know as hash value.

Properties of Hash function

  • Deterministic - for any given input a hash function must always give the same result.

  • Avalanche Effect - This means for a small change in the input, the output will change significantly.

  • Collision resistant - Give two messages m1 and m2, it is difficult to find a hash value such that hash(k, m1) = hash(k, m2) where k is the key value.

  • Fixed-length Mapping- For any input of fixed length, the hash function will always generate the output of the same length.

  • Large output space - The only way to find a hash collision is via a brute force search

Hash pointer

A hash pointer is a pointer where data is stored, and cryptographic hash of the data is also stored.

Hash pointer points to the data, and also allows us to verify the data

A hash pointer can be used to build all kinds of data structures such as blockchain and Merkel tree.

Merkle Tree

  1. A Merkle tree is a binary tree formed by hash pointers, and named after its creator, Ralph Merkle.

  2. In a Merkle tree, transactions are grouped into pairs, The hash is computed for each pair and this is stored in the parent node. Now the parent nodes are grouped into pairs and their hash is stored one level up in the tree. This is continuous till the root of the tree.

  3. The different types of nodes in a Merkle tree are:

  • Root node: The root of the Merkle tree is known as the Merkle root.

  • Leaf node: Leaf node contains the hash values of transaction data.

  • Non-leaf node - the non-leaf node contains the hash value of their respective children.

  1. Merkle tree is binary in nature, this means no. of leaf nodes needs to be even for the merkle tree to be constructed properly.

Public key cryptography

  1. Also known as Public key encryption

  2. Involves a pair of keys, public key and private key, each public key is published and private key is kept secure.

  3. Data that is encrypted with the public key can be decrypted only with the corresponding private key.

  4. commonly used implementations are based on RSA Algorithm.

  5. Public key cryptography enables the following:

  • Encryption and decryption, which allow two communicating parties to disguise data that they send to each other.

Digital signature

  1. A digital signature is a mathematical technique used to validate the authenticity and integrity of a message, software, or digital document.

  2. Key Generation Algorithms - Digital signature is electronic signatures, which assure that the message was sent by a particular sender.

  3. Signing Algorithms - To create a digital signature, signing algorithms like email programs create a one way-hash of the electronic data which is to be signed. The signing algorithm then encrypts the hash value using the private key (signature key).

  4. Signature Verification Algorithms- Verifier receives Digital Signature along with the data. It then uses Verification algorithm to process on the digital signature and the public key (verification key) and generates some value.

Zero knowledge system

The zero-knowledge protocol uses the statement (called a 'witness') as input to generate a succinct proof of its validity. This proof provides strong guarantees that a statement is true without exposing the information used in creating it.