The Alankrit Srivastava Blog

www.alankrit.net

  • Day 7 — If a Few People Control Mining, Is Bitcoin Still Decentralized?

    It might look like, from what has been discussed up to now, that Bitcoin is the perfectly balanced, fair and secure system. All transactions are verified by nodes, the miners compete to get their blocks added and their block reward, and this mechanism seems to keep the entire system running without anyone controlling it. But, if we look a little deeper, a problem can be spotted. The mining is a not easy operation. Specialized hardware and a lot of electricity is required for a process that, over time, becomes very competitive and exclusive. This begs the question, if mining becomes too expensive, won’t a small group of powerful miners take over?

    We can analyze the history of Bitcoin mining to understand how this came to be. When the Bitcoin system was launched, ordinary computers were enough for the mining activity. Everyone was able to run mining software on their PC and, eventually, gain a prize in BTC. Over time, with more participants involved, the difficulty of the cryptographic puzzle used to add blocks grew considerably. This made mining equipment very specialized and increasingly efficient machines, dedicated only to the Bitcoin mining. Gradually, mining went from a fun activity, or an extra income opportunity, to an industrial, large scale production process.

    As the race to mine bitcoins became more competitive, miners started to gather together, forming what are called “mining pools.” A mining pool consists of several miners who combine their computing resources and cooperate to solve the puzzle and achieve the mining of a new block. By pooling resources together, miners reduce the variability in their revenue, and can be paid more frequently than they could achieve alone. All mining pool members share the same amount of computing power that the pool has. When a block is successfully mined by the mining pool, the bitcoins obtained by that block reward are distributed proportionally among the members who provided the computer power.

    However, as more people join mining pools, we again see a problem: an increase of centralization of mining power. In fact, a single mining pool can easily possess a huge share of the Bitcoin network hash power and thus the capability of influencing the selection of the transactions to include into the block, or worse, the capability of launching a 51% attack on the network. An attack based on the 51% of the network computational power can even enable a user to rewrite the recent history of the Bitcoin block-chain. Fortunately enough, it’s nearly impossible to achieve a 51% attack due to its extreme cost. But the threat is still there and that might represent a weakness for the Bitcoin system itself.

    Although this tendency towards centralization does not completely ruin the system it must be said that, in fact, Bitcoin cannot become a centrally controlled system by few mining pools since any node of the network, no matter if he is a mining pool participant or not, is able to decide whether to consider a block valid or not, and if one mining pool starts to mine invalid block (by trying to fork the chain, for example) all the other nodes are supposed to stop mining it and continue to build up on a valid chain.

    We can thus observe that Bitcoin is a resilient system, resistant to external control thanks to the mechanism of independent nodes which validates blocks and miners which compete against each other. While the efficiency argument may make you think that Bitcoin could easily become a system controlled by few large organizations, its fundamental principles as well as economic reasons assure the decentralization that was at the heart of the project.

    This reveals us something important about Bitcoin. Despite the strength of its core design, it’s a system built to serve a purpose: transferring and storing value. As such, it does not support complex processes such as programmable agreements or distributed applications.

    The existence of such limitations opens a new question: would it be possible for the blockchain to do more than simply transfer value? Could it be used as a development platform to automate logic and build applications?

  • Day 6 — Who Actually Runs Bitcoin — And Why Do They Do It?

    By this point a natural question has begun to arise in the minds of the reader.

    If the Bitcoin system has no governing body, no bank, and no company running the show, then who is keeping the network alive and verifiable?

    Initially, it may seem that there must be some unseen hand secretly orchestrating things. This is far from the case however, Bitcoin’s maintenance is achieved through a collection of independent actors, from all over the world, each with different roles and different motivations.

    To properly understand this, we can break down Bitcoin participants into two key groups: nodes and miners.

    Nodes are the bedrock of the Bitcoin network. A node is simply a computer running the Bitcoin software which keeps a full or partial copy of the blockchain. Every time a new transaction is broadcast, it is independently checked against the network rules by a number of nodes around the world. The checks are made to ensure that the sender has the correct balance to make the transaction, that the transaction is properly signed, and that the same bitcoins are not being spent again. If any of these checks fail, then the transaction is rejected.

    What is fascinating about these nodes is that they gain no direct financial reward from checking transactions. This obviously begs the question why any individual would run a node at all.

    The motivation comes from ownership and trust. A node allows an individual to not have to rely on another party to verify the validity of transactions. They are then able to check the state of the network independently to ensure it is being governed correctly. For people, and organisations, who may own a significant amount of bitcoin this independence provides value because they are able to receive the ‘truth’ directly rather than through a third party.

    Thus, nodes act as the regulators of the network. They do not compete with each other or even necessarily know other participants, but they act to enforce the rules of Bitcoin. Any miner trying to submit an invalid block will find their attempt is rejected, no matter how much computational effort has gone into its creation, by nodes worldwide.

    Miners on the other hand are a different story. Whilst they run nodes to verify transactions and are required to do so for the system to function, their goal is different: they need to collect verified transactions into a block to present to the network and receive bitcoins in return. The miners have to do this by solving the computationally intensive problem that was discussed previously.

    Unlike nodes, miners do it for profit. They invest money in expensive computing hardware and have huge energy costs because the reward in Bitcoin and transaction fees is great enough to warrant such expenditure. This creates a competitive atmosphere, in which each miner will strive to be the first one to solve the computational puzzle in order to claim the next block.

    It is important to realise here that it does not matter if an individual’s computer is the fastest, the geographically closest, or has the best internet connection to solve the problem. Mining is a contest for the solution to a particular problem where each miner submits a ‘guess’ for the solution; with no knowledge of other people’s attempts. If your ‘guess’ is correct you win. Hence the higher the computational power of the computer the higher the number of guesses you can make and the more likely your answer is to be correct. Obviously smaller players can sometimes win as there is an element of chance involved.

    This leads us to an elegant balance in the network. Miners work hard to generate the coins and the rewards give them an incentive to spend a vast amount of energy. This in turn creates new blocks and transaction fees, but the network can still function with nodes even without them getting direct payment; their role is purely validation. Neither of these two groups controls the network and as long as people have an incentive, both miners and nodes will continue to exist and maintain the system.

    This is the process by which Bitcoin can exist without a central bank and without a managing body, by distributing power and by making money out of being involved with the system. But as a reward is given for mining a block, this suggests that a small amount of powerful actors will dominate the network. How will this impact the overall decentralization?

  • Day 5 — Why Would Anyone Spend Real Money to Mine Bitcoin?

    And we have now stumbled across the clever incentive structure at the heart of Bitcoin. As we learned, transactions are verified globally by a network, then added in blocks and appended to the blockchain through a competitive computational puzzle that requires extensive resources (in the form of specialized hardware, constant electricity, and some degree of patience) to solve. It doesn’t take a genius to realize that this leads to an obvious question. Who in their right mind would want to donate these real world resources (time, money, and energy) to operate this system?

    The answer comes down to the incentive layer:

    Bitcoin is constructed in such a way that participants contributing to the network are financially rewarded for their labor. When a miner successfully solves the computational puzzle and thus publishes their new block of transactions, they receive the reward of freshly created Bitcoins. Added to the reward of newly generated coins, a miner also gets a reward in the form of the transaction fees that their transactions collectively accumulate. These two rewards together motivate miners to expend their computational resources to participate in the system. Without this layer of incentive, it’s hard to imagine someone wanting to waste their resources on a system they don’t own.

    The brilliance of this construction is that it makes securing the network an economic activity. Miners are rational, self-interested agents making costs-benefits assessments. They invest in better machines, look for the cheapest source of electricity, and fiercely compete against each other for block rewards because it is the most plausible means to obtain the network’s currency. In doing so, Bitcoin turns security from a technical issue to an economic one. The network’s security relies on the financial interests of the network’s operators, rather than on assumptions about their honest intentions.

    To see why this system is so reliable, look at what happens when miners do try to cheat. A miner could include a fraudulent transaction, but once a block is submitted to the network, it will be individually verified by each other node. The block, which violates protocol rules, will be rejected very quickly. The cheated miner ends up wasting their entire computation and electricity expenditure, all for nothing. Miners who follow protocol rules, on the other hand, have a chance to earn rewards. It quickly becomes more economically feasible for miners to behave honestly rather than cheat.

    This system ensures the security of the network in yet another way: the larger the amount of computation invested, the more secure the system is. It is exponentially harder to perform enough computation to successfully “fork” the blockchain. This implies that it is far easier for thousands of people running inexpensive, specialized hardware for the benefit of the entire network, rather than for one entity to obtain enough computational power to disrupt the entire network.

    Finally, one other fundamental mechanism in Bitcoin to make sure that new Bitcoins are generated at a controlled rate, is its capped supply of new coins. In contrast to traditional currencies where their value is mostly regulated by monetary policy through the creation or destruction of cash (in the form of fiat money) by banks. In Bitcoin, however, new coins enter into circulation as a result of the mining process, and the rewarded number of new Bitcoins is decreased over time,halving itself, and that in turn controls the scarcity and therefore the perceived value.

    All in all, this entire system appears to be incredibly well balanced. Economic incentives are driving participation in securing the network, and the strict cryptographic rules guarantee the integrity of the transactions in the blocks. The decentralization of thousands of nodes globally contributes to the agreement on the ledger. Because there’s no trust placed in anyone or any organization, and simply placed in mathematical principles and economic incentives, people on Earth are allowed to engage in mutual agreements concerning a shared financial history without ever knowing each other personally.

    With the power and expense of mining growing ever so increasingly, we might start wondering if mining might ever centralize, causing the system to be not so decentralized after all.

    In our next post we discuss mining evolution, mining pools and how decentralization could survive against competing, ever-improving technologies.

  • Day 4 — The Puzzle That Keeps Bitcoin Honest

    So, we came to an interesting point here: miners are competing with each other in adding a new block to the blockchain, and to do so, they need to solve a computational puzzle. The miner who solves it first gets rewarded in Bitcoins. On first look this seems a little strange. Why does a financial system rely on solving puzzles, and what does solving puzzles have to do with sending money? It might seem unnecessary at first, but this is where it all starts.

    We need to look at what these miners are doing in the background. When a miner gets some transactions from the network, it bundles them all up together to form a “block” that can be added to the blockchain. This block contains a list of all these transactions as well as some extra data linking it to the previous block on the chain. So it’s not just an isolated lump of data, rather it’s just a further part of the blockchain, and is linked to previous bits of data in a way that forms continuity through the entire chain. However, in order for a miner to add this block to the blockchain, they have to work out what number can be combined with all of the other data in the block in such a way that a specific condition, set by the network, is met.

    This is where hashing is important. You can think of a hash as a digital finger-print for data. Any chunk of data can be put through a hashing function (whether it’s a sentence, a file or a block full of transactions) and we will get a seemingly random fixed length output. But the beauty of hashing functions is that they’re incredibly sensitive to change. If I alter the slightest bit of the data, even just changing one letter in a sentence, the hash will be completely different. This means every block can be given a fingerprint, based not only on the data inside it, but also the fingerprint of the block which precedes it. The chain becomes self linked.

    This makes the blockchain incredibly tamper evident. If I wanted to change a transaction in an earlier block, the hash would change, breaking the link between that block and the one following it. This would cascade through the entire blockchain, and it would become impossible to make any changes at all.

    However, what are miners actually solving? The network has one condition. In order to be considered valid, the hash of the block must meet a specific criteria (for instance, it must start with x amount of zeros). Although this sounds simple, it’s actually incredibly computationally difficult to figure out. There is no direct way to work this out, miners have to try out millions, or even trillions of possible inputs until they find a suitable one. They do this by changing a small value within the block known as a ‘nonce’, a value that when paired with the rest of the data in the block, is hashed repeatedly, over and over until a suitable result is found.

    It’s like trying to break into a combination lock without any numbers at all. It just requires brute force. When a miner does eventually find a valid block, they simply show it to the network. The other nodes can easily verify that it is a valid solution, and thus the block is added.

    This creates a disparity in ease; solving the problem is extremely computationally expensive, however verifying it is easy. This is part of what ensures Bitcoin is so secure. The cost in resources, meaning it’s effectively impossible for malicious users to disrupt the system. To alter an earlier transaction you’d have to carry out the same computational effort for that block and every block after it, plus beat everyone else on the network to it, and all of this at speed.

    This whole system is known as Proof of Work and ensures that a degree of effort is involved in the process of adding to the blockchain to make it resilient to attacks. Instead of relying on trust from a central party, Bitcoin uses mathematical functions.

    We now have the structure of the whole thing working; transactions get submitted, verified by various parties on the network and then grouped together by miners who then add the block to the blockchain through the process of Proof of Work. There’s no central entity involved and it works well.

    This leads nicely into one final, crucial question: If it takes such resources to mine blocks (time, electricity, computational power), what drives miners to do this work for the network?

  • Day 3 — Who Verifies Bitcoin Transactions If There Is No Bank?

    By now something about Bitcoin should start to feel a little bit strange. You send over some cash and it is logged in a global ledger, there is no bank and no one controlling the ledger, and it somehow all still works out. When you take a moment and think about that you will find that there is a nagging, awkward question: since there is no single entity approving the transactions, who is to stop people from cheating?

    In the traditional finance world there is always a central party to maintain trust. When you make an electronic transfer over a bank you are trusting that they are confirming you have the balance required, they are also verifying your identity and then the key point they are confirming you don’t double-spend your funds. Without these checks and balances it would be a simple matter for everyone to cheat and so you have a concept known as double-spending where people try to spend the same funds over two separate transactions.

    Bitcoin overcomes the double-spending problem in a quite peculiar way. Instead of replacing the central trusting party, they are instead distributing trust over thousands of independent parties. To simplify the idea think about what would happen if you put that many students in a classroom and had no teacher and no leader. Everyone would have their own little notebook where they record their transactions and when one student calls out that they want to make a transaction, all the other students would look in their notebook to verify if that student has enough funds or that it hasn’t already been transferred before. If it hadn’t, the transaction is recorded by everybody.

    Scale that up to the entire world and you will start to get a rough idea of how the bitcoin system works with thousands of computers called nodes constantly running and recording each transaction. When a transaction is announced to the entire network these nodes go and check that it isn’t trying to be double-spent or isn’t otherwise illegal, and then everyone adds that to their ledger. However it wouldn’t do any good for nodes to confirm all the transactions, the actual chain needs to be built somehow.

    That’s where miners come in. Miners are a specific group of people running on the network, they pick up all of the verified transactions and then try and bundle it into a block and be the one to add it to the blockchain. They don’t add the next block however simply by choosing which one they want it to be and because they want to, it has to be the one that solves a very hard problem. Whoever solves the computational puzzle first is rewarded with the new block (which contains new bitcoin), but the way that it’s done makes it so that only someone with more computational power than the rest of the network combined could manipulate the system.

    The problem and the system itself looks slightly convoluted but without both sides of this ‘verification’ and ‘miner’ equation the system wouldn’t work. However there is a more deep layer to all of this. You’ve heard of this computational puzzle the miners have to solve but what is this puzzle exactly and why is it so difficult? The puzzle lies at the center of Bitcoin’s security framework.

  • Day 2 — Where Did My Bitcoin Actually Go?

    Earlier, we came across an astonishing idea. It is possible to send money through the internet without any banks being involved. Instead of financial institutions verifying and storing transactions, it is through a network of global computers that a public ledger known as the blockchain is formed. It is only natural to ask an obvious question: Where do transactions go when you send Bitcoin to someone?

    As the answer is clear for the banking systems, if you make a transaction with your bank it simply adds this record to its own database and decrements from your balance while incrementing the recipient’s balance, all on a central bank server. However, for the Bitcoin network it is quite different. When you send Bitcoins, the transaction is broadcast to thousands of global computers that communicate among each other to maintain synchronized database of transactions.

    You could better understand this if you compare it to a Google Sheet where every single transaction of Bitcoin ever is recorded and every participant of the Bitcoin network holds a copy. Whenever a new transaction takes place, it gets added to all thousands of copies of this Sheet. Thus, if you send Bitcoin to your friend Rahul, it is declared to everyone in the network who then updates their copy of the global ledger.

    This ledger of all transactions is what is known as the blockchain. There is really nothing fancy about this word other than it represents a chain of records where records containing transactions are added in chunks called blocks. When a block becomes full, it gets added to the previous chain of records which can be said as creating a sequence of entries.

    An easy way to conceptualize the blockchain is to consider it as a diary page containing a group of transactions which are recorded after the specific time period expires, it is sealed and another page is started. Collectively, pages form a complete transaction history of the Bitcoin network.

    Once a block is formed and added to the chain, it becomes nearly impossible to edit it as the transaction will affect all subsequent blocks too; and that too is practically impossible with so many users in the network to coordinate that change in all of the blocks in the network at the same time. The transactions thus added are made publicly visible, though not linked with actual identities, which means everyone can see the entries on the blockchain and verify its integrity, but not the identities of individuals behind each transaction, rather strings of characters called wallet IDs will be displayed in place of them.

    The entire process is completely contrary to banking which uses its own private databases to maintain records which are then verified and managed solely by them. Here, the blockchain, which is public and open to everyone to verify, ensures a network that is transparent yet maintains privacy through a unique system of identity.

    But there is a remaining question; how does a particular set of transaction get verified, collected and formed into a block, linked and then recorded into the global blockchain? Well this task is designated to a group of users called miners who in return for their services are given Bitcoin as a reward. They are the ones who collect pending transactions, pack them into blocks and make them accessible to the whole network in return of mining new bitcoins.

  • Day 1 — I Sent Money Without a Bank. Wait… How Did That Even Work?

    A few years ago, if you wanted to send money to somebody, there were very few options. You could go to a bank, use internet banking, or just send money through a mobile app like Paytm, Google Pay or UPI. Mobile apps these days look extremely sleek and fast, but they only give the illusion. In the backend, every transaction ends up going to a bank. No matter how fast it feels or how short the time it takes, there is a bank somewhere in the middle making sure things check out.

    Lets take the example where you send Rs 500 to a friend. To you it feels like money is going directly to him, but in reality it isnt. Instead, you are asking the bank to change its database. Firstly, your bank checks if you have enough money (Rs 500). It then checks the validity of the destination bank account, checks the legality of the transaction, and then decrements the amount from your bank account while crediting it to your friend. To sum it up, it is nothing more than asking the bank to update its database from having balance X in your account, to balance X-500, and in the bank of your friend having a balance Y, to balance Y+500. This is how digital money works in the real world today and it has been working this way for decades – a middleman with trusted power.

    But things became strange in 2009. A man (or group of people) known only by the pseudonym Satoshi Nakamoto created a system which looked like just another form of digital money, but one crucial difference; it enabled the sending of money from one individual to another without a third party.

    This sounds like a contradiction in terms. If there is no bank verifying the transaction, then how will we be able to detect cheating? How do we know if you actually own the money which you are sending? And how do we stop one person from using the same digital money for multiple transactions? This was where many people became bewildered and honestly still are bewildered by this day and age.

    Lets imagine an everyday situation where you have to send some Bitcoins to your friend Rahul. Instead of opening a banking app, you would open something called a ‘crypto wallet’. A crypto wallet, however, does not actually store money in the sense of a physical wallet does storing cash. What it does is store certain cryptographic keys that give you access to funds, without which they cannot be touched or moved by anybody else.

    Each crypto wallet is associated with an address, called the ‘public address’ which can be thought of like an email address, but for your digital cash. Anyone in the world can send Bitcoins to this address. This address is usually a very long string of numbers and letters, which look very peculiar the first time you see it, but represent a destination in the Bitcoin network.

    So, when you are going to send your friend Rahul Bitcoins, you punch in his public address, the amount of Bitcoins you wish to send and when you hit ‘send’, your wallet announces the transaction to thousands of computers all across the world which are interconnected in the Bitcoin network.

    The interesting part is that this is where we depart from how banks operate. Instead of having a single entity like a bank to verify transactions, in the Bitcoin network, there are many computers all over the world which collectively verify each transaction on the basis of whether the transaction is legitimate, and the person sending money actually possesses the Bitcoins, and these Bitcoins have not already been spent elsewhere. The system is therefore able to verify if the transaction is legitimate or not.

    Where is it verified? It is verified in what is called a blockchain.

    A blockchain can be seen like a massive notebook that records all Bitcoin transactions in existence. For example, there could be entries in the notebook which are like “Alankrit sent 1 Bitcoin to Rahul”, “Rahul sent 0.5 Bitcoin to Sneha”, “Sneha sent 0.2 Bitcoin to Aman”, etc. And over time, as and when transactions occur, the notebook grows larger and larger.

    The key attribute of a blockchain is that, instead of one single notebook residing somewhere, there are thousands of copies all around the world, and whenever a transaction is made, all these thousand notebooks get updated. This makes altering the blockchain almost impossible as you would have to simultaneously alter a thousands of ledgers at the same time, and all these copies would have to be agreed upon. For example, imagine you are in a classroom and you and every single student in the class are keeping track of all transactions made by all students in a notebook. If, later on, a student decides to cheat by altering an entry in his notebook, all the other thousands of students in the class would easily detect this as his ledger will not match the notebooks of any other student. The system is thus reliable as many individuals maintain its integrity.

    And this is what distinguishes Bitcoin and all its descendant cryptos. For the very first time, individuals can make digital transactions without anyone’s approval and without a bank in between them. The whole system is powered by open source software and maintained by the users.

    However, it is now natural for a new question to arise: If banks are not verifying the transaction then who is and why should they do it for free?

    The answer is through what is called Bitcoin mining.

  • Day 1 – Warming Up With the Basics of JavaScript

    JavaScript begins with a few simple ideas that form the foundation of everything you’ll build later. Before diving into functions, loops, or DOM manipulation, it’s important to understand how JavaScript handles simple actions like printing output, storing data, and organizing related values. Today’s focus is on these essentials: logging messages, using constants and variables, understanding dynamic typing, working with arrays, and creating basic objects.

    The most fundamental operation is printing information to the console. JavaScript uses the console.log() function to display text or values, which is extremely useful during development. For example, writing console.log("Hello World"); prints the message to the console and helps you confirm that your code is running as expected.

    Another core concept is the difference between constants and variables. A constant is created using the const keyword, and once you assign a value to it, that value cannot be changed. For example, if you write const a = 10;, the number ten becomes fixed for the lifetime of the program. Trying to reassign it will immediately result in an error. This is useful when you want to ensure that a piece of data remains stable.

    Variables, on the other hand, are defined using the let keyword, and they allow you to change the value later. A variable such as let x = 10; can be reassigned to another number, or even to another type entirely. JavaScript is dynamically typed, which means a variable can start as a number and later hold a string like "ABC" without any issues. This flexibility is powerful but also requires attention, especially when dealing with operations like string concatenation. For instance, when a string and a number are added together using the + operator, JavaScript converts the number into a string and joins them, producing "ABC7".

    Arrays are another important building block. They allow you to group values together inside square brackets. An array like [2, 6, 100] stores three numbers, and you can access them using their index, such as arr[1] to retrieve the value 6. If you try to access a position that doesn’t exist—like arr[100]—JavaScript simply returns undefined instead of throwing an error.

    Arrays in JavaScript are also extremely flexible. They can hold values of different types, and they can even contain other arrays inside them. This means an array like [7, true, "abc", [2, 4, 6]] is completely valid. Accessing nested values is straightforward; for example, arr[3][1] retrieves the number 4 from the inner array. This ability to mix and nest values makes arrays ideal for representing structured information.

    Finally, JavaScript provides objects as a way to store related data using key–value pairs. An object such as:

    let obj = {
        name: "Sample Name",
        age: 29
    };

    groups related properties together. Accessing one of these values is done using dot notation—for example, obj.age returns 29. Objects are fundamental in JavaScript, forming the basis for everything from JSON data to browser APIs.

    These simple ideas—logging output, understanding constants and variables, handling dynamic typing, working with arrays, and creating objects—are the building blocks that every JavaScript program grows from. With this foundation in place, the next steps in learning JavaScript become much easier and more intuitive.

Built with ❤️ by Alankrit Srivastava