Friday, August 12, 2016

Blockchain Technology Explained: Powering Bitcoin

Microsoft recently became the latest big name to officially associate with Bitcoin, the decentralized virtual currency. However, the Redmond company did not go all out, and will only support bitcoin payments on certain content platforms, making up a tiny fraction of its business.

What’s The Big Deal With Bitcoin?

Like most good stories, the bitcoin saga begins with a creation myth. The open-source cryptocurrency protocol was published in 2009 by Satoshi Nakamoto, an anonymous developer (or group of bitcoin developers) hiding behind this alias. The true identity of Satoshi Nakamoto has not been revealed yet, although the concept traces its roots back to the cypher-punk movement; and there’s no shortage of speculative theories across the web regarding Satoshi’s identity.
Bitcoin spent the next few years languishing, viewed as nothing more than another internet curiosity reserved for geeks and crypto-enthusiasts. Bitcoin eventually gained traction within several crowds. The different groups had little to nothing in common – ranging from the gathering fans, to black hat hackers, anarchists, libertarians, and darknet drug dealers; and eventually became accepted by legitimate entrepreneurs and major brands like Dell, Microsoft, and Newegg.
While it is usually described as a “cryptocurrency,” “digital currency,” or “virtual currency” with no intrinsic value, Bitcoin is a little more than that.
Bitcoin is a technology, and therein lies its potential value.

This is why we won’t waste much time on the basics – the bitcoin protocol, proof-of-work, the economics of bitcoin “mining,” or the way the bitcoin network functions. Plenty of resources are available online, and implementing support for bitcoin payments is easily within the realm of the smallest app developer, let alone heavyweights like Microsoft.
This tutorial explains blockchain, the bitcoin technology.

Looking Beyond The Hype - Into The Blockchain

So what is blockchain? Bitcoin blockchain is the technology backbone of the network and provides a tamper-proof data structure, providing a shared public ledger open to all. The mathematics involved are impressive, and the use of specialized hardware to construct this vast chain of cryptographic data renders it practically impossible to replicate.
All confirmed transactions are embedded in the bitcoin blockchain. Use of SHA-256 cryptography ensures the integrity of the blockchain applications – all transactions must be signed using a private key or seed, which prevents third parties from tampering with it. Transactions are confirmed by the network within 10 minutes or so and this process is handled by bitcoin miners. Mining is used to confirm transactions through a shared consensus system, and usually requires several independent confirmations for the transaction to go through. This process guarantees random distribution and makes tampering very difficult.
This diagram explains bitcoin blockchain and how it works.
While it is theoretically possible to compromise or hijack the network through a so-called 51% attack the sheer size of the network and resources needed to pull off such an attack make it practically infeasible. Unlike many bitcoin-based businesses, the blockchain network has proven very resilient. This is the result of a number of factors, mainly including a large investment in the bitcoin mining industry.
Blockchain technology works, plainly and simply, even in its bitcoin incarnation. A cryptographic blockchain could be used to digitally sign sensitive information, and decentralize trust; along with being used to develop smart contracts and escrow services, tokenization, authentication, and much more. Blockchain technology has countless potential applications, but that’s the problem – the potential has yet to be realized. Accepting bitcoin payments for Xbox in-game content or a notebook battery doesn’t even come close.
So what about that potential? Is anyone taking blockchain technology seriously?

Welcome To The Wild-Wild West

Bitcoin and blockchain technology are certainly “out there,” and some developers view them as the next frontier. Developing a use case for bitcoin and blockchain technology applications could prove profitable in the long run, and many are eager to enter the space.
Throw an unregulated, pseudo-anonymous currency into the mix and you have the qualifications for a proper gold rush, backed by speculators and venture capitalists. Selling shovels is the best way to make money in a gold rush, and the bitcoin mining industry has that aspect covered too. It all sounds a bit like a “Wild West Boomtown”, with trigger-happy whisky guzzling outlaws on the prowl for a quick buck - certainly not an environment for the faint of heart.
So what on earth are Paul from IBM and Dominic from Bosch doing in the saloon, dressed like Marty McFly in Back to the Future III?
It’s simple – they are both getting a head start!
Both, Bosch and IBM, are looking into ways of harnessing blockchain technology as part of their Internet-of-Things (IoT) development programs. They are not alone either - remember Microsoft? A few days after Microsoft made its original bitcoin announcement, the company said it was also interested in the technology behind bitcoin for distributed, connected devices (or IoT devices).
Samsung is on board as well, and the Korean consumer electronics giant showed off blockchain tech at CES 2015, alongside IBM.

