Browsing Category

Tutorial

Explanations on how things work, general knowledge base

israel-palacio-778505-unsplash

The Bitcoin Lightning Network

The bitcoin lightning network is a p2p network built on top of and uses the bitcoin blockchain. In order to use it you need to download and install some new software. It aims to solve the 7 transactions per second issue which, if bitcoin were to become mainstream, would never happen due to it’s low throughput rate. Theoretically the lightning network can handle millions of transactions per second. Compare that to the Visa network, which only handles 45,000 per second.

The topology of the network begins with “layer 1” – that is, the Bitcoin network itself. The blockchain has a 1 megabyte cap to prevent spam transactions from clogging the network and bogging down the ability to transmit blocks to other listening bitcoin nodes. If Bitcoin is to be all-inclusive to everyone in the world, it must be usable and work on poor internet connections. The 1 mb blocksize helps us achieve that. To scale, there must be a layer 2, and one implementation of that is the lightning network.

Layer 2 promises to lift that 7 tps restriction by keeping a “record” of transactions between the two individuals using smart contracts. The two lightning clients can end their open connection with each other at any time and only need to tell layer 1 of the ending balance between the two parties, regardless of how many times they have swapped bitcoin back and forth. Much like how bitcoin uses public/private keys to secure addresses the lightning nodes use multi-signature addresses to secure the escrow of coins locked between the two parties. If one party wants to stop, both parties settle instantly.

A lightning node can connect to multiple individual nodes at the same time. This fact opens the door for not just transferring value between two people, but if you were connected to your friend John, and John was connected to a Starbucks node – then you can buy coffee through John without needing to open a channel (a channel is what we call a connection) directly with Starbucks.

The lightning network is still in it’s infancy, with 3,000 nodes and 8,000 open channels but it is an exciting time for the bitcoin space. Anyone can open a lightning node and connect with someone. Much like layer 1, layer 2’s goals as always is to be open, censorship-resistant, and permissionless.

bitcoin-3163494_1280

What Is A Blockchain?

Since about the year 2000 there’s been an array of buzzwords and catchphrases used in the technology industry in order to raise money from people for the purpose of investing into their startup. “The Cloud”, “Disrupt” (as long as it doesn’t affect the Old Guard), “Web 2.0”, and most recently, “Blockchain”, have all been used to secure funding and make others around you feel like you all know what you’re talking about. So what is a blockchain? Why would someone need it? Can you have “blockchain” without “Bitcoin”? Is it really this magical one-stop shop solution that is going to save your startup from failing? You might be able to secure some money from gullible investors, but it isn’t going to propel you any further ahead than if you used a traditional database.

In computer science, a linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence.
Wikipedia

Replace the above quote’s “linked list” with “blockchain” and you’ve nailed 90% of what a blockchain is. The remaining 10% are some special characteristics that puts the word “chain” in “blockchain”. Blocks consist of (rudimentarily) a header and the body data. The header that’s stored in the individual blocks reference the block immediately behind it, and is tied together using hashes.  In this manner a hash is used to secure the order in which the blocks are set, which is important because the body data of the block contains all of the transactions from the different addresses. It would pose a problem if blocks were not in order because the transactions wouldn’t be in the correct place for when the value was transferred. If some nefarious individual were to try to change a block from the past, perhaps to try to steal coins from another address, it would change the hashes of every single block after that affected block, thereby breaking the chain. The attacker would tell his node that his hacked blockchain is the correct one, which is all well and good for him, but he then needs to convince the rest of the bitcoin network – and that will not work. They ignore his chain. So what is a blockchain? It’s a data structure which locks nodes in a particular order. While normal linked lists can be modified in the middle of the chain, a blockchain’s data is secured by the network of self-governing bitcoin nodes and the hashes found in the header of each individual block.

An individual or company might want a blockchain if and only if there’s two cases they’re trying to achieve. The first is if they’re worried about the integrity of the data they’re storing. The second and most important is if they’re exposing that data to a network of individuals that may have the ability to modify or add to that data. A blockchain ensures that everyone in the network is working on the same dataset and is desired to preserve decentralization of the data. Instead of having a central server which can be taken down by state actors one would decentralize by using a blockchain to prevent that from happening. The Pirate Bay is a  great use-case example of a centralized service that has changed their business model and became decentralized. I won’t detail it out here but you can read more about what it means for them to be decentralized here.

