• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Idelto

Cryptocurrency news website

  • About
  • Monthly analysis
    • August 2019
    • July 2019
    • June 2019
  • Bitcoin/Ethereum
  • How to invest in cryptocurrencies
  • News

Cryptography

How To Lock And Protect Away Secret Files With GNU Privacy Guard

13/05/2022 by Idelto Editor

Users can take advantage of the cryptographic protection offered by GPG to secure files and data that they want to keep well under wraps.

In this guide, I will explain the options at your disposal for encrypting files using open-source software on a Linux, Mac, or Windows computer. You can then transport this digital information across distance and time, to yourself or others.

The program “GNU Privacy Guard” (GPG) an open-source version of PGP (Pretty Good Privacy), allows:

  1. Encryption using a password.
  2. Secret messaging using public/private key cryptography
  3. Message/Data authentication (using digital signatures and verification)
  4. Private key authentication (used in Bitcoin)

Option One

Option one is what I’ll be demonstrating below. You can encrypt a file using any password you like. Any person with the password can then unlock (decrypt) the file to view it. The problem is, how do you send the password to someone in a secure way? We’re back to the original problem.

Option Two

Option two solves this dilemma (how-to here). Instead of locking the file with a password, we can lock it with someone’s public key — that “someone” is the intended recipient of the message. The public key comes from a corresponding private key, and the private key (which only the “someone” has) is used to unlock (decrypt) the message. With this method, no sensitive (unencrypted) information is ever sent. Very nice!

The public key is something that can be distributed over the internet safely. Mine is here, for example. They are usually sent to keyservers. Keyservers are like nodes that store public keys. They keep and synchronize copies of peoples’ public keys. Here’s one:

Ubuntu Keyserver

You can enter my email and find my public key in the result. I’ve also stored it here and you can compare what you found on the server.

Option Three

Option three is not about secret messages. It is about checking that a message has not been altered during its delivery. It works by having someone with a private key sign some digital data. The data can be a letter or even software. The process of signing creates a digital signature (a large number derived from the private key and the data that’s getting signed). Here’s what a digital signature looks like:

It’s a text file that begins with a “begin” signal, and ends with an “end” signal. In between is a bunch of text that actually encodes an enormous number. This number is derived from the private key (a giant number) and the data (which is actually always a number also; all data is zeros and ones to a computer).

Anyone can verify that the data has not been changed since the original author signed it by taking the:

  1. Public key
  2. Data
  3. Signature

The output to the query will be TRUE or FALSE. TRUE means that the file you downloaded (or message) has not been modified since the developer signed it. Very cool! FALSE means that the data has changed or the wrong signature is being applied.

Option Four

Option four is like option three, except that instead of checking if the data has not been modified, then TRUE will mean that the signature was produced by the private key associated with the public key offered. In other words, the person who signed has the private key to the public key that we have.

Interestingly, this is all that Craig Wright would have to do to prove he is Satoshi Nakamoto. He doesn’t have to actually spend any coins.

We already have the addresses (similar to public keys) that are owned by Satoshi. Craig can then produce a signature with his private key to those addresses, combined with any message such as “I really am Satoshi, haha!” and we can then combine the message, the signature, and the address, and get a TRUE result if he is Satoshi, and a CRAIG_WRIGHT_IS_A_LIAR_AND_A_FRAUD result if he isn’t.

Option Three And Four — The Difference.

It’s actually a matter of what you trust. If you trust that the sender owns the private key to the public key you have, then verification checks that the message has not changed.

If you don’t trust the private key / public key relationship, then verification is not about the message changing, but the key relationship.

It’s one or the other for a FALSE result.

If you get a TRUE result, then you know that BOTH the key relationship is valid, AND the message is unaltered since the signature was produced.

Get GPG For Your Computer

GPG already comes with Linux operating systems. If you are unfortunate enough to be using a Mac, or God forbid a Windows computer, then you’ll need to download software with GPG. Instructions to download and how to use it on those operating systems can be found here.

You don’t need to use any of the graphical components of the software, everything can be done from the command line.

Encrypting Files With A Password

Create the secret file. This can be a simple text file, or a zip file containing many files, or an archive file (tar). Depending on how sensitive the data is, you might consider creating the file on an air-gapped computer. Either a desktop computer built with no WiFi components, and never to be connected to the internet by cable, or you can build a Raspberry Pi Zero v1.3 very cheaply, with instructions here.

Using a terminal (Linux/Mac) or CMD.exe (Windows), change your working directory to wherever you put the file. If that makes no sense, search the internet and in five minutes you can learn how to navigate the file system specific to your operating system (search: “YouTube navigating file system command prompt” and include your operating system’s name).

From the correct directory, you can encrypt the file (“file.txt” for example) like this:

gpg -c file.txt

That’s “gpg”, a space, “-c”, a space, and then the name of the file.

You’ll then be prompted for a password. This will encrypt the new file. If you’re using GPG Suite on the Mac, notice the “Save in Keychain” is checked by default (see below). You might want to not save this password if it’s particularly sensitive.

Whichever OS you use, the password will be saved for 10 minutes to the memory. You can clear it like this:

gpg-connect-agent reloadagent /bye

Once your file is encrypted, the original file will remain (unencrypted), and a new file will be created. You must decide if you will delete the original or not. The new file’s name will be the same as the original but there’ll be a “.gpg” at the end. For example, “file.txt” will create a new file called “file.txt.gpg”. You can then rename the file if you wish, or you could have named the file by adding extra options in the command above, like this:

gpg -c –output MySecretFile.txt file.txt

Here, we have “gpg”, a space, “-c”, a space, “–output”, a space, the filename you want, a space, the name of the file you are encrypting.

It’s a good idea to practice decrypting the file. This is one way:

gpg file.txt.gpg

This is just “gpg”, a space, and the name of the encrypted file. You don’t need to put any options.

The GPG program will guess what you mean and will attempt to decrypt the file. If you do this immediately after encrypting the file, you may not be prompted for a password because the password is still in the computer’s memory (for 10 minutes). Otherwise, you’ll need to enter the password (GPG calls it a passphrase).