Forbes recently looked into the matter and made a bold prediction – the business magazine concluded that based on how blockchain technology works, it would likely break free from bitcoin to power distributed apps sometime this year.
In fact, many bitcoin developers are already working on so-called bitcoin 2.0 or bitcoin 3.0 projects. These often have little to do with the original concept, although they usually use some sort of token currency.Ethereum is one example – it is built around blockchain technology, but the emphasis is on smart contracts rather than surrogate currencies. IBM and Samsung are employing Ethereum for their IoT projects. Some of the same people involved in Ethereum development are working on another project, dubbed Storj, a fully distributed peer-to-peer cloud storage network with end-to-end encryption.

Potential Uses And Implications Of Blockchain Technology

There are already thousands of developers and dozens of companies experimenting with blockchain applications, but we have yet to see large scale projects built around blockchain technology that are not bitcoin or “altcoin” related. IoT could bring blockchain technology to the masses. Research firm IDC expects the user base to grow at a compound annual growth rate (CAGR) of 17.5% this decade, with up to 28.1 billion IoT devices in the wild by 2020, and revenue passing the $7 trillion mark the same year.
The technology is out there, it works, it’s free, and a lot of smart people are tinkering with it. However, so far these alternate blockchain applications have ranged from practical jokes to small experimental projects. The fledgling technology is still in its infancy, and this is to be expected.
The potential is more or less obvious. Decentralizing trust is a big thing, allowing the creation of vast, secure networks without a single point of failure. You can think of them as an additional layer of the internet, a layer that can be used for authentication, signage, secure communications and content distribution, financial transactions and much more.
Blockchain technology could allow developers a simple way of outsourcing security. For example, instead of creating secure IoT devices and networks, much of the heavy lifting could be effectively offloaded to the blockchain, freeing up resources on the client’s side and speeding up development.

The elusive goal for all blockchain developers is to make the technology just as seamless and unobtrusive as internet protocols. For example, how many people realize they are using TCP/IP every time they start browsing the net? This is the ultimate goal - to make the use of blockchain technology invisible to the end user. Blockchain technology can become yet another layer added to various products and services in order to provide more functionality and security, while saving resources and developer man-hours.
This article was written by NERMIN HAJDARBEGOVICa Toptal Technical Editor.

Thursday, July 14, 2016

Mobile Banking: Apple Pay vs. Android Pay vs. Samsung Pay

Smartphones have turned into the Swiss Army knife of the tech world, enabling millions of people to take care of countless computing needs on the go, and mobile payments are another frontier. The hardware is ready and software is not far behind, so what’s the hold up?
Well, in order to make mobile payments a reality, tech companies have to jump through a number of technological and regulatory hoops, plus, they have to wait for various other industries to get in line, as well. Apple, Google and Samsung are heavyweights and trendsetters, but that does not mean they are able to force banks, credit card companies, and merchants to play their game.
Today, we will be taking a look at the future of mobile payments and emerging opportunities for developers. Needless to say, with each new opportunity, developers will have to face new challenges. However, since we are talking about money, I don’t think anyone expects a shortage of software developers eager to learn a few new tricks and get into this space.

Apple Pay vs. Android Pay vs. Samsung Pay