Pundits in the FinTech sphere dislike the word Bitcoin but love the word Blockchain. It’s the next big thing, according to them. To have a blockchain but without some sort of financial-incentivized token behind it makes for an inefficient database that would be better served as a centralized MySQL database. Services these individuals are trying to build could very well be suited for a blockchain, but to try to reinvent the wheel, especially a wheel that’s been around since 2009 and has better security than almost all Fortune 500 companies is not only shortsighted but a clear money grab attempt. Nobody will voluntarily waste electricity to help you secure your over-engineered blockchain without some sort of reward, which in the case of Bitcoin are the bitcoins themselves.

tools-1209764_1920

Bitcoin’s Use Cases

Why would someone want to have bitcoin in their possession? What is bitcoin used for? Bitcoin has a lot of use cases and solves a lot of problems, even though some people don’t think so. For that individual, and most likely you, being in a first-world country makes you not need bitcoin for your every day life. For others however, bitcoin is a very powerful tool that does affect their every day life – and it might affect you as well, even if you don’t know it yet.

Bitcoin as a tool

It’s odd to think of bitcoin as a tool, but much like gold which is used as a hedge against other currencies to reduce your volatility, or other financial instruments to help you achieve financial freedom, bitcoin is a tool that actually gives you financial sovereignty:

It cannot be inflated

Banks have a very special power. They have fractional reserve banking, which means that when you deposit $100 into your checking or savings account, they’re allowed to loan out $90 of that immediately. Some banks aren’t even required to hold any of your cash at all. This power lets them in essence create money out of thin air. Those that take out loans are creating money out of nothing – the bank never had the cash, and it’s interest rate creates more money over time. Bitcoin has a hard cap of 21 million bitcoins that will ever exist, with a pretty big majority of them already lost. You can combat the annual 2% inflation rate by holding deflationary currency and assets, like bitcoin.

It cannot be seized by banks

In times of strife, other countries have resorted to stealing it’s citizens cash in order to pay off their bad debts. This is not something that’s happened a long time ago and no longer happens, in fact it happened back in 2012. If you think you can protect yourself by putting money in the bank, just remember once you put cash in your savings account it’s no longer your money. Your account can be seized or flagged at any point in time, for almost no reason.

It cannot be seized by law enforcement

The United States is rampant with corruption, and law enforcement is no exception. Civil asset forfeiture is the practice in which cash and other valuables are seized by authorities who suspect are being used by a criminal or a part of a crime. The money itself is guilty and you must prove that it’s innocent in order to get it back. It was used as a tool to fight against drug dealers and other criminals but is now being abused to shakedown ordinary people driving down highways. Bitcoin cannot be seized as long as you keep the private keys to yourself. Realistically it can be used to protect individuals living in 3rd world countries or those trying to escape destitute areas. It’s easy to seize gold when crossing borders – but not so easy to seize something you’ve memorized.

It eliminates remittance fees

Immigrants come to America with the hopes of finding better jobs. They will send money overseas to their families to help them with food, clothing, and other necessities. The most popular way right now to do this is by using 3rd party services like Western Union. If you want to send $100 from the United States within 3 days, the fee is $8. That’s 8% of your hard earned money gone. Bitcoin charges less than 10 cents to send money anywhere in the entire world and is settles within 10 minutes. There are services right now dedicated to trying to replace Western Union like BitPesa.

What is Bitcoin used for? First layer of use is protecting your wealth from those in power. Second layer, like what we’re seeing with BitPesa, is the application of money as a protocol on the internet. The ability to program money and transfer value will see exciting and new applications over the coming years.

cyber-security-3400657_1920

Can Bitcoin Be Hacked

Whenever there’s an exchange that’s lost bitcoin or some other cryptocurrency the media always has a sensational headline that reads something like “Bitcoin Hacked”. The truth is of course that Bitcoin itself as the protocol has never been hacked, only exchanges with poor website best practices, weak API security, and/or bad internal processes are the ones that were hacked. Bitcoin has been running with four 9 uptime (99.99%) since 2009 and yes while it’s had problems with it’s protocol early on the fact is if a hacker wanted to transfer your bitcoin to her address it would be impossible without knowing your private key.