You will notice with the “ls” command (Mac/Linux) or “dir” command (Windows), that a new file has been created in your working directory, without the “.gpg” extension. You can read it from the command prompt with (Mac/Linux):

cat file.txt

Another way to decrypt the file is with this command:

gpg -d file.txt.gpg

This is the same as before but with a “-d” option as well. In this case, a new file is not created, but the contents of the file are printed to the screen.

You can also decrypt the file and specify the output file’s name like this:

gpg -d –output file.txt file.txt.gpg

Here we have “gpg”, a space, “-d” which is not strictly required, a space, “–output”, a space, the name of the new file we want, a space, and finally the name of the file we are decrypting.

Sending The Encrypted File

You can now copy this file to a USB drive, or email it. It is encrypted. Nobody can read it as long as the password is good (long and complicated enough) and can’t be cracked.

You could send this message to yourself in another country by storing it in email or the cloud.

Some silly people have stored their Bitcoin private keys to the cloud in an unencrypted state, which is ridiculously risky. But if the file containing Bitcoin private keys is encrypted with a strong password, it’s safer. This is especially true if it’s not called “Bitcoin_Private_Keys.txt.gpg” – Don’t do that!

WARNING: It’s important to understand that in no way am I encouraging you to put your Bitcoin private key information on a computer (hardware wallets were created to allow you to never need to do this). What I am explaining here is for special cases, under my guidance. My students in the mentorship program will know what they are doing and will only use an air-gapped computer, and know all the potential risks and problems, and ways to avoid them. Please don’t type seed phrases into a computer unless you are a security expert and know exactly what you are doing, and don’t blame me if your bitcoin is stolen!

The encrypted file can also be sent to another person, and the password can be sent separately, perhaps with a different communication device. This is the simpler, and less secure way, compared to option two explained at the beginning of this guide.

There are actually all sorts of ways you can construct the delivery of a secret message across distance and time. If you know these tools, think hard and carefully about all the risks and scenarios, a good plan can be made. Or, I am available to assist.

Good luck, and happy Bitcoining!

This is a guest post by Arman The Parman. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc or Bitcoin Magazine.

Filed Under: Bitcoin Magazine, Cryptography, encryption, English, Feature, GPG, Marty's Bent, PGP, privacy, security, technical

Bitcoin Barbed Wire And The Crypto Anarchist Manifesto

02/04/2022 by Idelto Editor

Comparing Bitcoin to barbed wire from Timothy May’s “Crypto Anarchist Manifesto” can give insight into the gravity of this seemingly abstract invention.

(Source)

Some of Bitcoin’s properties sound abstract. Properties like digital ownership, censorship resistance, decentralization and more. But the deeper you dig into the Bitcoin rabbit hole, the more you realize that Satoshi Nakamoto even implemented some mutually exclusive properties simultaneously: freedom of privacy and property rights. In fact, Bitcoin reconciles an uncensorable pseudonymous system and an extreme form of property rights. I would like to show why this combination was actually almost impossible by using an analogy based on the example of barbed wire in Timothy C. May’s “Crypto Anarchist Manifesto.”

We first find the “barbed wire” analogy in one of the shortest but most exciting texts of the cypherpunk movement, the aforementioned “Crypto Anarchist Manifesto.” While the common man had never heard of the internet at the time, the minds of the cypherpunks, who were only forming in the early 1990s, had already painted a clear picture of the information age and its promises and dangers. Those who find the thesis in “The Sovereign Individual” to be prophetic should definitely keep in mind what the cryptography anarchists were already discussing a decade earlier.

With works like “Security Without Identification: Transaction Systems To Make Big Brother Obsolete” by David Chaum in 1985, this once-nascent movement set a counterpoint to the tendencies of technology moving toward centralization and control, even if this actual danger was still a long way off. May was a libertarian-minded former Intel employee who had retired from the company at 35. He became a cofounder of the cypherpunks email list and wrote influential texts. Among them was the “Crypto Anarchist Manifesto,” which he distributed at a hacker conference in 1988.

In it, May points to the great future of cryptography, which would eventually realize the grand vision of anonymity and privacy in cyberspace. In what is an almost frighteningly visionary essay from today’s perspective, May shows what possibilities encrypted communication between people could offer. He not only compared encrypted communication to the invention of the printing press, but chose an analogy that had it all: the invention of barbed wire.

May wrote, “Just as a seemingly minor invention like barbed wire made possible the fencing-off of vast ranches and farms, thus altering forever the concepts of land and property rights in the frontier West, so too will the seemingly minor discovery out of an arcane branch of mathematics come to be the wire clippers which dismantle the barbed wire around intellectual property.”

Interestingly, it is clear from the comparison that the imminent (state) surveillance and restriction of the individual goes hand in hand with the invention of barbed wire. It is cryptography, however, that cuts the barbed wire around intellectual property. From today’s perspective, the mental image May chose to paint can hardly be surpassed in terms of genius and ambivalence. After all, thanks to Bitcoin, the image even works in two directions.

Barbed wire is an often underestimated invention, and few people knew what implications it would hold. In the U.S., the so-called “frontier,” or the borderland between the settled or “civilized” and the undeveloped areas, had moved farther and farther west. It was seen as a divine mandate, a “Manifest Destiny,” to settle the whole country. To this end, President Abraham Lincoln had launched the Homestead Act in 1962. It stated that any “honest citizen” could take up land free of charge. All one had to do to claim his property was to make it his own through agricultural use. 

(Source) An advertisement for Glidden’s barbed wire. The farmer had registered his patent in 1873.

But tilling the fields in the vast prairie was difficult, for the land was practically a single open space. It was inhospitable, overgrown with wild grasses, sometimes difficult to access and used by cowboys, ranchers or Native Americans, sometimes almost nomadically. Fencing off land was either expensive or ineffective because neither wooden fences nor planted hedges could keep out unwelcome visitors.

A single and, at first glance, tiny invention changed everything from the nature of agricultural use to the treatment of public lands and even the concept of ownership: the invention of barbed wire. The new type of fence was advertised in 1875 as the “Greatest Discovery of the Age.” Patented by Joseph Glidden of Illinois, it was “lighter than air, stronger than whiskey, cheaper than dust.” And indeed, it brought about a transformation of the American West. The double, twisted wire with spikes was used everywhere: by railroad companies demarcating their lines, by ranchers demarcating fields or raising cattle and by anyone else who used it to mark and protect what was “theirs.”