Let’s start with a quick overview of the most promising mobile payments platforms out there.
There’s money to be made in mobile payments, so Apple, Google and Samsung are eager to get on board.There’s money to be made in mobile payments, so Apple, Google and Samsung are eager to get on board.
Apple Pay hardly needs an introduction at this point, but I should note that it’s still the new kid on the block. Apple limited the initial rollout to North America, so it will be a while before users around the globe get a chance to pay for their coffee with their iPhone.
Samsung fired back with the announcement of Samsung Pay during the Galaxy S6 launch event. Like Apple’s service, Samsung’s payment solution is limited to its own hardware, but it has a few neat tricks up its sleeve. My favourite is Magnetic Secure Transmission (MST), which was integrated following the acquisition of LoopPay. This clever technology allows compatible Samsung phones to emit a magnetic field that simulates the swiping of a “magstrip” card, fooling the card reader into thinking a card was swiped. In theory, it should enable the use of Samsung Pay on legacy point of sale (POS) devices, which were designed and deployed long before mobile payments became a reality.
Android Pay is launching in North America as we speak, and being vendor-agnostic, it should work on a majority of Android devices. Users will just need a phone running Android 4.4.x KitKat or later, along with Near Field Communication (NFC) support. Google claims NFC is already present in about 70 percent of potentially compatible phones. NFC integration took a while, bearing in mind that Google first deployed the technology into the good old Nexus S, which launched in late 2011. The latest versions of Android, iOS, and Windows support biometric security as well, which should help.
In many respects, Apple Pay, Android Pay, and Samsung Pay are similar; the underlying idea is the same, the implementation is similar, and the goal is to enable virtually any consumer to use these services, which means they have to be fool proof or fail. They rely on tokenization to eliminate sensitive data transfers. If you are familiar with Google Wallet, you probably know that it does not rely on tokenization. However, Android Pay still shares some solutions used in Google Wallet. For example, both rely on Host Card Emulation (HCE), while Apple Pay employs a Secure Element (SE) to protect sensitive information. Both HCE and SE have certain advantages, and you can check out this quick comparison for more info.
Secure Element and HCE are two very different ways of protecting sensitive information.Secure Element and HCE are two very different ways of protecting sensitive information.
Looking at the feature set and market support, each platform – Android Pay, Apple Pay and Samsung Pay – has something going for it. Apple Pay relies on a large and loyal consumer base running homogenous hardware. Samsung’s trump card is MST. Android Pay will be available on more devices than Apple Pay and Samsung Pay combined, but, for the moment, it will have to deal with heterogeneous hardware. You can probably see what I am aiming at here: If we had one mobile payments standard that covered all of the above, we would probably see faster market adoption.

The Problem With Mobile Payments

So what are the big challenges for these systems? Security, privacy, and consumer trust, along with time-to-market and market adoption.
While consumers may get a new phone every two years or so, merchants don’t replace their POS infrastructure as often. This means they are stuck with the same hardware for years. Banks, credit card companies and payment rail operators need to force an upgrade. And this brings up another problem: If a merchant in Ottawa or Seattle gets a lot of consumer demand for NFC-enabled POS terminals, he or she will contact the credit card company. To stay competitive, merchants will need new hardware to keep up with demand. However, what happens in Lagos or Buenos Aires? Not much, because demand won’t pick up for a while, and the infrastructure won’t be ready for years.
In my opinion, the lack of a coherent mobile payments infrastructure strategy is the biggest problem facing the industry. It may take years for all the pieces of the puzzle to fall into place. As usual, developed markets will lead the way, while developing countries will be slow to catch up.
The fact of having three different, yet similar, platforms endorsed by three tech giants, is another problem. It will slow down adoption, and depending on how easy it is to migrate from one platform to another, it may lock in users who simply can’t be bothered to switch. Make no mistake, mobile payments services will be big money makers for those who end up controlling the market. Google Wallet transactions, reportedly, did not generate a profit, and Google was losing cash on each transaction. However, imagine a billion smartphone users paying for everything with their mobile phones, now imagine that you skim off just a couple of dollars off their transaction fees each year. That sounds like a nice little money maker, does it not? Analysts are still divided, but most are bullish on Apple Pay’s prospects. It’s safe to assume that rivals will not cede this potentially lucrative market to Apple, and I expect a number of players will emerge, especially from big, regional markets like China and India.
Mobile payments will be a hotly contested space, and strong competition could be a double-edged sword.
Security and regulatory concerns are another problem. Although a lot of time and effort will go into making these systems secure, sooner or later, cybercriminals will catch up and come up with inventive ways of bleeding reckless consumers dry. Yes, I said it, mobile payments will never be totally secure no matter what tech companies do. Sooner or later, someone will figure out a way of scamming people out of their money. However, looking at the broader picture, I don’t think this will be a huge concern. Credit card fraud is still widespread, and people still get mugged in dark alleys. Criminals will simply shift their focus.
Mobile payments could help curb street crime, but what about cybercrime?Mobile payments could help curb street crime, but what about cybercrime?
Besides, if you ever find yourself $100 out of pocket over a mobile payments hack (or fraud), consider this: That’s still better than being robbed of $100 at knifepoint.
Regulation will also have to catch up with mobile payments, and this may take a while. Since we are not a law firm, I won’t get into this particular problem. Let’s just let lawmakers and lawyers figure it out. That usually works, sort of.