To lay the groundwork for this discussion it’s important to know what hacking is since knowing the meaning and ways to hack something will help you visualize it’s impossibility of doing it to Bitcoin. When some entity from their computer wants to steal cryptocurrency from another entity, whether that’s you as an individual, an entire exchange, or Bitcoin itself there has to be an attack vector. The hacker will choose the easiest attack vector there is in order to steal. As an individual, unless you’ve posted sensitive information online (like your private key or seed words) you’re not very easy to hack. Clicking on nefarious links or downloading and running malware creates this easy attack vector on you. An exchange is much easier to try to hack since it’s always online and the hacker knows that there’s bitcoin inside for the taking.

They go about hacking an exchange by looking for holes. There’s articles all the time that’s being published about entire company’s user databases being leaked, and this is just plain sloppiness from these large companies. No encryption, no security, and lax processes cause these things to happen. Once a hacker has gotten their hands on this sensitive information they can log in and transfer your (and everyone else’s) bitcoin out of the exchange and into their own address, then we read more headlines of “Bitcoin Hacked!”

If Bitcoin were hackable it would have happened already. You’d log into your personal account and see a balance of 0.

There’s a 100 billion dollar market ready to be in another person’s hands and all of the information is freely visible for the hacker to see on the blockchain but it hasn’t happened yet. No one has hacked a single satoshi. If it were to happen the value of any cryptocurrency would immediately fall to $0 because there’d be no value there. Bitcoin solves the double spending problem of digital assets, but the problem would not be solved if Bitcoin were hackable.

To put this idea into perspective about how impossible this is, we need to know what bitcoin’s encryption is. Human brains can only imagine numbers to a certain level. You can easily visualize 10 items, you have a pretty good idea of how much 100 items is. Depending on the size of the object, the human brain can hazily recognize what 1,000 marbles looks like in a jar. When it comes to millions of things however, we tend to fail pretty dramatically at it. When it comes to “cracking” a bitcoin key, we’re talking about numbers that exceed the number of atoms in the universe. If you can imagine the singular grains of sand of all the beaches in the entire world, the key-space of a possible bitcoin key exceeds that number.

Mathematicians have calculated the probability of cracking a 256 bit key (SHA-256 which is what Bitcoin uses), and even using the most powerful supercomputers in the world, that it would take longer than the heat death of the universe to find even 1 key. The key-space for a private key is 2160 which is an unfathomably large number. This kind of encryption is used by the NSA and SSL certificates of servers to protect sensitive information between two parties. It should stand to reason that the next time you read an article titled “Bitcoin Hacked” you should think twice about what that means.

brass-cent-coins-164689

History Of Money

The history of money, at least from an ancient times and United States perspective, is an interesting one. This article is just going to be a collection of videos and articles that dispel myths about what the US dollar represents. Other authors have described this very well and I’m not going to re-hash what has already been said.

andre-francois-556746-unsplash

How Does Bitcoin Work?

How does bitcoin work? This article will talk about that very simply and not go into great detail so as to not confuse anyone that may be 100% new. There are a couple of players in the Bitcoin ecosystem that allow individuals to send bitcoin to one another, and they are miners and nodes (those articles go into greater depth about what they are). Without one or the other the entire Bitcoin system would grind to a halt, and no one would be able to send the currency to each other.

Mining bitcoin

Almost every depiction of Bitcoin mining in the media shows an infographic with a pick axe and computer that hacks away at a rock to generate coins. It’s simple to visualize but doesn’t really represent what’s actually happening. Anyone can mine bitcoin by downloading software and running it on their computer. When running this software, your computer is using it’s processing power (electricity) to execute a mathematical function in a lottery to find a special string of characters. The mathematical function is very fast and easy to do, and is called “hashing”.

A bunch of random data is gathered together and hashed millions of times until one person finds the lucky string of characters. If the miner wins this lottery, it stops hashing and takes the random data it used during the hashing and broadcasts it to the Bitcoin nodes in the network for validation that it actually found a real block.