Barbed wire was a double-edged sword. Settlers loved it because it made property a fact. Cowboys, who used the free land extensively, hated the dangerous wire that led to injury and infection. Native Americans were driven farther and farther off their land because their concept of property was not to draw firm boundaries. No wonder they quickly referred to barbed wire as “the devil’s rope.” Old-time cowboys also lived by the principle that the great prairie was common property and cattle could run free under the law of “open range.”

Barbed wire was a disruptive invention and a fight quickly broke out over it. In the “fence-cutting years,” masked gangs like the Javelinas or Blue Devils cut fences and threatened settlers who put them up until lawmakers stepped in. The barbed wire was to remain.

It is interesting that cypherpunk Timothy C. May uses the analogy of barbed wire to counter-image the invention of cryptography. It was an equally underestimated and seemingly small invention, but one that successfully played “wire-cutter.” The ideal of the free “open range” was restored and unlike the gangs that ended up being taken down, mathematics was simply unstoppable.

(Source) Barbed wire versus the open range – a settler fencing off his plot.

The mental image is great because it turns the logic on its head. Barbed wire drew boundaries in freedom. But a tiny pair of wire cutters can undo them. And, as if with a battle cry, the “Crypto Anarchist Manifesto” ends, “Arise, you have nothing to lose but your barbed wire fences!”

Today, with Bitcoin, one of the cypherpunks’ visions has arrived in reality. In fact, we are exactly on the path that the “Crypto Anarchist Manifesto” had prophesied, in both cryptographic and economic terms. The text said that cryptographic methods would, “fundamentally alter the nature of corporations and of government interference in economic transactions.” We are well on our way to that reality, thanks to Bitcoin.

But despite how unappealing the image of the barbed wire that divided a vacant land into plots may seem to us, Satoshi Nakamoto’s mathematical-economic invention has a few similarities to the disruptive invention of barbed wire in the 19th century. At first glance, Bitcoin is also a small mathematical discovery that comes across as unassuming, but Bitcoin fundamentally changes a few things.

The ambivalence is that, on the one hand, it is indeed the vision of an “open range” that cuts through resistance, borders and (government) surveillance like wire cutters. On the other hand however, Bitcoin allows precisely the effortless demarcation of ownership. Bitcoin is a bit like “barbed wire” for property rights in the digital world. This is because it is the ingenuity of this invention, cryptographic encryption in conjunction with the timechain, that turns what was initially only a theoretical right to property into a reality.

This is because Bitcoin transactions, although pseudonymous, show many formal aspects of property rights as we know them from real estate. For example, ownership is publicly registered and shown without gaps across the interconnected blocks. This ownership is publicly accessible and verifiable for each individual. And it is ensured that no duplicate claims exist. The timechain becomes a kind of public land registry. Transferring these features and processes to a pseudonymous system is indeed unique — barbed wire and wire cutter at the same time.

While critics of the technology bother with superficial analogies like the tulip mania, Bitcoiners know that fundamental philosophical debates underlie all the issues at stake in Bitcoin. Philosophers like John Locke or Jean-Jacques Rousseau would write entire books about the fundamental questions of this digital commodity, if they were still alive.

After all, what do we actually own besides our bodies? That which we cultivate with our work? That which we transform? Or simply that which we can demarcate?

This is a guest post by Holger von Krosigk. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc. or Bitcoin Magazine.

Filed Under: Bitcoin, Bitcoin Magazine, Crypto-anarchists, Cryptography, culture, Cypherpunks, English, Opinion, The Sovereign Individual

How SHA256 And Mining Protect The Bitcoin Network

24/02/2022 by Idelto Editor

How is Bitcoin defended by energy? And what is a nonce? These questions and more are answered within!

How mining works is fascinating. When I explain it to people, I enjoy seeing their face the moment their mind is blown. I’ll explain it here, but just know, I’m imagining all your faces as your minds blow!

I have to start with hash functions. Without hash functions, Bitcoin would not be possible. Let me explain what they are first, not only so you can sound cool at parties, but also because it’s fundamental to understanding how Bitcoin works — particularly mining but also transactions — under the hood.

You don’t need to understand how Bitcoin works in order to benefit from it, just like how you don’t need to understand how TCP/IP works to use the internet. But do go on, because it’s quite interesting and I’ll make it easy to understand, I promise.

Hash Functions

Let’s start with a schematic which I’ll explain below…

(Graphic/@jirols_btc)

On the left is the input, the center is the function, and on the right is the output. The input can be any data, as long as it’s digital. It can be of any size, provided your computer can handle it. The data is passed to the SHA256 function. The function takes the data and calculates a random-looking number, but with special properties (discussed later).

The first Secure Hash Algorithm (SHA) was originally developed by the NSA and there are many different versions now (Bitcoin uses SHA256). It’s a set of instructions for how to jumble up the data in a very complicated but specified way. The instructions are not a secret and it’s even possible to do it by hand, but it is very tedious.

For SHA256, the output is a 256-bit number (not a coincidence).

A 256-bit number means a binary number 256 digits long. Binary means the value is represented with two symbols, either 0 or 1. Binary numbers can be converted to any other format, for example decimal numbers, which are what we are familiar with.

Although the function returns a 256-digit binary number, the value is usually expressed in hexadecimal format, 64 digits long.

Hexadecimal means that instead of 10 possible symbols like we are used to with decimal (0 to 9), we have 16 symbols (The ten we are used to, 0-9, plus the letters a, b, c, d, e, and f; which have the values 11 to 15). As an example, to represent the value of decimal 15 in hexadecimal, we just write “f” and it’s the same value. There’s plenty of information available online with a quick Google search if you need more elaboration.

To demonstrate SHA256 in action, I can take the number 1 and run it through an online hash calculator, and got this output (in hexadecimal):

The top box is the input, the bottom box is the resulting output.

Note that all computers in the world will produce the same output, provided the input is the same and the SHA256 function is used.