The Mobile Payments Revolution Is Just Getting Started

So what does the advent of services like Samsung Pay, Apple Pay and Android Pay mean for developers? It is still too early to make a definitive call, because the services really aren’t out yet.
Technically, Apple Pay is alive and kicking, but it’s limited to certain markets. However, the list of Apple Pay partners is growing, albeit international adoption is likely to remain slow. A couple of weeks ago, Samsung announced that the Samsung Pay beta is live in the US, but users can try it out only if they have a “special invite.” Android Pay has not launched yet, but recent leaks suggest it should launch in the second half of September 2015.
Of course, Apple Pay, Samsung Pay and Android Pay aren’t the only services out there. We are seeing new ones developed by established players, such as MasterCard and PayPal, but we are also seeing ancillary services created by startups like Square.
It looks like it will take a few quarters, or even a couple of years, for all three services to mature and gain mainstream adoption. However, I believe it’s time for developers to start considering the implications of the upcoming mobile payments revolution.
These will be the key drivers pushing mobile payments adoption:
  • Convenience
  • Once consumers try contactless payments, they don’t go back
  • Speed will create new use cases
  • Reduced exposure to risk
  • Mass availability
Convenience is the driving force behind mobile payments. Why mess around with cards if you can pay for stuff with your mobile phone? The fact that other cards, such as loyalty bonus cards issued by merchants, can be integrated into digital wallets, is another possibility. Who doesn’t want to carry around fewer cards in their wallet?
Although contactless payments are a relatively new concept, it appears that users who get hooked never look back. In a recent interview with Fortune, MasterCard Chief Emerging Payments officer Ed McLaughlin said people who tap to pay more than two or three times “don’t go back to their prior behaviour,” due to the speed and convenience of contactless payments.
However, this does not mean that mobile payments will merely replace existing card transactions. The newfound convenience is likely to create more use cases for digital payments because they could supplant cash transactions in many situations.
This brings up another point that doesn’t have much to do with technology. If a mobile phone with loads of cards is lost, all the user needs to do to render them useless is to destroy the security tokens. There is no need to replace the cards, which is a hassle. Use of tokenized mobile payments solutions will also reduce the need to protect data on the retailer side, thus reducing operating costs and reputational risk in case of data breach (insert Ashley Madison reference here).
That’s not all. Less cash in physical wallets and cash registers also means less crime. What’s the point of stealing a wallet if all the thief will find in it is some change, a driver’s license and a gym membership card? Why would armed robbers bother holding up a gas station or convenience store if there is simply next to no cash to steal? Of course, there is always the risk that someone could somehow breach all the security layers and steal your money digitally. However, this would really raise the bar for the average criminal.
Apple Pay, Android Pay and Samsung Pay are small but important steps toward a cashless economy.Apple Pay, Android Pay and Samsung Pay are small but important steps toward a cashless economy.
Mass availability will be tricky. It might not be a fast process, especially in emerging markets, but once the infrastructure is in place, we will see rapid growth. Deloitte predicts that 2015 will be a watershed moment for the industry.
In a research note, the financial giant said:
“Deloitte expects that 2015 will be an inflection point for the usage of mobile phones for NFC-enabled in-store payment, as it will be the first year in which the multiple prerequisites for mainstream adoption – satisfying financial institutions, merchants, consumers, technology vendors and carriers – are sufficiently addressed.”

