Blockchain and Cryptocurrency

Some notes in areas of cryptocurrency.

Blockchain

Blockchain is a linked list of blocks where each block contains some information. (Also known as Distributed Ledger Technology DLT). The lists are linked in chronological order and stored in a distributed system. The list grows during transactions in which a new block is added. Older blocks on the list can never be removed. It is always an append method. The list is essentially a ledger with complete history. These blockchains are stored across several systems in a pool making it decentralized.

The data that is stored in a block depends on the type of blockchain. For example, a bitcoin blockchain would store information about the sender, receiver and the amount of bitcoins in a block. Every block also has hashes which is an identifier. If the data inside the block were to change, the hash would change. This is how users are able to verify changes. Each block also has a hash value for its previous block, which creates the chain. The very first block at the root of the list is called the genesis block.

A block is created by a computer solving a difficult math problem and having that solution verified through the network. The problem it’s solving is the creation of the hash, which is done through an cryptography algorithm. The first computer that is able to generate this hash appends it to the blockchain. Because the solution is mathematical, other nodes on the network are able to quick verify the solution and update their blockchain with the new hash.

The process of generating the new hash is called Proof of Work and for the computer that was able to complete it first would get some incentive. In the case of bitcoins, this user gets a small amount of coin for completing that solution. Another term used for doing the Proof of Work is called mining.

The benefits of using blockchains is its tracability, transparency and due to being distributed across the network its reliability. It is very difficult to tamper with a blockchain since that change would need to propagated through all the nodes simulataneously.

There are many different types of blockchains some being open to the public, some private and some controlled specific to an organization for specific purposes only (public but controlled).

 

Cryptography

One of the important components of blockchains is cryptography. There are 3 main components of blockchain cryptography – hashing, encryption and signing.

Hashes are algorithms that take one piece of data and translate it to another form but it still represents that original data. For example, we could use Base64 encoding to hash strings into their Base64 format.

Another part of cryptography is encryption. Encryption is done in two ways – Symmetric Encryption and Asymmetric Encryption. With symmetric encryption we use a single key to encrypt the original data. That same key is needed to decrypt the data. Things like Bitlocker uses a symmetric encryption. Asymmetric encryption is the use of public and private keys. Here a public key is used to encrypt the data but it cannot be used to decrypt it. Only the private key can decrypt the data. So in a transaction, we would use the receiver’s public key to encrypt the data and send it to them. The receiver would use their private key to decrypt the incoming data. If that receiver needs to respond, they use their private key to encrypt the data and send it back to the sender. The sender then uses the original public key to decrypt the data.

With public key cryptography we can also use signing. Signing is an additional authentication step in asymmetric encryption. Here the sender sends two messages to the receiver. One is an unencrypted version of the message and the second is an encrypted version using the sender’s private key. The receiver would be able to use the sender’s public key to decrypt the encrypted message. Then using the same hash algorithm (which is agreed upon during transaction), the receiver hashes both the original unencrypted message and the decrypted message. If the hash values of these messages match, then the receiver can trust the sender’s public key and therefore the message truly came from that sender.

 

Consensus

For the blockchain network to work we need to have consensus, which is a trust among all nodes in the network. The nodes have an agreement of all transactions across the network. Every node on the network also needs to agree that the blockchains are in the correct order. This can be done based on the hashes the public keys for each of transactions (or blocks) in that blockchain.

When a new transaction happens, a node on the network would make a proposal which other members in the network would review and accept. But depending on the blockchain network, there are different requirements when creating a new block. For example, in bitcoin the block must include the data + a random value called a nonce. This value is unknown at first. Instead the bitcoin environment sets a requirement saying that with the data + nonce must produce a hash that meets a certain requirement (example length, format, has leading zeroes, etc). Given these requirements the miners need to figure out what the nonce is.

The process of discovering the nonce can only be done through brute force. Since there is no way of determining the nonce mathematically, the miner must randomly try different values that result to the accepted hash. Once a miner finds the nonce, it is easy for other nodes of the network to verify the work since they just take the data + nonce and see if it matches the hash requirement. This is what is called Proof of Work, where a miner has validated that they mined the possibilities for the answer and was able to find it on their own. As a result, the miner is also awarded some small fee. As the other nodes verify the new nonce for this block, that blockchain becomes updated throughout the network and eventually all nodes will recognize the new transaction block on top of that blockchain.