The hexadecimal number output, if converted to decimal, is (notice it takes more digits to write):

48,635,463,943,209,834,798,109,814,161,294,753,926,839,975,257,569,795,305,637,098,542,720,658,922,315

And converted to binary it is:

11010111000011010110010011100111111111100110100111111001110000110011101011010111000000001001110111111110101101000111111010101110100011110101101101001001110101010100010001011110001110101001001110000000001111001010010110111011011011110000111010110110100101111010111001101011100110101110011010111001101011100110101110011010111001101011100111

Just out of interest, here is the same value in base 64.

1w1k5/5p+cM61wCd/rR+ro9bSdVEXjqTgDylu28OtpY=

Note that the smallest possible value SHA256 could return is zero, but the LENGTH is still 256 bits. This is how zero is represented:

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

And the largest possible value is:

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

In decimal, that’s:

115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,935

In hexadecimal, it is:

FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Note there are exactly 64 F’s.

Zero in hexadecimal can simply be written as one single zero, but for hash output, it’s 64 of them to keep to the requirement of a fixed size output:

0000000000000000000000000000000000000000000000000000000000000000

Here is a summary of some facts about the hash function that are vital to appreciate:

  • The input cannot be determined from the output
  • The input can be any length
  • The output is always the same length
  • The output will always be reproduced identically if you provide the same input.
  • Any change to the input, no matter how small, will cause an unpredictable and wildly different output
  • The output is seemingly random, but is actually deterministic (meaning it is calculated and reproducible)
  • The output cannot be predicted. It can only be calculated and this takes a measurable amount of work by a computer (and hours with pencil and paper! Don’t do it.)

Now that you understand the basic concept of what a hash is, you can understand the explanation of how Bitcoin mining works.

But before you move on, I recommend you go to an online hash calculator and play with it a little and test for yourself what I’ve said about hash functions. I like this one.

Mining

I will start by demonstrating a concept of work, which is where “proof-of-work” in Bitcoin comes from.

Go to the online hash calculator and type “I am creating 50 bitcoins and paying myself this amount.”

Type it exactly, case sensitive, including the full stop. You should get this output:

Now, let’s create a rule that says for this payment message to be valid, we need the hash to start with one zero. To do that, we have to change the input somehow. But, as you’ve learned, it’s not predictable what the output would be for a given input. What modification can we make to ensure a hash starting with zero?

We have to add data using trial-and-error. But we also don’t want to change the meaning of the input message. So, let’s create a field (an allocated section) called a “nonce” which will hold a nonsense value.

The word “Nonce” is supposed to be derived from “number only used once,” but I don’t see it.

Notice below how just adding “Nonce:” as an extra field heading changes the hash output.

The output still doesn’t start with a “0”, so let’s add some nonsense (I added a meaningless “x”):

It still doesn’t start with a zero. I tried some more characters until the hash started with a zero:

There we go. Now, according to the arbitrary rules I set for this pretend version of Bitcoin, the text in the input window is a valid block with a single transaction paying me 50 bitcoin.

Note that Bitcoin blocks are essentially pages of a ledger. Each block is numbered and creates new bitcoin, along with listing the transactions between users. This record is where bitcoin lives.

Now a new rule. For the next block, the hash of the previous block must be included. I’ll add a little complexity and add a few more fields to approach what a real Bitcoin block has.

The hash starts with an “f” not “0”, so I’ll have to try some values in the nonce field:

This time I was luckier and found a suitable nonce after only four tries. Recall that for the first block it took 22 tries. There is some randomness here, but generally it’s not too difficult to find a valid hash if all we’re trying to get is one zero. There are 16 possible values for the first hash digit so I have a 1 in 16 chance that any modification I make to the input field will result in the first hash digit being “0.”

Note that Bitcoin’s fields are like this, but there’s more detail that I haven’t added. This is just to illustrate a point, not necessarily to detail exactly what a Bitcoin block looks like.

I will add a time field to the next block as I need that to explain the “difficulty adjustment” next:

Above is block number three. It includes the previous block’s hash and now I’ve also started to include the time. The nonce I found successfully made the hash start with a zero (I just kept typing a “1” until the hash target was met).

There’s enough here now that I can start explaining a few interesting concepts about the Bitcoin blockchain and mining.

Winning A Block

The mining process is competitive. Whoever produces a valid block first gets to pay themselves a set block reward. A miner that produces the same block number a bit later gets nothing — that block is rejected. Explaining why that is will cause too much of a diversion now, so I’ll explain it in the appendix.

After block three is found and broadcasted to everybody (all the Bitcoin nodes), all the miners stop working on what would have been their version of block three. They begin to build on top of that successful block three (by pulling its block hash forward into a new block) and start working on finding a suitable nonce for block four. The winner publishes the result and then everyone starts working on block five, etc.

With each block, new bitcoin are being created and collectively make up the total supply so far. If there are many miners, then statistically we should expect that blocks will be produced faster, and therefore bitcoin will be created faster. Problem, right?

Seeking a limited supply of bitcoin with a predictable issuance over time, Satoshi Nakamoto thought of this problem and introduced a negative feedback loop to keep block production at 10-minute intervals on average. How? See if you can think of a way. Pause for a moment and ponder — see if you can come up with the same genius solution and read on when you give up.

NODES: I mention “valid” blocks. So what? Who’s checking? The Bitcoin nodes are. A Bitcoin node keeps a copy of the blockchain so far and follows a set of rules to check that new blocks are within the rules and reject those that aren’t. Where are the rules? In the code. A computer that downloads the Bitcoin code is a node.

The Difficulty Adjustment

The average time to create new Bitcoin blocks is calculated by every node every 2016 blocks (this is why the time field is needed). This is part of the protocol and rules that the nodes follow. A formula is applied to adjust the number of zeros each block hash must start with in order to be valid.

Strictly, it’s not the number of zeros that is adjusted but a target value the hash has to be below, but thinking of leading zeros is simpler to explain.

If blocks are being produced too fast, then the hash target is adjusted according to pre-defined rules that all nodes follow identically (it’s in their code).

Keeping it simple for my example, let’s say other people are competing with me, blocks are happening too quickly, and now the fourth block needs two zeros instead of one, according to an imaginary calculation.