Mobile Payments For Developers

But what do Apple Pay, Android Pay, Samsung Pay and other mobile payments platforms mean for the average mobile developer?
There are a number of ways mobile payments will become a part of our everyday lives:
  • Integration into existing products and services
  • Further evolution of “click-and-mortar” business models
  • Creation of alternative services built on top of mobile payments platforms
  • Development of entirely new use cases for mobile payments
The first point is the most obvious one, and I suspect it will have the biggest impact on software development. I won’t be discussing the technical side of integrating mobile payments into existing applications, or new ones; the process is well-documented, so you can head over the Google and check out the official Android API tutorial. Google also offers information on user flows, process flow diagrams, a quick integration overview, UI branding requirements, and best practices. Apple also has a number of resources covering Apple Pay, including the official Apple Pay Programming Guide, app review guidelines, identity guidelines, iOS UI guidelines and more.
The question is, how many businesses will decide to integrate mobile payments into their existing mobile apps over the next few years? Since industry leaders will ensure the process is straightforward, I don’t think there will be many technical challenges to overcome. Get the APIs, follow the guides, and that’s it; it’s a bit like integrating any other payment option.
Integration will cover retail, e-tail, and, in some cases, in-app payments. The hope is that seamless, one-tap payments will help increase conversion rates, at least that’s what tech companies are saying to attract businesses.
However, unlike m-commerce, which already relies on a host of digital payment options, traditional retail will stand to gain more from new mobile payments platforms. We already use PayPal to buy stuff online, but what about the sandwich shop down the street, furniture shops, gas stations and so on?
Mobile payments will blur the line between retail and m-commerce, turning brick-and-mortar retailers into click-and-mortar businesses.Mobile payments will blur the line between retail and m-commerce, turning brick-and-mortar retailers into click-and-mortar businesses.
The trend of blurring the lines between traditional brick-and-mortar retail and online commerce is sometimes referred to as “click-and-mortar.” It’s a broad concept, dealing with goods bought online and picked up in retail locations, use of price comparison engines in physical stores (to make sure you are getting a good deal), or plain browsing through malls, to see how a product actually looks and feels before you go home and make an online purchase. Sure, all of us buy books, gadgets and hardware components online, but what about shoes, pants, or office chairs? That’s stuff most people prefer to try beforehand. A purchase would usually involve a cash or card transaction, but with mobile payments, it becomes another fully digital transaction.
So far, we’ve dealt with a few ways mobile payments will change how existing businesses operate, but what about entirely new use cases? What about new services resulting from the integration of mobile payments platforms in our smartphones and wearables? This will likely be the next niche to emerge: A space for innovation and the creation of a new generation of killer apps, piggybacking the new mobile payments infrastructure. I think it’s still too early to say what sort of concepts could be built on top of services like Apple Pay and Android Pay. Besides, if I had any good ideas, I would be busy recruiting talent to make such a service a reality, and I definitely wouldn’t be writing about it in a blog post.

Who Will Win The Mobile Payments Race?