There are cases in which two different nodes would come upon the Proof of Work answer at the same time. This is called fork. This could happen by chance or by malicious attack (trying to double spend). In this scenario we need to observe the blockchain for the next block to appear. In blockchain, the deeper chain always wins. But there is risk here because when there is a fork and we’ve considered the branch that is to become obsolete, we would loose out on that block and if this was cryptocurrency, we would be loosing out on the amount of money tied to that block or transaction. To avoid this problem, it is considered best practice to wait for the blockchain to grow 6 more blocks before permanently accepting the transaction.

To create 6 blocks in bitcoin, it usually takes about 60 minutes. Bitcoin is designed to force miners to take about 10 minutes to Proof of Work a single block. As time goes on and the miner’s rig improves, being able to brute force faster, the bitcoin network automatically increases the difficulty of the Proof of Work by changing the requirement for the hash value that is to be generated by the nonce. Conversely, if the processing time takes more than 10 minutes the bitcoin network would automatically throttle down the difficulty.

 

Smart Contracts

This is using the blockchain technology to store different data in the blocks. While cryptocurrency stores monetary transaction information in the blocks, this doesnt always need to be the case. For example we could store program data in the blocks. The Ethereum network supports this type of blockchains.

Some key concerns with storing programmatic data on a blockchain is that everything in that chain is immutable – nothing in the past can be changed. Therefore if there is a bug in the block, that bug will reside there forever. To address the bug a future block would need to override that previous blocks code processing. Also, due to the nature of blockchains all data/code will be readable to the world. And note that every miner on the network would be executing the code in these blockchains.

The Ethereum network had a particular blockchain with a bug and hackers were able to exploit it for hundreds of millions of dollars. To correct this the Ethereum network did a fork and moved all transactions to the new branch. As that branch grew deeper than the previous branch, it corrected the problem and was able to retain the lost money.

An example of smart contracts can be seen when doing a goods for money transaction. For such transactions, code could be added into block indicated the conditions of the transaction. For example, it could include the condition that only when seller agrees to transaction then the buyer will transmit the money, else the money will not transmit. By typing this condition into the block, that block not only contains the transaction information (such as buyer, seller and money amount) but a definition of the transaction and what condition was met.

 

Use Cases for Blockchains

Blockchains are disrupting many industries and in particular the financial industry. Whereas traditional ways or tracking finances are centralized, by using a bank, blockchain disrupts this by having transactions distributed and decentralized.

Walmart is using blockchains in its food distribution. It is able to track the history of all its food products such that if an outbreak were to occur they would be able to quickly reference where and when that outbreak happened.

Another use case is in the diamond industry. Here blockchains are used to track diamonds from the mine to the consumer. Since every transaction is being recorded through the blockchain it can be easy to trace those diamonds that came from unethical sources.

Blockchains are being considered for the new internet. There are many parts of the internet that are decentralized already, for example the way routing can have multiple paths and how through replication data is spread across a largely distributed network. However, some parts of the internet are not decentralized, such as the domain hosting and certificate authorities. Also identity is centralized on the internet through the identity providers. One’s identity on the internet is always through that identity provider. Companies like Blockstack are trying to change this by creating decentralized identification. This means each individual owns a specific identity key that is owned solely by them with no provider. That identity relies on the blockchain and dispersing that blockchain into a large network of users.

There was a recent phenomenon called cryptokitties where one could purchase into a limited number of crypto kittens. Due to the limited number it became like Beanie Babies and drove up demand. Some of which sold for thousands of dollars of a total capital of over $10 million.

 

 

51% (Fifty-one Percent) Attack and Double Spending Problem

This is an attack on the blockchain mining. If 51% of the blockchain miners were controlled by a single entity, then that entity would be able to exploit the system. By controlling a majority of the hashing algorithms, it would be able to modify current processes such that any transactions they are doing get hidden or halted. In this way this attacker would be able to double spend – meaning submitting duplicate transactions since they are controlling the majority of the validation processes.

Such incidents almost occurred in bitcoin in 2014. But the community was able to detect that a single entity was approaching 51% and quickly alerted all it’s members. This caused the other miners to leave the pool essentially leaving the attacker by themselves with no one to exploit. A flip side to this is that realistically, if such entity were able to control a majority of the mining processes, the money they would earn from that processing would most likely outweigh the benefits of exploiting the rest of that pool. Therefore there isnt much incentive to run such an attack.

 