It’s going to take me a bit longer to get two zeros, but we’re imagining that there are many other people competing with me so the total time taken for anyone to find a block is kept to a target.

Here is the next block:

Notice the time. More than 10 minutes passed since the previous block (I just made the time up to demonstrate). The 10-minute target is probabilistic; it is never known exactly when the next block will be found.

I messed around on the keyboard for a minute until two zeros showed up. This was exponentially harder than finding a single zero. The chance of finding two zeros in a row is 1 in 162, or a 1 in 256 chance.

If more people were to join in the mining and competition for new bitcoin, then eventually three zeros will be required.

I just looked up the last real Bitcoin block, which contains the hash of the previous block. The hash was:

000000000000000000084d31772619ee08e21b232f755a506bc5d09f3f1a43a1

That’s 19 zeros! There’s a 1 in 1619 chance of finding such a block with each attempt. Bitcoin miners do many, many attempts per second, collectively all over the world.

The number of attempts per second is known as the “hash rate.” Currently, the estimated world hash rate is just under 200 million terahashes per second ( one terahash is a trillion hashes). With that many attempts per second, a block with a hash starting with 19 zeros is found around every 10 minutes.

In the future, as more miners join in, the hash rate will go up, blocks will be found faster, and Bitcoin’s difficulty will adjust to require 20 zeros, which will push block production back down to around 10 minutes.

The Halving

When Bitcoin first started, 50 bitcoin were produced with every block. The rules of the Bitcoin blockchain specify that after every 210,000 blocks the reward will be cut in half. This moment is known as “the halving,” and happens roughly every four years. The halving, combined with the difficulty adjustment keeping blocks at 10-minute intervals, means that around the year 2140, the block reward will be 0.00000001, or 1 satoshi, the smallest unit of a bitcoin, and can’t be halved anymore. Mining won’t stop, but the block reward will be zero. From that moment, no new bitcoin will be created going forward and the number of bitcoin is mathematically calculable and close enough to 21 million coins. This is how the total supply is known — it is programmatically set.

Even with the block reward at zero, the miners will still be incentivized to keep working in order to earn transaction fees.

How exactly is the block reward cut in half? It’s in the code held by the nodes. They know to reject any new block after 210,000 where a miner pays himself over 25 bitcoin. And then to reject any blocks after 420,000 where a miner pays himself over 12.5 bitcoin, and so on.

Transaction Fees

So far I’ve only shown imaginary blocks with a single transaction — the transaction where the miner gets paid a reward. This is called the “coinbase transaction.”

It’s not named after the company, Conbase, I mean Coinbase. The company named itself after the coinbase transaction, not the other way around. Don’t get confused.

In addition to the coinbase transaction, there are transactions of people paying each other. Here’s an imagined example:

I didn’t bother finding a real hash this time (It’s actually the real hash reported in block 200,001). The nonce I just made up for fun, but notice a message can be embedded there.

Satoshis famously included the words, “Chancellor on Brink of Second Bailout for Banks” in the first Bitcoin block (The Genesis Block), after the newspaper headline for the day.

The point here is that there are 132 transactions included (not all shown). Look at transaction #132 – 2.3 bitcoin from an address is paying 2.1 bitcoin to another address and also to a second address the amount 0.1 bitcoin (I’ve used dots to shorten the length of the address).

So a source of 2.3 bitcoin pays a total of 2.2 bitcoin (2.2 + 0.1 = 2.2). Is there 0.1 bitcoin missing? No, the difference is claimed by the miner, as I’ll explain.

The miner is allowed to pay himself 25 bitcoin as the block reward (because 210,000 blocks have passed so the reward has been halved from 50 to 25). But if you look, the coinbase transaction is 27.33880022. The extra 2.33880022 bitcoin comes from the other 132 transactions in the block – the inputs will all be slightly greater than the total of the outputs. So the miner gets to claim this “abandoned” bitcoin as payment to himself. These are considered transaction fees paid to the miner.

The block space is limited. When Bitcoin was new, users could send transactions with no fee and the miners would include the transaction in the block. But now there are more users and since getting on the next block is competitive, users include a fee in the transaction to entice the miner to choose their transaction over others’.

So when the block reward steadily goes down, halving every four years and eventually to zero, miners still get paid in this way.

Some have suggested that one day the reward to miners will not be enough and will cause Bitcoin to fail. This concern has been thoroughly debunked and I won’t repeat it here.

Can A Block Be Re-written?

This is extremely unlikely and it’s worth understanding why. You’ll then appreciate why Bitcoin transactions are immutable (unchangeable).

I explained earlier that the hash of the previous block is included in the current block. That means any editing of transactions in an old block changes the hash of that edited block. But that hash is recorded down in the next block, so that means that the next block needs to be updated, too. But if you change the hash recorded in that next block, then its hash needs to change, and so on.

Note that any time a hash is changed, you lose all these lovely zeros and will just be left with a random-looking hash — and have to do all the work again to get the zeros back. If you do that for the block you tried to edit, you then have to redo the work for the next block, and the next all the way to the most recent block. You can’t simply stop at the old block, because the rules of Bitcoin are such that the longest chain of blocks is the real Bitcoin record. If you go back and edit a block 10 blocks ago, you no longer have the longest chain. You have to add 10 more blocks and then a bit more because as you were creating those 10 blocks, the real chain probably became a bit longer. You have to race to overtake the real chain. If successful, then the new version becomes the real version.

Repeating the entire world’s collective hashing effort from the edited block to the latest block is the barrier to editing Bitcoin. The energy was expended to create those hashes with all those improbable zeros and that energy expenditure must be repeated to edit Bitcoin. This is why energy used to mine Bitcoin is not “wasted”; it is there to defend Bitcoin from edits, to make the ledger immutable without needing to trust a central authority.

What happens if two miners find a block at the same time?

This actually happens every now and then, and it always sorts itself out as follows:

Every node will receive either one of the new nearly-simultaneous blocks first and will accept that one and reject the one arriving just moments later. This results in a split of the network, but it’s temporary.

To illustrate, let’s call one of the blocks blue and the other red (they have no color, just bear with me).