They all want a slice of the pie, but the pie is huge and there is enough to go around. Apple Pay, Android Pay, Samsung Pay and other competing platforms should have no trouble gaining market share and turning a profit for their parent companies (unlike Google Wallet).
Ultimately, this is good news for everyone, from regular consumers who want a safer and faster way of spending money, to tech and financial giants that will reap the benefits and make a handsome profit.
The software industry will need to cater to all needs and address all mobile payment platforms that gain a sufficient market share in a given region. For example, if you want to develop an app for North American consumers, you should have no trouble integrating all the popular platforms. However, if you want to target China, you will probably have to tap local alternatives as well (let’s say solutions offered by major Chinese mobile brands and retail giants like Xiaomi, Huawei, Meizu and Alibaba’s Alipay).
I doubt anyone, including Google and Apple, could monopolise this niche; there is simply too much at stake, so entrepreneurs and governments will rush to promote region-specific mobile payments solutions. Why should Apple shareholders make money on transactions executed in China, why should Brazilians pay a fraction of each transaction to Google? That’s something politicians and regulators will need to deal with, but it might have an impact on market adoption and fragmentation.
In any case, I think the takeaway should be clear: It’s time to start looking into mobile payments and getting ready to integrate them. While progress is slow, market research suggests we will see a lot of growth moving forward, which means developers will have no choice but to hop on board. Keep track of new developments, check out the official documentation and get ready to integrate mobile payments; it’s as simple as that.
This article was written by  NERMIN HAJDARBEGOVICa Toptal Technical Editor.

Friday, July 8, 2016

Cryptocurrency for Dummies: Bitcoin and Beyond

Bitcoin created a lot of buzz on the Internet. It was ridiculed, it was attacked, and eventually it was accepted and became a part of our lives. However, Bitcoin is not alone. At this moment, there are over 700 AltCoin implementations, which use similar principles of CryptoCurrency.
So, what do you need to create something like Bitcoin?
Without trying to understand your personal motivation for creating a decentralized, anonymous system for exchanging money/information (but still hoping that it is in scope of moral and legal activities), let’s first break down the basic requirements for our new payment system:
  1. All transactions should be made over the Internet
  2. We do not want to have a central authority that will process transactions
  3. Users should be anonymous and identified only by their virtual identity
  4. A single user can have as many virtual identities as he or she likes
  5. Value supply (new virtual bills) must be added in a controlled way

Decentralized Information Sharing Over Internet

Fulfilling the first two requirements from our list, removing a central authority for information exchange over the Internet, is already possible. What you need is a peer-to-peer (P2P) network.
Information sharing in P2P networks is similar to information sharing among friends and family. If you share information with at least one member of the network, eventually this information will reach every other member of the network. The only difference is that in digital networks this information will not be altered in any way.
Cryptocurrency and Toptal
You have probably heard of BitTorrent, one of the most popular P2P file sharing (content delivery) systems. Another popular application for P2P sharing is Skype, as well as other chat systems.
Bottom line is that you can implement or use one of the existing open-source P2P protocols to support your new cryptocurrency, which we’ll call Topcoin.


To understand digital identities, we need to understand how cryptographic hashing works. Hashing is the process of mapping digital data of any arbitrary size to data of a fixed size. In simpler words, hashing is a process of taking some information that is readable and making something that makes no sense at all.
You can compare hashing to getting answers from politicians. Information you provide to them is clear and understandable, while the output they provide looks like random stream of words.
P2P Protocols
There are a few requirements that a good hashing algorithm needs:
  1. Output length of hashing algorithm must be fixed (a good value is 256 bytes)
  2. Even the smallest change in input data must produce significant difference in output
  3. Same input will always produce same output
  4. There must be no way to reverse the output value to calculate the input
  5. Calculating the HASH value should not be compute intensive and should be fast
If you take a look at the simple statistics, we will have a limited (but huge) number of possible HASH values, simply because our HASH length is limited. However, our hashing algorithm (let’s name it Politician256) should be reliable enough that it only produces duplicate hash values for different inputs about as frequently as a monkey in a zoo manages to correctly type Hamlet on a typewriter!
If you think Hamlet is just a name or a word, please stop reading now, or read about the Infinite Monkey Theorem.

Digital Signature

