January 07, 2018

Blockchain technology and Bitcoin(Cryptocurrency)

Block Chain Technology

People use the term ‘blockchain technology’ to mean different things, and it can be confusing. Sometimes they are talking about The Bitcoin Blockchain, sometimes it’s other virtual currencies, sometimes it’s smart contracts. Most of the time though, they are talking about distributed ledgers, i.e. a list of transactions that is shared among a number of computers, rather than being stored on a central server. Current digital economy is based on the reliance on a certain trusted authority. Our all online transactions rely on trusting someone to tell us the truth it can be an email service provider telling us that our email has been delivered; it can be a certification authority telling us that a certain digital certificate is trustworthy; or it can be a social network such as Facebook telling us that our posts regarding our life events have been shared only with our friends or it can be a bank telling us that our money has been delivered reliably to our dear ones in a remote country. The fact is that we live our life precariously in the digital world by relying on a third entity for the security and privacy of our digital assets. The fact remains that these third party sources can be hacked, manipulated or compromised. This is where the blockchain technology comes handy.

What is a blockchain?

A blockchain is essentially a distributed database of records or public ledger of all transactions or digital events that have been executed and shared among participating parties. Each transaction in the public ledger is verified by agreement of a majority of the participants in the system. And, once entered, information can never be erased. The blockchain contains a certain and verifiable record of every single transaction ever made. 
Bitcoin, the decentralized peer to peer digital currency, is the most popular example that implements blockchain technology. The digital currency bitcoin itself is highly controversial but the underlying blockchain technology has worked perfectly and found wide range of applications in both financial and nonfinancial world.

A blockchain is just a file. A blockchain by itself is just a data structure. That is, how data is logically put together and stored. Other data structures are databases (rows, columns, and tables), text files, and comma separated values (csv), images, lists, and so on. You can think of a blockchain competing most closely with a database.
Books in a chain = pages in a book
      For analogy, a book is a chain of pages. Each page in a book contains:
       The text: for example the story.
       Information about itself: at the top of the page there is usually the title of the book and sometimes the chapter number or title; At the bottom is usually the page number which tells you where you are in the book. This ‘data about data’ is called Meta-data.
Similarly in a blockchain block, each block has:
The contents of the block, for example in bitcoin is it the bitcoin transactions, and the miner incentive reward to bitcoin miners (currently 25 BTC).
       A ‘header’ which contains the data about the block. In bitcoin, the header includes some technical information about the block, 
       A reference to the previous block, and a fingerprint (hash) of the data contained in this block, among other things. 
This hash is important for ordering.

Block ordering in a blockchain

Page by page. With books, predictable page numbers make it easy to know the order of the pages. If you ripped out all the pages and shuffled them, it would be     easy to put them back into the correct order where the story makes sense.
Block by block. With blockchains, each block references the previous block, not by ‘block number’, but by the block’s fingerprint, which is cleverer than a page number because the fingerprint itself is determined by the contents of the block.
The above figure shows visual representation of ordering of block in blockchain.

Internal consistency

       By using a fingerprint instead of a timestamp or a numerical sequence, you also get a nice way of validating the data. In any 
blockchain, you can generate the block fingerprints yourself by using certain algorithms. If the fingerprints are consistent with the data, and the fingerprints join up in a chain, then you can be sure that the blockchain is internally consistent. If anyone wants to meddle with any of the data, they have to regenerate all the fingerprints from that point forwards and the blockchain will look different. This means that if it is difficult or slow to create this fingerprint, then it can also be difficult or slow to re-write a blockchain. A peek inside a blockchain block: the fingerprints are unique to the block’s contents.
It has the potential to revolutionize the digital world by enabling a distributed agreement where each and every online transaction, past and present, involving digital assets can be verified at any time in the future. It does this without compromising the privacy of the digital assets and parties involved. The distributed agreement and secrecy are two important characteristics of blockchain technology.

Short History of Bitcoin

In year 2008, an individual or group writing under the name of Satoshi Nakamoto published a paper entitled “Bitcoin: A Peer-To-Peer Electronic Cash System”. This paper described a peer-to-peer version of the electronic cash that would allow online payments to be sent directly from one party to another without going through a financial institution (Bank, PayPal etc.). Bitcoin was the first realization of this concept. Now word cryptocurrencies is the label that is used to describe all networks and mediums of exchange that uses cryptography to secure transactions-as against those systems where the transactions are channeled through a centralized trusted entity.