Miners then work on the next block, but there will be a split as to which block they extend the chain from.

Let’s say the winning miner found a block using the blue chain. They will send the new block to all the nodes and the longest chain will be apparent. The nodes that had accepted the red chain will then drop it and adopt the blue chain.

All miners that were working on the red chain will stop and will now work on the longer chain, which is the blue chain. The red chain is dead.

Appendix

Why A Runner Up Miner’s Block Is Invalid

Suppose block 700,000 just got mined by MINER-A. Thirty seconds later, MINER-B also created a different version of block 700,000. When MINER-B broadcasts this alternative, every node is going to reject it because they have already seen and accepted the block by MINER-A. What’s more, in that 30 seconds, let’s say that MINER-C found block 700,001. Given that MINER-B’s competing 700,000th block does not extend the current chain (which is up to 700,001), it is also rejected for that reason.

Even more interesting is that if MINER-B had been working on block 700,001 instead of a competing version of 700,000, they would have had just as much chance of mining a valid block 700,001 as they would have to finally find an alternate block 700,000. So as soon as any miner sees a new block, they should set their effort on the next block.

If, however, Miner-B found block 700,000 one second after MINER-A did, then it’s possible that some nodes see MINER-A’s block first while others see MINER-B’s block first, depending on geographic locations and internet speeds. In that case, there is a temporary fork, and some miners will be working to extend one version while other miners will be working to extend the other. As explained earlier using the “blue chain” and “red chain” descriptors, eventually one of the versions will extend further before the other and become the valid version unanimously.

This is a guest post by Arman The Parman. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc or Bitcoin Magazine.

Filed Under: Bitcoin Magazine, Blocks, Cryptography, English, Marty's Bent, Mining, Opinion, SHA-256, technical

Bitcoin Is A One-Way Hash Function

31/12/2021 by Idelto Editor

Bitcoin offers an irreversible digital property function that prior to its invention simply did not exist.

Understanding Bitcoin is a one-way hash function should make sense because a hash function cannot be reversed. Once you understand that, it is hard to go back to thinking otherwise. The secure hash algorithm or SHA-256 puts Bitcoin in a different lane, where you can share your bitcoin address without risking the security of your funds. But there is so much more.

A one-way hash function is a mathematical function that generates a fingerprint of the input, but there is no way to generate the original information twice. The genius around a secure hash function is a topic I will touch on, but Bitcoin and the whole inception behind it are akin to scrambling an egg. It is a one-way function; once the egg is cracked, the yolk cannot be placed back into the egg and sealed. Once the yolk is cooked on a hot skillet, the egg scramble cannot be turned back into the yolk. The Bitcoin algorithm is no different. The core code is essentially set in stone in cyberspace and still functions without an administrator at the helm of its creation.

In the past, the process of trade and money was complicated and bequeathed with ethical dilemmas. Africans saw cowrie shells and glass beads as revered money, so Europeans flooded the market with these beads. The implications were vast. The increase of counterfeit beads debased the value, which made it easier to manipulate for trade. The Romans clipped bits from the existing coins in circulation and then used the leftover clippings to mint new coins.

The coins kept getting smaller. Yet, the empire kept expanding. Prices went up while the purchasing power of the currency went down. Which ultimately, over time, collapsed the Roman economic system. America is doing the same on a grander scale by expanding the money supply via the money printer, although not having the dollar pegged to a gold-backed currency after the Nixon shock. It encourages an ever-increasing weak currency where printing worthless paper notes are just as damaging.

The first Age of Enlightenment arose as a result of the separation of church and state. The second Age of Enlightenment will emerge as a result of the separation of money and state. History has shown that any monetary currency clipped, removed, manipulated, or altered will always be exploited by human hands. Bitcoin removes these motives that have corrupted emperors, politicians, investors, and bankers alike, facilitating the road to serfdom. The hash function of SHA-256 and RIPEMD-160 aids in completely removing levels of exposure and seizure through public and private keys.

RIPEMD-160

Each part of the hash function plays a vital role, from managing Bitcoin addresses to bolstering the proof-of-work process. The RIPEMD-160, which is short for RACE Integrity Primitives Evaluation Message Digest, is used to help turn public keys into bitcoin addresses. There are five Ripe Message-Digest functions, but 160 is used in the Bitcoin network because it is highly secure and functional. RIPEMD-160 is used in the Bitcoin standard, which creates an alternative to lengthy public addresses. It is a more robust version of the RIPEMD-128 algorithm, which produces a 128-bit output. The process of hash function construction is challenging, especially given that it must accept strings of arbitrary length as input.

How this all works under the hood is a 65-bit private key is formulated, which generates an uncompressed public key. This public key is essentially your Bitcoin address, but it is a long series of digits after its initial inception. Padding is implemented to strengthen and prevent length extension attacks. For ease of use, the key is shortened or compressed with RIPEMD-160 down to 20 bits. This is where a compressed function comes into play. The protocol uses a checksum to check for mistakes via SHA-256, which hashes twice to validate the address is secure and correct.

Using RIPEMD-160 when creating Bitcoin addresses reduces the address space. This means that instead of having to type in very long addresses, they are reduced to a more manageable length. This process is a one-way function. Each public and private key is mathematical unique and cannot be duplicated, only shortened and compressed.

“SHA-256 is not going to be broken by Moore’s law computational improvements in our lifetimes. If it’s going to get broken, it’ll be by some breakthrough cracking method.” –Satoshi Nakamoto

SHA-256

Bitcoin uses the SHA-256 hash function in its proof-of-work process. Proof-of-work is considered the original cryptocurrency consensus mechanism. Bitcoin is the original and best example of that mechanism. At one point, difficulty adjustment was so low that mining could be achieved on computers with low hash power, such as a home computer. Over time, as the demand for more mined Bitcoin increased, the difficulty adjustment to earn one increased.

The difficulty to acquire Bitcoin has gone beyond what home computing power can accomplish. Mining computing hardware equipped with ASIC chips is the best choice to mine bitcoin. Currently, there is a lot of competition for hash rate, making it almost unprofitable to mine unless you have a high-end mining rig being fed off of cheap renewable energy. In comparison, if you are considering getting into mining bitcoin, do not forget you will be in competition with high-end major mining companies like Final Hash, Marathon Digital, and Riot Blockchain, Inc.