Bitcoin nodes

Bitcoin nodes are the backbone of the network because they actually are the ones that hold the Bitcoin blockchain in their memory and enforce the block validation from miners. Again, just like miners, the Bitcoin node is a piece of software that anyone can download and run on their computer.  There are over 100,000 people running a Bitcoin node currently. It downloads the blockchain from others in the network and validates the blocks in the chain automatically. The size of the blockchain is hundreds of gigabytes in size currently and grows every time a new block is found and added to the chain by about 1 megabyte every ten minutes.

The Bitcoin node will receive new blocks from miners and check their validity using the randomized data that was sent to it from the lucky miner. The node confirms the block’s validity using the same rules the miner used to find the block, so there’s no cheating. The node will add the new block to the end of the blockchain and award the Bitcoin address with new, freshly minted bitcoins out of thin air as a reward for finding a block. The node will then let the other nodes in the network of the new block so the other nodes can verify it’s a real block for themselves, and then add it to the end of their own copy of the blockchain. The node will also let the other miners know they were out of luck and should start working on a new block.

Bitcoin blocks

Bitcoin blocks are the pieces of the chain within the blockchain. They themselves represent a collection of payments from one user to another user’s address, and is why it takes 10 minutes to get 1 confirmation: A Bitcoin miner selects a bunch of payments to include in a block as a part of their hashing data then gets to work. Once found, it is broadcast to any Bitcoin node along with the miner’s Bitcoin address (so the node knows what address to award the coins to) and then works on the next block.

Conclusion

This was a very top level “How does Bitcoin work?” breakdown. We learned how miners and nodes interact with other in a broad sense, and with this knowledge you now should understand how the system behaves without too much technical know-how.

 

 

 

michael-longmire-689531-unsplash

How Many Coins Are There?

There will only ever be 21 million bitcoins in existence. That is the max bitcoin supply. There’s a ton of coins already “lost”, which means the person that had the coins have lost the private key and therefore can no longer send the coins to anyone. They are locked in the address forever, or at least until Bitcoin is hacked.

I know there’s only ever going to be 21 million coins because the Bitcoin protocol, which is the software every full node and miner runs, dictates the inflation rate of the coins. This rate is predetermined to release a certain amount of new freshly minted coins every 10 minutes. Back when Bitcoin was first conceived the inflation rate was 50 coins every 10 minutes. Approximately every 4 years this rate is halved, and as of this writing only 12.5 coins are being printed every 10 minutes. The maximum will stay at 21 million because those that hold the coins will not want to devalue their asset by increasing the cap. If only a handful (or hundreds) of people want to change the protocol to allow more than 21 million coins, without a majority rule, the cap will stay at 21 million.

Of the 16 and a half million Bitcoin that have been mined so far, it is estimated that up to 25% have been lost for good.

Currently there are about 17 million total coins that have the possibility of being moved around. There’s estimates that 4 million of those coins are lost forever. There’s also estimates that a large portion of those 13 million coins left won’t ever be moved due to long term holders. The liquidity in the market is rather small, if someone with a lot of money wants 1,000 bitcoin or more they usually due an “over the counter” purchase. Buying 1,000 coins from an exchange would shoot the price up by $500 or more so this person approaches a large bitcoin miner that might have a lot of coins they’re looking to sell for cash to pay for their electricity bill. This skirts the exchange process and keeps the price right where it’s at, for a while.

No one truly knows why the max bitcoin supply of 21 million as a number was chosen, but we can calculate how this number is derived by multiplying all of the rewards by the amount of blocks it takes to get to that reward. We think 210,000 blocks was chosen (that’s how many 10 minute chunks are in 4 years time) as the halving time to give everyone a fair shot at getting a coin. The coin should be deflationary in order to give it value and let it hold value against a fiat currency like the US dollar as it gains in popularity, and the coin should have new freshly minted coins for a specific amount of time as opposed to being forever inflationary. The last coin will be minted in the year 2140. After that, no new coins will be given.