The author of the first paper wanted to remain anonymous and hence no one knows Satoshi Nakamoto to this day. A few months later, an open source program implementing the new protocol was released that began with the Genesis block of 50 coins. Anyone can install this open source program and become part of the bitcoin peer-to-peer network. It has grown in popularity since then.


How does BlockChain work?

I am explaining the concept of the blockchain by explaining how Bitcoin works since it is fundamentally related to the Bitcoin. However, the blockchain technology is applicable to any digital asset transaction exchanged online.
Bitcoin uses cryptographic proof instead of the trust in the third party for two willing parties to execute an online transaction over the Internet. Each transaction is protected through a digital signature. Each transaction is sent to the “public key” of the receiver digitally signed using the “private key” of the sender. Each transaction is broadcast to every node in the Bitcoin network and is then recorded in a public ledger after verification. Every single transaction needs to be verified for validity before it is recorded in the public ledger. 
Verifying node needs to ensure two things before recording any transaction:

1. Spender owns the cryptocurrency—digital signature verification on the transaction.
2. Spender has sufficient cryptocurrency in his/her account: checking every transaction against spender’s account (“public key”) in the ledger to make sure that he/she has sufficient balance in his/her account.

In Figure you can see, if one wants to send a money to any other one first its amount of transaction and other details like address where to send the money means destination address along with source address and the public key for that transaction is represented in the form of block. This block is broadcast in the pool (Bitcoin network) where miners (or participating parties) approve the transaction is valid. After approval by miners the block can be added to the chain that provides permanent and see-through record of transactions and at the end money is received by destination.  

However, the question is that of maintaining the order for these transactions that are transmitted over the all the nodes in Bitcoin Network. There may be case where transaction do not come in order on which they are generated and for this reason we need a system to making sure that double spending cryptocurrency does not happen. Considering that the transactions are passed through network node by node, there is no guarantee of the order in which they are received at a node are the same is that of the transactions were generated.  

That means there is a need of mechanism so that entire Bitcoin network can agree about the order of transaction, which is overwhelming task in distributed system.
The Bitcoin solved this problem by a mechanism that is now popularly known as Blockchain technology. The bitcoin system orders transactions by placing them in groups called blocks and then linking these blocks through what is called Blockchain. The transactions in one block are considered to have happened at the same time. These blocks are linked to each-other (like a chain) in a proper linear, chronological order with every block containing the hash of the previous block.

November 30, 2017

Machine Learning and Application

What is Machine Learning

The goal of building systems that can adapt to their environments and learn from their experience has attracted researchers from many fields, including computer science, engineering, mathematics, physics, neuro science, and cognitive science.

To solve a problem on a computer, we need an algorithm. An algorithm is a sequence of instructions that should be carried out to transform the input to output. For example, one can devise an algorithm for sorting. The input is a set of numbers and the output is their ordered list. For the same task, there may be various algorithms and we may be interested in finding the most efficient one, requiring the least number of instructions or memory or both. For some tasks, however, we do not have an algorithm for example, to tell spam emails from legitimate emails. We know what the input is: an email document that in the simplest case is a file of characters. We know what the output should be: a yes/no output indicating whether the message is spam or not. We don't know how to transform the input to the output. What can be considered spam changes in time and from individual to individual.

A subfield of computer science and artificial intelligence (AI) that focuses on the design of systems that can learn from and make decisions and predictions based on data. Machine learning enables computers to act and make data-driven decisions rather than being explicitly programmed to carry out a certain task. Machine Learning programs are also designed to learn and improve over time when exposed to new data. Machine learning has been at the center of many technological advancements in recent years such as self-driving cars, computer vision and speech recognition systems. 

Machine learning is programming computers to optimize a performance criterion using example data or past experience. We have a model defined up to some parameters, and learning is the execution of a computer program to optimize the parameters of the model using the training data or past experience. The model may be predictive to make predictions in the future, or descriptive to gain knowledge from data, or both. It uses the theory of statistics in building mathematical models, because the core task is making inference from a sample. The role of computer science is in two ways: First one is in training, we need efficient algorithms to solve the optimization problem, as well as to store and process the massive amount of data we generally have. Second is, once a model is learned, its representation and algorithmic solution for inference needs to be efficient as well. In certain applications, the efficiency of the learning or inference algorithm, namely, its space and time complexity, may be as  important as its predictive accuracy.