The cool part about SHA-256 is security and the ability to encrypt sensitive blockchain information that otherwise could be used to the detriment of the user. This security is immutable and runs on a consistent schedule. Secure hash algorithms help compile and sort out astronomical math equations to earn bitcoin by mining computers. The human intervention of the process is not needed and would be downright impossible to achieve even with the best calculators money could buy. A private key is a 256-bit number. A “bit” has a value of 0 or 1 and is the smallest unit of measurement for computer data.

Digital signatures are secured with private keys, meaning you can transact with Bitcoin monetarily under that key’s unique bit number. If you don’t have the correct private key, you cannot spend the bitcoin or gain access to any funds under the keys blockchain database. Therefore, these private keys must be correctly generated, then stored in a safe and secure location. Remember the saying coined by Isaiah Jackson, “No keys, No cheese.”

The possibility data is revealed from the hash value is so low it is considered impossible. The combinations of digits and data remove brute force attacks or hijacking of the network due to sheer complexity. In addition, it’s also severely unlikely that two data values (known as collision) have the same hash. After reading this essay, learning about hash functions when in doubt about Bitcoin’s security and possible exposure with corrupted public or private keys should be a breeze.

Those feelings of doubt should be quelled once you understand how well thought out and secure the encryption process is thanks to the genius of Satoshi. The Bitcoin network is designed to take money out of the hands of centralized control and into a permissionless decentralized world. The hash functions SHA-256 and RIPEMD-160 make this possible, in a functional one-way and secure fashion.

This is a guest post by Dawdu Amantanah. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc or Bitcoin Magazine.

Filed Under: Bitcoin Magazine, Cryptography, English, Hashes, ripemd-160, SHA-256, technical

Bitcoin Security: Trustless Private Messaging With Public And Private Key Cryptography

12/12/2021 by Idelto Editor

Message privacy, increasingly important to Bitcoiners, can be achieved with public and private key cryptography.

As a Bitcoiner, you’re going to need a secure way to communicate privately, without relying on a company to encrypt your data for you. For example, freely available methods with end-to-end encryption like Telegram (not with its default option) and Signal and others are easy to use, but I don’t completely trust them.

This article will show you how to send messages using free open-source software, GNU Privacy Guard (gpg), which allows encryption and decryption using public and private key cryptography. It’s more tricky at first to DIY, but once you get the hang of it, it’s not that hard. I’ll take you through it step by step, just follow along and bookmark this article for future reference.

This is a little more background about gpg (including pgp) for those who wish to dig deeper. It’s of interest to note that public and private key cryptography is not only used for encryption and decryption, but also used for the verification of digital signatures — used in Bitcoin transactions and also data in general (e.g., checking if the software you downloaded is genuine and not tampered with, as shown in the first video here).

How It Works

To make a public and private key pair, your computer generates a very large (“unguessable”) random number from which the gpg software will create for us a private key, and from that, a public key is created (just like Bitcoin private keys, more info here).

The public key is shared with the world (like a Bitcoin address) and contains your ID (email and name) which you publish online. Here is mine. Think of the public key like an open safe. Anyone can write a message and encrypt that message with your PUBLIC key (i.e., put it in your safe and lock the door shut) — only you have the private key and, therefore, only you can open your safe (i.e., decrypt and read the message).

A side note: Don’t worry about this for now — just note that, in Bitcoin, there is no “encryption” going on with payments. Instead, there are “signatures” made with private keys, which can be “verified” by anyone using public keys.

Overview

In this guide, I’ll take you through the following steps:

  1. Download gpg.
  2. Make your own private and public key.
  3. Store your private key to a USB drive.
  4. Upload your private key to your other computer’s’ keychain.
  5. Upload your PUBLIC key to a keyserver and/or your website.
  6. Upload your public key’s fingerprint to your online profile, e.g., Twitter or Keybase.
  7. Send me a message encrypted with my public key, and I will reply encrypting with your public key.

Download GPG

The first thing you’ll need to do is download the gpg software.

Linux

If you’re using Linux, gpg should already be installed. If not, you can install it with the command:

sudo apt-get install gnupg

If you just want to check if it’s installed, type this:

gpg –version

HINT: If you’re running a Bitcoin Node on a Raspberry Pi, you can actually use SSH to access your Pi’s terminal and run gpg commands like that. If what I said makes no sense, don’t worry, ignore it, it’s outside the scope of this article.

Mac

If you have a Mac, you’ll need to download and install “GPG Suite” — it’s free unless you also want the email tools (no need). This will give you the command line tools you need.

Windows

Download and install “Gpg4Win.” It’s free. There is a donation page before downloading, you can select $0 to proceed.

When installing, you can uncheck all the boxes except the first.

Make Your Own Private and Public Key

Open the terminal in Mac or Linux or command prompt in Windows.

Type:

gpg –full-generate-key

Choose the default RSA option.

Then choose the size of your key. Bigger is more secure.

Then select how long the key should be valid. I prefer not to let the key expire.

Then you’ll fill out some personal details. This will be made public so people know who the public key belongs to. The data actually gets embedded into the key. Choose “O” for “Okay” to proceed.

Then lock your private key with a “passphrase.”

I was advised to move the mouse around or type on the keyboard during key creation to add some extra randomness to the key. These are the details of the key I created (at the bottom).

Store Your Public Key To A USB Drive

The computer you used to create the private key has the key in its “keychain,” and it’s locked with a passphrase. The keychain is just an abstract concept — the key(s) are actually just stored in a file somewhere.

I suggest you backup your private key to a USB thumb drive. This allows you to copy it to a different computer if needed and reduces the risk of loss.

To do that, we first have to export it from the keychain and put it into a file.

Start by getting the key’s ID:

gpg –list-keys

This shows you all the keys (public and private) in your computer’s keychain.

Copy the key ID to the clipboard. Mine is:

D7200D35FF3BEDFDAB6E0C996565B2E40BC9A48F

Then we export the public keys to a file, and we need to put the key ID in the command (that’s why we copied it to the clipboard).