When signing a paper, all you need to do is append your signature to the text of a document. A digital signature is similar: you just need to append your personal data to the document you are signing.
If you understand that the hashing algorithm adheres to the rule where even the smallest change in input data must produce significant difference in output, then it is obvious that the HASH value created for the original document will be different from the HASH value created for the document with the appended signature.
A combination of the original document and the HASH value produced for the document with your personal data appended is a digitally signed document.
And this is how we get to your virtual identity, which is defined as the data you appended to the document before you created that HASH value.
Next, you need to make sure that your signature cannot be copied, and no one can execute any transaction on your behalf. The best way to make sure that your signature is secured, is to keep it yourself, and provide a different method for someone else to validate the signed document. Again, we can fall back on technology and algorithms that are readily available. What we need to use is public-key cryptography also known asasymmetric cryptography.
To make this work, you need to create a private key and a public key. These two keys will be in some kind of mathematical correlation and will depend on each other. The algorithm that you will use to make these keys will assure that each private key will have a different public key. As their names suggest, a private key is information that you will keep just for yourself, while a public key is information that you will share.
If you use your private key (your identity) and original document as input values for the signing algorithm to create a HASH value, assuming you kept your key secret, you can be sure that no one else can produce the same HASH value for that document.
How Bitcoin and Cryptocurrency works
If anyone needs to validate your signature, he or she will use the original document, the HASH value you produced, and your public key as inputs for the signature verifying algorithm to verify that these values match.

How to send Bitcoin/Money

Assuming that you have implemented P2P communication, mechanisms for creating digital identities (private and public keys), and provided ways for users to sign documents using their private keys, you are ready to start sending information to your peers.
Since we do not have a central authority that will validate how much money you have, the system will have to ask you about it every time, and then check if you lied or not. So, your transaction record might contain the following information:
  1. I have 100 Topcoins
  2. I want to send 10 coins to my pharmacist for the medication (you would include your pharmacists public key here)
  3. I want to give one coin as transaction fee to the system (we will come back to this later)
  4. I want to keep the remaining 89 coins
The only thing left to do is digitally sign the transaction record with your private key and transmit the transaction record to your peers in the network. At that point, everyone will receive the information that someone (your virtual identity) is sending money to someone else (your pharmacist’s virtual identity).
Your job is done. However, your medication will not be paid for until the whole network agrees that you really did have 100 coins, and therefore could execute this transaction. Only after your transaction is validated will your pharmacist get the funds and send you the medication.

Miners - New Breed of Agents

Miners are known to be very hard working people who are, in my opinion, heavily underpaid. In the digital world of cryptocurrency, miners play a very similar role, except in this case, they do the computationally-intensive work instead of digging piles of dirt. Unlike real miners, some cryptocurrency miners earned a small fortune over the past five years, but many others lost a fortune on this risky endeavour.
Miners are the core component of the system and their main purpose is to confirm the validity of each and every transaction requested by users.
In order to confirm the validity of your transaction (or a combination of several transactions requested by a few other users), miners will do two things.
First, they will rely on the fact that “everyone knows everything,” meaning that every transaction executed in the system is copied and available to any peer in the network. They will look into the history of your transactions to verify that you actually had 100 coins to begin with. Once your account balance is confirmed, they will generate a specific HASH value. This hash value must have a specific format; it must start with certain number of zeros.
There are two inputs for calculating this HASH value:
  1. Transaction record data
  2. Miner’s proof-of-work
Considering that even the smallest change in input data must produce a significant difference in output HASH value, miners have a very difficult task. They need to find a specific value for a proof-of-work variable that will produce a HASH beginning with zeros. If your system requires a minimum of 40 zeros in each validated transaction, the miner will need to calculate approximately 2^40 different HASH values in order to find the right proof-of-work.
Once a miner finds the proper value for proof-of-work, he or she is entitled to a transaction fee (the single coin you were willing to pay), which can be added as part of the validated transaction. Every validated transaction is transmitted to peers in the network and stored in a specific database format known as theBlockchain.
But what happens if the number of miners goes up, and their hardware becomes much more efficient? Bitcoin used to be mined on CPUs, then GPUs and FPGAs, but ultimately miners started designing their own ASIC chips, which were vastly more powerful than these early solutions. As the hash rate goes up, so does the mining difficulty, thus ensuring equilibrium. When more hashing power is introduced into the network, the difficulty goes up and vice versa; if many miners decide to pull the plug because their operation is no longer profitable, difficulty is readjusted to match the new hash rate.