It should be noted however that there aren’t enough full bitcoins to go around. While it may seem obvious to the reader that with only 21 million bitcoin but 7 billion people this is clearly the case, what might not be so obvious is that there’s 30 million millionaires in the entire world. Not every millionaire will be able to get their hands on a real bitcoin – only paper derivatives of the coin like ETFs and other price trackers will be available to them.

background-2426328_1280

What Is A Bitcoin Address?

In order to receive money in a peer-to-peer transfer some sort of public information needs to be provided to the sending party to know where to send the money to. A bitcoin address can be thought of as a bank account number that corresponds to your bank. Someone can take that address and send bitcoin to you.

The address actually consists of two parts, a private key and a public key. The public key is derived from a private key by some simple math and can be sent to anyone in the world with the knowledge that giving someone the public key will still keep your funds safe. Every bitcoin wallet software protects you from exposing the private key, but if you need it normally there are commands to display it but this is not advised. It should be noted that anyone can see the balance and history of your transactions if they have the public key.

An example of a bitcoin address public key is 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX and it normally starts with either a 1 or a 3. More secure and advanced wallets will generate new keys for you after every transaction, and is advised since reusing an old address is not best practice for anonymity. The bitcoins that are sent to this address are not actually on the address itself. Rather, the ledger (or blockchain) states that your address contains X bitcoin, and until you move it, that address will always have that value. You can actually memorize a private key (or “seed words” that generate all of your private keys) and cross borders with millions of dollars in your head and no one would know. Once you get to another secure computer, you can jot down your memory and the advanced wallet will populate all of your keys again and your money is right there for you.

Anyone with the corresponding public key can combine a message, a putative digital signature on it, and the known public key to verify whether the signature was valid, i.e. made by the owner of the corresponding private key.

The concept of a public and private key goes way back into the 1970s but was officially named in 1997. In Bitcoin, to transfer funds from your bitcoin address to someone else’s, your wallet software will generate a signed message using your private key and their public key. The message contains pertinent information including the amount to send, and other parameters not covered here. When the wallet software broadcasts the transaction to the network and is mined, the signature is validated using your public key. Only someone with a corresponding private key will be able to create valid signatures. If it’s valid we can assume that it was you that sent the money. If a hacker has access to your machine and is able to send money the system doesn’t know that it wasn’t you, and you’re out of luck. The coins are gone forever and the transaction is irreversible.

The fact the transaction is irreversible might make some people uneasy, but it’s this very nature that gives Bitcoin it’s greatest strength: it is an immutable and censorship-resistant asset where you can not be told who you can and can not send money to. There are no blacklists in bitcoin. Bitcoin does not care about trade embargoes or FATF blacklists. It is a truly open currency that is 100% inclusive to everyone in the world.

ricardo-gomez-angel-734321-unsplash

What Are Bitcoin Nodes?

There’s a lot of moving parts in the Bitcoin network, and bitcoin nodes are a huge piece of that machine. Anyone and everyone can download and run a node on their home computer. Almost all nodes come with built-in wallets as well, which is nice but is not necessary to run a full bitcoin node. By running a node you are helping to secure the entire Bitcoin blockchain. You are providing a service to other nodes and helping to create a more secure and decentralized Bitcoin network.

Bitcoin nodes house the blockchain on the user’s computer. When a miner finds a block they tell a node that they’ve found one and to award their bitcoin address with some new bitcoins. If the node determines that the block was valid – that is, the signature in the block not only matches the previous block’s header (thereby growing the “chain”), but the correct number of 0’s were found in the hash of the block – then the node gives the miner a thumbs-up by way of giving the provided bitcoin address new coins for them to spend, and grows the block by 1.

Running your own full node is the only way to have full control and to ensure that all the rules of Bitcoin are being followed. Nodes do this by rejecting blocks that don’t follow the consensus rules and by rejecting connections from peers that send them. bitcoinist.com

At the same time, the validating node broadcasts this block to all of it’s listening peers. These peers download the block to their version of the blockchain, then broadcasts that same block to all of their peers, and so on. In this way the nodes communicate with each other much like a torrent program downloads music or other media from it’s peers.