The above command uses gpg and has some options.

The “–output” option specifies that the output should go to a file, provided straight after.

I chose “public.gpg” ias the name of the file, and it will be created as the command is executed.

“–armor” specifies the output should be in ASCII-armored format and “–export” specifies which key from the keychain should be exported, provided straight after.

If you want to see the contents of the file, just use the “less” command (‘q’ exits the ‘less’ function):

less public.gpg

Next, let’s export the private key. The command is like the one before with some adjustments. Change the file name to something like “private.gpg” and change the “–export” option to “–export-secret-key.”

We now have “public.gpg” and “private.gpg” files in the current directory. Copy them to a USB drive and keep them safe and hidden. It’s not as sensitive as a Bitcoin private key, but the loss or theft of the “private.gpg” file would allow someone to impersonate you. If your passphrase is strong, it’s unlikely an attacker will be able to use your private key even if they got their grubby hands on it.

Upload Your Keys To Your Other Computer’s Keychain

Take your USB drive with your private key to your other computer. Make sure gpg is installed. Open a terminal and navigate to the location of your file. Enter the command:

gpg –import private.gpg

Remember “private.gpg” is a file name, so replace that with your file’s name, don’t just blindly copy the command without thinking. You will be asked to enter the passphrase, and then the private and public keys will be imported in one go.

To delete the private key, the command is:

gpg –delete-secret-keys KEY_ID

Substitute KEY_ID for the key ID or email of your key.

Upload Your PUBLIC Key To A Keyserver And/Or Your Website

There are several popular keyservers in use around the world. The major keyservers synchronize themselves just like Bitcoin nodes do, so it is fine to pick a keyserver close to you on the internet and then use it regularly for sending and receiving keys (PUBLIC keys, of course).

gpg –keyserver keyserver.ubuntu.com –send-key D7200D35FF3BEDFDAB6E0C996565B2E40BC9A48F

The above command is on one line. There is a space after “–send-key” which may not be obvious as the formatting on your browser may break the line into two.

“–keyserver” is an option that expects the web address of a keyserver next.

“–send-key” is an option that expects a Key_ID.

If you want to import a public key of someone else directly from a keyserver, enter the above command but change “–send-key” to “recv-key,” and use his or her Key_ID.

Upload Your Public Key’s Fingerprint To Your Twitter/Keybase

What’s the point of this? If you display a short version of your public key in various places, someone sending you a message can be more certain that they are downloading the correct public key.

You can see your key’s fingerprint with this command:

gpg –fingerprint KEY_email

With most of these commands, sometimes an email will work, sometimes it needs the exact KEY_ID. You can always see what your KEY_ID is with:

gpg –list-keys

Once you see your fingerprint, copy it and paste it into your online profiles as I have done on Twitter.

When you download my public key, the fingerprint will be displayed after you import it, or if you use the “–list-keys” command, or “gpg –fingerprint Key_ID”.

You can then check the output with my online profile to make sure you have the correct key.

Send Me A Message Encrypted With My Public Key, And I Will Reply Encrypting With Your Public Key

First, you’ll need to get my public key. You can browse to keyserver.ubuntu.com, and enter my email into the search field.

Or you can visit my contacts/gpg page and follow instructions there. Copy my Key_ID to the clipboard.

Open a terminal and enter this command:

gpg –keyserver keyserver.ubuntu.com –recv-keys e7c061d4c5e5bc98

You now have my public key imported to your computer’s keychain.

Now you can type a letter to me in a text file (letter.txt) or Word document (anything, really) and save it to disk. In a terminal, navigate to where you stored the file. Then type this command:

gpg –output letter.gpg –encrypt –recipient [email protected] letter.txt

Here you’ve got a command which will be all on one line. The “–output” option lets you create a filename typed immediately afterward, where the encrypted data will go.

The “–encrypt” option is an instruction to encrypt.

The “–recipient” option allows you to choose which public key in your keychain to use to encrypt the message. Immediately afterward, if you type in an email address, it will choose the right key from your keychain.

Finally, following the email or Key_ID, you put the name of the file you want to encrypt.

You might get some warnings and confirmation messages, but after that, you should have a new file called “letter.gpg” or whatever filename you chose. The original file still exists (“letter.txt”). You can delete that file with (using Linux or Mac):

rm letter.txt

You can also clear the history of the command prompt with:

history -c

You can then send an email and attach “letter.gpg” and send it to me. When I receive it, I will download it to disk first, then use this command to decrypt the file:

gpg –output decrypted_message.txt –decrypt letter.gpg

This will create a new file “decrypted_message.txt” using the encrypted data from “letter.gpg.” The computer can read which public key encrypted the data (so I don’t need to specify a Key_ID), and it can see it has the private key to that public key in the keyring, so it can use it to decrypt the message.

Conclusion

I’ve shown you the steps to create a private and public key for yourself, encrypt a message with my public key, and send me the message which I will decrypt with my private key.

If you send me your public key, or instructions to get it, I can encrypt a message and send you a message if you like.

Give it a go!

This is a guest post by Arman the Parman. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc or Bitcoin Magazine.

Filed Under: Bitcoin Magazine, Cryptography, encrypted messaging, English, Marty's Bent, Messaging, privacy, Private Key, public key, security, technical

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to Next Page »

Primary Sidebar

Archives

Recents articles

  • Indian Regulator SEBI Proposes Banning Public Figures From Endorsing Crypto Products
  • Iran Blocks 9,200 Bank Accounts Over Suspicious Foreign Currency, Crypto Transactions
  • Former Fed Chair Bernanke: Bitcoin Is Mainly Used in Underground Economy for Illicit Activities
  • Five Stalls That Caught My Attention At Bitcoin 2022’s Bitcoin Bazaar
  • How Bitcoin Should Be Upgraded In The Future
  • Grayscale Launches European ETF While Urging SEC to Approve GBTC Conversion Into Spot Bitcoin ETF
  • China Backed Publication: Terra LUNA Crash Vindicates Country’s Ban on Crypto-Related Activities
  • Bitcoin Songsheet: Wind And Solar Are The Altcoins Of Energy

© 2022 · Idelto · Site design ONVA ONLINE

Posting....