Blockchain - The Global Cryptocurrency Ledger

The blockchain contains the history of all transactions performed in the system. Every validated transaction, or batch of transactions, becomes another ring in the chain.
So, the Bitcoin blockchain is, essentially, a public ledger where transactions are listed in a chronological order.
The first ring in the Bitcoin blockchain is called the Genesis Block
To read more about how the blockchain works, I suggest reading Blockchain Technology Explained: Powering Bitcoin, by Nermin Hajdarbegovic.
There is no limit to how many miners may be active in your system. This means that it is possible for two or more miners to validate the same transaction. If this happens, the system will check the total effort each miner invested in validating the transaction by simply counting zeros. The miner that invested more effort (found more leading zeros) will prevail and his or her block will be accepted.

Controlling The Money Supply

The first rule of the Bitcoin system is that there can be a maximum of 21,000,000 Bitcoins generated. This number has still not been achieved, and according to current trends, it is thought that this number will be reached by the year 2140.
This may cause you to question the usefulness of such a system, because 21 million units doesn’t sound like much. However, Bitcoin system supports fractional values down to the eight decimal (0.00000001). This smallest unit of a bitcoin is called a Satoshi, in honor of Satoshi Nakamoto, the anonymous developer behind the Bitcoin protocol.
New coins are created as a reward to miners for validating transactions. This reward is not the transaction feethat you specified when you created a transaction record, but it is defined by the system. The reward amount decreases over time and eventually will be set to zero once the total number of coins issued (21m) has been reached. When this happens, transaction fees will play a much more important role since miners might choose to prioritize more valuable transactions for validation.
Apart from setting the upper limit in maximum number of coins, the Bitcoin system also uses an interesting way to limit daily production of new coins. By calibrating the minimum number of leading zeros required for a proof-of-work calculation, the time required to validate the transaction, and get a reward of new coins, is always set to approximately 10 minutes. If the time between adding new blocks to the blockchain decreases, the system might require that proof-of-work generates 45 or 50 leading zeros.
So, by limiting how fast and how many new coins can be generated, the Bitcoin system is effectively controlling the money supply.

Start “Printing” Your Own Currency

As you can see, making your own version of Bitcoin is not that difficult. By utilizing existing technology, implemented in an innovative way, you have everything you need for a cryptocurrency.
  1. All transaction are made over the Internet using P2P communication, thus removing the need for a central authority
  2. Users can perform anonymous transactions by utilizing asynchronous cryptography and they are identified only by their private key/public key combination
  3. You have implemented a validated global ledger of all transactions that has been safely copied to every peer in the network
  4. You have a secured, automated, and controlled money supply, which assures the stability of your currency without the need of central authority
One last thing worth mentioning is that, in its essence, cryptocurrency is a way to transfer anonymous value/information from one user to another in a distributed peer-to-peer network.
Consider replacing coins in your transaction record with random data that might even be encrypted using asynchronous cryptography so only the sender and receiver can decipher it. Now think about applying that to something like the Internet Of Things!
A cryptocurrency system might be an interesting way to enable communication between our stove and toaster.
A number of tech heavyweights are already exploring the use of blockchain technology in IoT platforms, but that’s not the only potential application of this relatively new technology.
If you see no reason to create an alternative currency of your own (other than a practical joke), you could try to use the same or similar approach for something else, such as distributed authentication, creation of virtual currencies used in games, social networks, and other applications, or you could proceed to create a new loyalty program for your e-commerce business, which would reward regular customers with virtual tokens that could be redeemed later on.
This article was written by Demir Selmanovic, a Toptal Javascript developer.

Design by Lasantha