Being gatekeepers of the blockchain, the nodes also have to have protocols that automatically deal with bad actors. From fake blocks to DoS attacks the bitcoin nodes need to handle these situations to keep the Bitcoin network at the constants 99.9999% uptime it’s grown to be accustomed to. There are internal blacklists that prevent repeated attempts to ping the node. Miners or individuals that manually send fake blocks to the node need to have that node validated – if it’s not valid, the block is simply ignored.

If you’re interested in helping the network grow and stay secure, consider running a full Bitcoin node. You can do so by downloading and running the Bitcoin Core software.

classroom-1209820_1920

What Is Bitcoin Mining?

If you’ve ever seen a news piece covering Bitcoin what you’re most likely seeing is just one side of it, and that’s bitcoin mining. You’re usually shown pictures of massive warehouses showing hundreds of pieces of equipment that is very loud and has cables running everywhere, or a very simplistic picture of a pickaxe hitting a rock and bitcoins flying out of it. This article covers what those pieces of machinery are actually doing, how mining works, and where it fits in the Bitcoin protocol.

What Is Bitcoin Mining

Bitcoin mining is the act of using computer processing power to execute a special formula that calculates a number. The special formula is called a hashing function. The hashing function that Bitcoin uses is called SHA256, and it takes any kind of text as input and results in a hash. Here’s an example:

SHA256("This is a test") = c7be1ed902fb8dd4d48997c6452f5d7e509fbcdbe2808b16bcf4edce4c07d14e

Miners use their computers to first collect the transactions they’re going to include in the block, the header from the previous block (to preserve the connection of the blocks in the blockchain), and a random piece of text called a “nonce” all in a text value. They then hash the entire thing in SHA256 and look at the result value. If the value falls within the network’s limits of being a valid block, the miner submits that found block to the network for bitcoin nodes to validate as true. The special value the network is looking for is any text value that has minimum number of zeros in the hashed value. Here’s an example of that number from block id 540677:

0000000000000000000b2be42297654db25290e69d1499c8250938c0eb813223

Currently, a successful hash must start with approximately 17 zeros, so only one out of 1.4×1020 hashes will be successful. In other words, finding a successful hash is harder than finding a particular grain of sand out of all the grains of sand on Earth.
http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and-paper.html

These zeros in front help ensure blocks are found about every ten minutes, and the network increases or decreases the number of zeros needed depending on how many people are trying to mine for bitcoin. When a miner finds a block they are awarded new bitcoins and any fees that were present on the transactions that they decided to include in the block. As such, miners will include transactions in the order of highest fee to lowest fee in order to gain the most money on their work put into finding a block. Since blocks are limited to 1mb in size, this means if you as a bitcoin user want to transfer value from one address to another address you must include a higher than normal fee in order to make sure it gets into the very next block.

How It Fits In The Bitcoin Protocol

Once the miner finds a valid block it needs to be proven that it’s valid by the network. The miner does not award itself with bitcoins and fees from the block, the bitcoin node does. The miner will submit the block to a node along with the hash found and the bitcoin address where the awarded coins should be going to.

The node takes the data submitted and confirms that the data contains a reference to the previous block in order to preserve the blockchain’s chain, and that the resulting SHA256 on all of the block’s data matches the hash submitted by the bitcoin miner. If all of these are true, then the miner is awarded the block reward (currently at 12.5 bitcoins) and any fees associated with all the transactions in the block. As a last step, the node then broadcasts this new block to every node (and resulting miners) which will then begin work on the next block referencing the new block’s header, and continues on.

Bitcoin Mining Cheaters

It might follow then that to get free coins one just needs to take a valid hash already used and submit it to the network to trick it into giving you free coins. This will not work for a number of reasons, but the two primary ones are the nature of hashing functions along with how the hash is calculated.

Hashing is a one-way function. You can not take a hash and somehow calculate what the text was that was used to create the hash on complex values. People have created rainbow tables which are large databases of text values containing the unhashed text value and the hashed value, however these are used to crack passwords so the complexity of the data in a bitcoin hash makes this an impossibility.

Finally the bitcoin nodes themselves that are validating these blocks will compute the hash themselves, so any submitted data along with the hash is checked for validity before including them in the blockchain and awarding the miner with coins. In a nutshell that’s how bitcoin mining works, from a top-level non-math intense view.