Blockchain
Blockchain
Limitations of Blockchain.
Blockchain technology has enormous potential in creating trustless, decentralized applications.
But it is not perfect. There are certain barriers which make the blockchain technology not the
right choice and unusable for mainstream application. We can see the limitations of blockchain
technology in the following image.
Lack of Awareness
There is a lot of discussion about blockchain, but people do not know the true value of
blockchain and how they could implement it in different situations.
Limited availability of technical talent
Today, there are a lot of developers available who can do a lot of different things in every field.
But in the blockchain technology, there are not so many developers available who have
specialized expertise in blockchain technology. Hence, the lack of developers is a hindrance to
developing anything on the blockchain.
Immutable
In immutable, we cannot make any modifications to any of the records. It is very helpful if you
want to keep the integrity of a record and make sure that nobody ever tampers with it. But
immutability also has a drawback. We can understand this, in the case, when you want to make
any revisions, or want to go back and make any reversals. For example, you have processed
payment and need to go back and make an amendment to change that payment.
Scalability
Blockchain like bitcoin has consensus mechanisms which require every participating node to
verify the transaction. It limits the number of transactions a blockchain network can process. So
bitcoin was not developed to do the large scale volumes of transactions that many of the other
institutions are doing. Currently, bitcoin can process a maximum of seven transactions per
second.
Key Management
As we know, blockchain is built on cryptography, which implies that there are different keys,
such as public keys and private keys. When you are dealing with a private key, then you are also
running the risk that somebody may lose access to your private key. It happens a lot in the early
days when bitcoin wasn't worth that much. People would just collect a lot of bitcoin, and then
suddenly forgot what the key was, and those may be worth millions of dollars today.
History of Blockchain
Consensus Algorithm
Proof of Work (PoW)
Proof of Work is the oldest consensus mechanism used in the Blockchain domain. It is also
known as mining where the participating nodes are called miners.
In this mechanism, the miners have to solve complex mathematical puzzles using
comprehensive computation power.
They use different forms of mining methods, such as GPU mining, CPU mining, ASIC mining,
and FPGA mining.
And the one that solves the problem at the earliest gets a block as a reward.
However, the process is not that easy. A puzzle can be solved only via trial and error
method. Additionally, the level of complexity of the puzzle increases with the speed at
which blocks are mined. So, it becomes mandatory for one to create a new block within a
certain time frame to cope up with the difficulty level.
Proof of Stake (PoS)
Proof of Stake is the most basic and environmentally-friendly alternative of PoW consensus
protocol.
In this blockchain method, the block producers are not miners, but they act like validators.
They get the opportunity to create a block over everyone which saves energy and reduces
the time.
However, for them to become a validator, they are supposed to invest some amount of
money or stake.
Also, unlike that in the case of PoW, miners are provided with a privilege to take their
transaction fees in this algorithm for there is no reward system in this consensus model.
Proof of Burn (PoB)
Proof of Burn (PoB) consensus model works on the principle of letting miners ‘burn’ or ‘ruin’
the virtual cryptocurrency tokens, which further provides them with a privilege to write
blocks in proportion to the coins.
The more coins they burn, the more are the chances of picking the new block for every coin
they get.
But, in order to burn coins, they are required to send it to the address where it couldn’t be
spent for verifying the block.
This is widely employed in the case of distributed consensus. And the finest example of this
consensus mechanism is the Slim coin.
Proof of Capacity (PoC)
In the Proof of Capacity (PoC) mechanism, solutions for every complex mathematical puzzle
are accumulated in digital storages like Hard disks.
Users can use these hard disks to produce blocks, in a way that those who are fastest in
evaluating the solutions get better chances for creating blocks.
The process it follows is called Plotting.
The two cryptocurrencies that rely on PoC blockchain consensus protocol are Burstcoin and
SpaceMint.
10. Proof of Elapsed Time (PoET)
PoET was introduced by Intel with an intent to take over cryptographic puzzles involved in
PoW mechanism
It is based on the idea of fairly distributing and expanding the odds for a bigger fraction of
participants. And so, every participating node is asked to wait for a particular time to
participate in the next mining process.
The member with the shortest hold-up time is asked to offer a block.
At the same time, every node also comes up with their own waiting time, after which they
go into sleep mode.
So, as soon as a node gets active and a block is available, that node is considered as the
‘lucky winner’.
This node can then spread the information throughout the network, while maintaining the
property of decentralization and receiving the reward.
Cryptography.
Cryptography is technique of securing information and communications through use of
codes so that only those person for whom the information is intended can understand it and
process it.
Cryptography prevents unauthorized access to information.
The prefix “crypt” means “hidden” and suffix “graphy” means “writing”.
Features Of Cryptography are as follows:
Confidentiality: Information can only be accessed by the person for whom it is intended and no
other person except him can access it.
Integrity: Information cannot be modified in storage or transition between sender and intended
receiver without any addition to information being detected.
Non-repudiation: The creator/sender of information cannot deny his intention to send
information at later stage.
Authentication: The identities of sender and receiver are confirmed. As well as
destination/origin of information is confirmed.
Asymmetric Cryptography
This encryption method uses a pair of keys, an encryption key, and a decryption key, named
public key and private key respectively.
The key pair generated by this algorithm consists of a private key and a unique public key
that is generated using the same algorithm. It is also called Public-Key Cryptography.
The use of asymmetric cryptography is where the environment is continuously expanding
and the data is exchanged between different communication partners. The reason is its high
scalability.
In this type of cryptography, to perform key exchange, one party produces the secret key
and encrypts it with the public key of the receiver. The receiver then can easily decrypt it
using their private key.
Once the connection is established, the rest of the communication will be completed by
using the secret key as the encryption key.
However, unlike symmetric key, the problem with asymmetric rises when the public key has
to be authenticated.
The public key holds the risk of getting tampered with by any malicious third party. However,
this problem can be solved by using Public-key infrastructure (PKI).
In this method, another third party known as certificate authorities, check the ownership of
the keys. Another method named “web of trust” can also be used to provide authenticity of
key pairs.
Bitcoin
Launched in 2009, Bitcoin is the world's largest cryptocurrency by market capitalization.
Unlike fiat currency, Bitcoin is created, distributed, traded, and stored using a decentralized
ledger system known as a blockchain.
Bitcoin and its ledger are secured by proof-of-work (PoW) consensus, which also secures the
system and verifies transactions.
Bitcoin can be purchased via various cryptocurrency exchanges.
Bitcoin's history as a store of value has been turbulent; it has undergone several boom and
bust cycles over its relatively short lifespan.
Genesis Block
A Genesis Block is the first block in a cryptocurrency blockchain.
A blockchain consists of a series of blocks that are used to store information related to
transactions that occur on a blockchain network.
Each block contains a unique header, and each such block is individually identified by its
block header hash.
These blocks are chained together by their encrypted headers, with the Genesis Block being
the foundation—and they grow in number.
A block's number is referred to as its height on the blockchain.
So, the Genesis Block has a height of zero, the following block has a height of one, and so
on.
The chained information in each block is one of the things that makes a blockchain so
secure.
Bitcoin's Genesis Block was the first instance of a proof-of-work blockchain system and is the
template for all other blocks in its blockchain.
Orphan Blocks
In blockchain terms, orphan blocks are blocks mined simultaneously as another block but
not accepted by the blockchain.
Most of the time, this is because there are not enough blocks generated from that block for
the network to recognize it as the longest fork.
There can be two miners who solve valid blocks simultaneously. The network uses both
blocks until one chain has more verified blocks. Then, the blocks in the shorter chain are
orphaned.
Orphan blocks are a regular occurrence in a distributed blockchain such as Bitcoin.
The Bitcoin blockchain discards orphan blocks; however, other blockchains may use them for
different purposes.
Technically, orphan blocks are called stale blocks, but because most people refer to them as
orphans or uncles, the name orphan (and uncle) block has stuck.
CAP theorem
CAP theorem, also known as Brewer's theorem, was introduced by Eric Brewer in 1998 as
conjecture. In 2002, it was proven as a theorem by Seth Gilbert and Nancy Lynch. The
theory states that any distributed system cannot have consistency, availability, and partition
tolerance simultaneously:
Consistency is a property which ensures that all nodes in a distributed system have a single,
current, and identical copy of the data.
Availability means that the nodes in the system are up, accessible for use, and are accepting
incoming requests and responding with data without any failures as and when required. In
other words, data is available at each node and the nodes are responding to requests.
Partition tolerance ensures that if a group of nodes is unable to communicate with other
nodes due to network failures, the distributed system continues to operate correctly. This
can occur due to network and node failures.
It has been proven that a distributed system cannot have consistency, availability, and partition
tolerance simultaneously. This is explained with the following example. Let's imagine that there
is a distributed system with two nodes. Now let us apply the three theorem properties on this
smallest of possible distributed systems only with two nodes.
Consistency is achieved if both nodes have the same shared state; that is, they have the
same up-to-date copy of the data.
Availability is achieved if both nodes are up and running and responding with the latest
copy of data.
Partition tolerance is achieved if communication does not break down between two nodes
(either due to network issues, Byzantine faults, and so forth), and they are able to
communicate with each other.
S.N
O Private Key Public Key
In this, the same key (secret key) and In public-key cryptography, two keys are
algorithm are used to encrypt and used, one key is used for encryption, and the
2. decrypt the message. other is used for decryption.
In private key cryptography, the key is In public-key cryptography, one of the two
3. kept a secret. keys is kept a secret.
The private key is Symmetrical because The public key is Asymmetrical because
there is only one key that is called a there are two types of keys: private and
4. secret key. public keys.
In this cryptography, the sender and In this cryptography, the sender and receiver
5. receiver need to share the same key. do not need to share the same key.
S.N
O Private Key Public Key
8. It is used for large amounts of text. It is used for only short messages.
There is the possibility of losing the key There is less possibility of key loss, as the key
9. that renders the systems void. is held publicly.
Bitcoin Wallets
“A Bitcoin wallet (and any crypto wallet, for that matter) is a digital wallet storing the encryption
material giving access to a Bitcoin public address and enabling transactions,”
Bitcoin wallets not only hold your digital coins, but they also secure them with a unique private
key that ensures that only you, and anyone you give the code to, can open your Bitcoin wallet.
Think of it like a password on an online bank account.
With a crypto wallet, you can store, send and receive different coins and tokens.
Types of Bitcoin Wallets
As with physical wallets, Bitcoin wallets come in a range of styles, each offering a tradeoff
between convenient access and security against theft.
Mobile
Mobile wallets, like WazirX multi-cryptocurrency wallet and Exodus bitcoin wallet are those that
run as apps on phones, tablets and other mobile devices.
Web
Web-based wallets, like Guarda Bitcoin Wallet, store your coins through an online third party.
You can gain access to your coins and make transactions through any device that lets you
connect to the internet. These web-based wallets are frequently associated with crypto
exchanges that allow you to trade and store crypto all in one place.
Desktop
Desktop wallets, like Guarda and Exodus, are programs you can download onto a computer to
store coins on your hard drive. This adds an extra layer of security versus web and mobile apps
because you aren’t relying on third-party services to hold your coins. Still, hacks are possible
because your computer is connected to the internet.
Hardware
Hardware wallets are physical devices, like a USB drive, that are not connected to the web.
These include Ledger Nano X Bitcoin Wallet and Trezor Model T Bitcoin Wallet available in India.
To make transactions, you first need to connect the hardware wallet to the internet, either
through the wallet itself or through another device with internet connectivity.
Paper Wallets
In a paper wallet, you print off your key, typically a QR code, on a paper document. This makes it
impossible for a hacker to access and steal the password online, but then you need to protect
the physical document.
Bitcoin types of Transaction. (p2p-kh, p2sh, pay to multisig, pay to pub key)
P2PK
Pay-to-Public-Key (P2PK) is the original method of receiving bitcoin, and it does not involve an
address. Instead, as the name suggests, bitcoin is paid directly to an exposed public key.
P2PK is no longer used because it is a more expensive, less private, and less secure way of
receiving bitcoin than subsequent methods.
P2PKH
Pay-to-Public-Key-Hash (P2PKH) was available for use at bitcoin’s beginning, and it showed up
on the blockchain for the first time less than two weeks after the genesis block. P2PKH makes
several improvements upon P2PK, such as utilizing an address. P2PKH addresses are typically 34
or 33 characters in length, and they are encoded in Base58 format. They begin with a prefix
of 1 and are currently responsible for receiving and securing 43% of the mined bitcoin supply,
more than any other address type.
P2MS
Pay-to-Multisig (P2MS) is a trivial transaction type that was only briefly relevant and has never
been responsible for holding more than 100 bitcoin at one time across all network participants.
Nevertheless, P2MS is a part of bitcoin’s history.
P2MS was introduced as a standard script in early 2012, as specified by BIP 11. However, this
transaction type suffered from the same problems as P2PK since it included exposed public keys
and did not use any address format. It also limited the number of public keys in a multisig
quorum to three.
P2SH
Pay-to-Script-Hash (P2SH) was introduced to bitcoin as a soft fork in accordance with BIP 16 on
April 1, 2012. P2SH shares a lot in common with P2PKH. The main difference is that the address
is created by hashing a redeem script instead of hashing a single public key.
A redeem script can be thought of as coded instructions specifying how bitcoin received to the
P2SH address can be spent in the future. There could be a wide range of possibilities, including
multiple different public keys. The receiver, not the sender, determines the script details, and
the spending instructions are not exposed publicly until bitcoin is spent out of the address.
Structure of a block.
Let’s just draw a conceptual image of a block with reference
to a ledger of transactions.
The above image will create a simpler conceptual block
visualization in your head. However, the actual block contains
a lot more information than the ledger image above.
Following are the significant elements of a block –
Block Height –
It’s the sequence number of the block in the chain of blocks.
Block Height: 1 is the genesis block (first block in the network).
Block Size –
It’s a 4-bytes or 32-bit field that contains the size of the block.
It adds size in Bytes. Ex – Block Size: 216 Bytes.
Block Reward –
This field contains the amount rewarded to the miner for adding a block of transactions.
Tx Count –
The transaction counter shows the number of transactions contained by the block. The field has
a maximum size of 9 bytes.
Block Header –
The Block header is an 80-Byte field that contains the metadata – the data about the block.
Let’s briefly discuss the 6 components of the Block Header.
Time – It’s the digitally recorded moment of time when the block has been mined. It is
used to validate the transactions.
Version – It’s a 4-bytes field representing the version number of the protocol used. Usually,
for bitcoin, it’s ‘0x1’.
Previous Block Hash – It’s a 32-bytes field that contains a 256-bits hash of the previous
block. This helps to create a linear chain of blocks.
Bits – It’s a 4-bytes field that tells the complexity to add the block. It’s also known as
“difficulty bits.”
Nonce – It’s a 4-bytes field that contains a 32-bit number. These are the only changeable
element in a block of transactions.
Merkle Root – A 32-bytes field containing a 256-bit root hash. It’s constructed hierarchically
combining hashes of the individual transactions in a block.
Transactions
It’s a variable-size field that includes the list of all transactions contained in the block.
FYI, each bitcoin block contains about 2000 transactions. The size of each block is approx. 1MB.
The size and number of transactions in a block vary in blockchains. It’s decided based on
network congestion and communication overhead.
Ethereum
Ethereum is a decentralized global software platform powered by blockchain technology.
It is most commonly known for its native cryptocurrency, ether (ETH).
Ethereum can be used by anyone to create any secured digital technology.
It has a token designed to pay for work done supporting the blockchain, but participants can
also use it to pay for tangible goods and services if accepted.
Ethereum is designed to be scalable, programmable, secure, and decentralized.
It is the blockchain of choice for developers and enterprises creating technology based upon
it to change how many industries operate and how we go about our daily lives.
Cryptocurrency
Cryptocurrency is a digital payment system that doesn't rely on banks to verify transactions.
It’s a peer-to-peer system that can enable anyone anywhere to send and receive payments.
Instead of being physical money carried around and exchanged in the real world,
cryptocurrency payments exist purely as digital entries to an online database describing
specific transactions.
When you transfer cryptocurrency funds, the transactions are recorded in a public ledger.
Cryptocurrency is stored in digital wallets.
Cryptocurrency received its name because it uses encryption to verify transactions.
This means advanced coding is involved in storing and transmitting cryptocurrency data
between wallets and to public ledgers.
The aim of encryption is to provide security and safety.
The first cryptocurrency was Bitcoin, which was founded in 2009 and remains the best
known today.
Much of the interest in cryptocurrencies is to trade for profit, with speculators at times
driving prices skyward.
Explain EVM.
The Ethereum Virtual Machine (EVM) is the computation engine for Ethereum that manages
the state of the blockchain and enables smart contract functionality.
The EVM is contained within the client software that you need in order to run a node on
Ethereum.
Nodes on Ethereum keep copies of transaction data, which the EVM processes to update
the distributed ledger.
Generally speaking, nodes on Ethereum natively support the EVM as the client software
implements this functionality.
The EVM participates in block creation and transaction execution.
In block creation, the EVM sets standards for managing the state from block to block.
In transaction execution, the EVM executes tasks by interpreting the instructions
in Opcodes; however, the data is formatted in bytecode.
To get the data into bytecode, you can use a programming language such as Solidity (i.e., the
native programming language for smart contracts) to compile and deploy the smart contract
using bytecode.
Smart Contract
A Smart Contract (or cryptocontract) is a computer program that directly and automatically
controls the transfer of digital assets between the parties under certain conditions.
A smart contract works in the same way as a traditional contract while also automatically
enforcing the contract.
Smart contracts are programs that execute exactly as they are set up(coded, programmed)
by their creators.
Just like a traditional contract is enforceable by law, smart contracts are enforceable by
code.
The bitcoin network was the first to use some sort of smart contract by using them to
transfer value from one person to another.
The smart contract involved employs basic conditions like checking if the amount of value to
transfer is actually available in the sender account.
Later, the Ethereum platform emerged which was considered more powerful, precisely
because the developers/programmers could make custom contracts in a Turing-complete
language.
It is to be noted that the contracts written in the case of the bitcoin network were written in
a Turing-incomplete language, restricting the potential of smart contracts implementation in
the bitcoin network.
There are some common smart contract platforms like Ethereum, Solana,
Polkadot, Hyperledger fabric, etc.
Ricardian Contract
A Ricardian Contract is a legal contract that was introduced first in 1995 by a well-known
programmer, Ian Grigg.
“It is a form of digital documents that act as an agreement between two parties on the
terms and condition for an interaction between the agreed parties.”
What makes it unique is – it is cryptographically signed and verified.
Even when it is a digital document, it is available in a human-readable text that is also easy
to understand for people (not only lawyers).
It is a unique legal agreement or document that is readable for computer programs as well
as humans at the same time.
Simply put, it has two parts or serves two purposes. First, it is an easy-to-read legal contract
between two or more parties. Your lawyer can easily understand it, and even you can read it
and understand the core terms of the Contract.
Second, it is a machine-readable contract as well. With blockchain platforms, these contracts
can now easily hashed, signed, and can be saved on the blockchain.
All in all, Ricardian Contracts merge legal contracts with technology, blockchain
technology to be precise. They bind the parties into a legal agreement before the execution
of the actions on the blockchain network.
Externally Owned Accounts vs Contract Based Accounts
Below are the differences between Externally owned accounts and contract-based accounts.
S.
No. Externally Owned Accounts Contract Accounts
2. The private key is needed to access EOAs. No key is needed to access Contract Accounts.
5. No execution fee is associated with EOAs. The execution fee is associated with CAs.