Consensus Conference

An annual blockchain technology summit to share and discuss the future use cases of the technology. Attendees include many startups trying to expand on the technology for many sectors, such as financial, government, security, insurance, healthcare, and security.

Organized by coindesk.

 

Cryptocurrency

Cryptopcurrency uses the blockchain technology to produce a digital currency for goods and services transactions. In 2009 Satoshi Nakamoto used the blockchain concept to create Bitcoin. Today there are several types of cryptocurrency.

  • Bitcoin
  • Ehereum
  • Litecoin
  • Dogecoin
  • IOTA
  • Zcash

 

Traditional currency is called Fiat Currency (ie paper money). These are issued by governments. It usually has delays between transactions and settlements as there is a need for intermediaries to prevent fraud and loss. For these services there are transaction fees. In comparison, cryptocurrencies do not have a central authority and therefore no intermediaries. Transactions clear based on how many in the network receive and update the information.

 

Bitcoin

Bitcoins use blockchains as part of transactions. For example if John was sending 5 coins to Jenny, this transaction would be a new block in a blockchain with information about the receiver, the sender and the amount. One of the benefits of bitcoins is that there is no savings account or repository storing all the coins. Everything is based off blockchains only. Therefore, in order for John to send 5 coins to Jenny, John would need to indicate where those 5 coins came from. John may have 3 and 2 bitcoins from two separate previous transactions. So when John sends 5 bitcoins to Jenny, what he is actually doing is creating a new block where it references the 3 and 2 bitcoin blockchains before it. Essentially a merger of two prior blockchains.

 

The process of mining or generating a new block is controlled by the bitcoin network. The difficulty of solving the hash problem is calibrated so that it typically takes 10 minutes to process on a typical mining computer. As hardware processing power increases, the bitcoin network re-evaluates the degree of difficulty every year and changes it to continue this 10 minute duration per block.

Best practice says that for smaller transactions, users should wait for at least 2 blockchain confirmations before considering the transaction complete. So this would be about 20 minutes. For larger transactions it states that users should wait 6 blocks, or 60 minutes before considering the transaction complete.

 

Transactions

Bitcoin transactions can be viewed publicly on the site: blockhain.info

Here we can see transactions, as well as summaries to the overall bitcoin economy. A transaction always has one or many input amount and one or many output amount. The input amount indicates where the transaction bitcoin sources are coming from (which are other prior transactions). The output amount are the new destinations for this transaction. On top of the input and output amount there is also a Fee amount, which is the cost of this transaction. This fee is paid to the miner who processed this transaction.

 

Coinbase

Coinbase transactions are the mined reward given to the miner for finding the winning block (finding the nonce that generates a hash that meets the bitcoin requirement). The coinbase started at 50 bitcoins has was set to halve every 210,000 blocks. At the current rate, it is expected to hit near zero sometime after 2030. Once the coinbase is gone, the miners would make money by charging fees through each transaction.

 

Mining Pools

These are massive pools of computers that do mining. These mining pools can be controlled by a single entity or a collection of people. People could pay to join a mining pools, in which they are paying for the hardware that goes into these pools. In return, whatever mining rewards the pool wins get distributed to those investors. Due to the number of these massively large mining pools, personal mining is no longer feasible. The odds of a personal rig being able to generate Proof of Work against these pools are very slim, almost like winning the lottery.

As of today, in bitcoin the top mining pools are listed below. In bitcoin over 99% of its mining are done in mining pools (almost no individual miners).

  • BTC.com
  • AntPool
  • SlushPool
  • ViaBTC

In the bitcoin network there are about 10,000 full bitcoin nodes.

 

Politics and Environmental Concerns

A thing of concern is that most of bitcoin mining pools are in China. This puts risk to the rest of the world in the case that China were to unify or have their pools collaborate together to force a 51% attack. Interestingly, the Chinese government has set regulations to restrict mining in China.

Another concern is the amount of computing power that is put into the bitcoin network. There is a substantial amount of energy being consumed by the mining rigs to keep the bitcoin network alive. Ironically the amount of energy needed to complete a new transaction in bitcoin, from Proof of Work to getting that new block disseminated throughout the network is significant. This brings up environmental concerns to supporting the bitcoin network.