Blockchain Basics: Hashing

Blockchain Basics: Hashing

Lightbulbs, bits and bytes

You may know that all data in a computer is composed of 0 or 1. The smallest unit of data is a bit, which is also 0 or 1. Imagine a computer with many light bulbs, and the light bulbs have two states, on (1) or off (0). Different data will display different patterns by the light bulbs. Big data such as videos use quite a lot of light bulbs, while a short email requires fewer light bulbs. A single light bulb represents a bit. In addition, you may have heard of a word called byte, which is equivalent to the combination of 8 light bulbs. 1MB of data is about 1 million bytes, which is equivalent to 8 million light bulbs.

Today, home computers have billions or even trillions of light bulbs. But we found that even a collection of 256 light bulbs is enough to represent any particle that can be observed in the universe. Imagine all the patterns that a group of 256 light bulbs can produce, which is an astronomical number: that is, 2^256 possibilities.

Cryptographic Hash Function (or Cryptographic Hash Function)

A hash function function, that is, taking any input, can produce an output of a specific size. The process of applying a hash function and then producing certain data is called hashing or transliterated as hashing. The output of a hash function is called a hash . The basic characteristic of a specific hash function is the size of its output. For example, in the example in this article, we use a hash function that produces an output of 256 bits (32 bytes). Of course, there are hash functions that can produce smaller outputs, or larger outputs, and there are other hash functions that can produce 256 bits, but in this example, we don’t care about the specific hash function used.

Using this example hash function, when an N-MB video is hashed, the output is: some of the 256 light bulbs are lit. When a short email is hashed, the output of the 256 light bulbs shows a different pattern. In some ways, hashing looks like压缩. To explain the difference simply, hashing will always produce the same number of light bulbs, while compressing an N-MB video will still produce an output of millions of light bulbs. A compressed video can be decompressed to get the original video. When a video is hashed to only 256 light bulbs, the probability of reconstructing the original video from the hash is very small. This may not sound ideal, but it is actually a powerful feature of hashing functions.

A key feature of a secure cryptographic hash function is that it is单向. This means that, from a mathematical and computer science perspective, it is almost impossible to infer the input from the output. In other words, given a hash, it should be impossible to understand or find out the input data provided to the hash function. In technical terms, we call this pre-image resistance resistance.

The result is that a hash function should take about the same amount of time whether hashing a larger or smaller input. Another desirable result is that the hash, or the pattern of light bulbs produced by the hash function, should appear随机, with the pattern of light bulbs produced by hashing the data "password1" being very different from the pattern of light bulbs produced by hashing the data "password2". Otherwise, if the patterns were similar, an adversary could infer that the inputs were similar, and if related words (e.g., "pass", "word") were found, the passwords could be easily discovered. A secure hash function produces significantly different outputs even if the inputs differ by only one bit.

The ideal behavior for security is that given a hash, the only way to find the input data is by hashing all combinations of inputs until the correct input is hashed. If the input is random, then the time to find it is uncertain.

While finding the input for a hash should be very difficult and take a long time, computing a hash is very fast. A hash function with a large input may produce an output in less than a second. Considering that today's smartphones are capable of billions of calculations per second, 1 second is a long time for computing.

Cryptographic hash functions should also be collision resistant resistant. A collision occurs when a hash function produces the same output when applied to more than one input. If hashing data 1 (perhaps a spreadsheet) and hashing data 2 (perhaps an image) produces the same output, then a collision has occurred .

The importance of cryptographic hash functions and their security will become clearer when we describe the blockchain and hashing section.

Blockchain and Hashing

Hashing is widely used in blockchain, and here are some examples.

Addresses on the blockchain are derived by hashing a public key. An Ethereum account address is derived by hashing a public key with Keccak-256 (developers should read the key differences between it and SHA3-256). A Bitcoin address is derived by hashing a public key with SHA2–256 and RIPEMD160.

Collision resistance of hash functions is important because if 2 people generate the same address (a collision occurs), then either party can spend the money at that address.

Signatures are also a fundamental component of blockchain. Similar to signing a check, cryptographic signatures determine which transactions are valid. Signatures are generated by a private key and a hash of the data to be signed.

Transaction hashes are very visible in the blockchain. For example, if you describe a transaction as "Alice sent X units of currency to Bob at T on D day", then transactions will be submitted as their hashes, such as 5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060 is a transaction in the Ethereum blockchain. Transaction hashes are also more directly usable, such as "Transaction 1024 in 1337 blocks". You can just copy this hash and paste it into a blockchain browser to view the details of the transaction.

Metaphysically, blocks in a blockchain are identified by their hashes, which serve the dual role of authentication and integrity verification. An identification string also provides its own integrity and is called a self-certifying identifier.

For blockchains that use mining mechanisms, Proof-of-Work is a number, called a nonce, that, when combined with other hashed data, produces a value smaller than the specified target value. Mining makes hashing a fast, one-way, irreversible algorithm. Finding a valid nonce takes time because there are no clues available to help them find a small enough hash, and the only way to find one smaller than the target value is to calculate a lot of hashes: in Bitcoin, there are currently more than 10^25 (10 septillion) hashes. When a nonce is found, it takes 1 second to verify it, and then the new block is broadcast on the network, forming the latest consensus and blockchain.

The data stored on the blockchain is permanent, but it is unwise to store a large amount of data on the blockchain. The practical blockchain storage method is to store fixed-size (usually small) data representations on the blockchain, which we call "data hashing". One application of the blockchain is as a timestamp service. Suppose you want to prove that a picture currently exists to ensure that it is not fabricated in the future. You can store the hash of the picture on the blockchain. One year later, when the judge asks whether the picture really existed a year ago, you can provide the picture, and then the judge can hash the picture and compare it with the hash you stored on the blockchain.

Hashing also involves more advanced examples, such as blockchain, scalability, and the Merkle tree tree, which is the root of light wallet innovation.

Hashes for secure identification

Secure cryptographic hash functions are one-way, fast to compute, and collision-resistant. Combining these features, they process any type of input and produce a fixed-size output, called a hash, which is very useful as an identifier for any data. A hash of 256 bits in length represents an astronomical number of combinations, which is more than enough to use them as unique identifiers for the global Internet of Things. Even at the nanoscale, these hashes can be written as 64 characters (hexadecimal), which makes them sufficient for use as identifiers. In blockchain, hashes are used as identifiers for blocks, transactions, and addresses .

Hashes also have the advantage of security and privacy. If a song is recorded in digital format, and the hash of the song is recorded on the blockchain, no one else can claim that they were the first to create the song and generate the hash, nor do they know the song itself: someone cannot write the song, nor can they tamper with the hash. Similarly, unless a song or other digital property or data is identified, only the hash itself is displayed on the blockchain. Ownership records can also be stored on the blockchain. For a simple example, a car registry can store a hash of car data (photos, VIN, license plate) on the blockchain, and only the car owner, insurance company and government will know the actual details of the car.

In-depth theory, extensive application

Designing cryptographic hash functions is a combination of art and science. To prove their security, advanced mathematics and computer science are required. Blockchain is the first hash-filled user interface for the general public. A good user experience hides a lot of hashes, but as we see with various IDs and serial numbers today, sometimes hashes are the best identifiers to replace long text. As encryption and IoT technologies become more popular, I hope to see more 64-character hashes in the future!

Original article: https://medium.com/@ConsenSys/blockchain-underpinnings-hashing-7f4746cbd66b#.94m1n6n3b
By Joseph Chow (ConsenSys).
Photo: Bogdan Burcea
Translation: Free and easy
Source (translation): Babbitt Information (http://www.8btc.com/blockchain-und…nnings-hashing)


<<:  How can bank card organizations use blockchain currency to expand their business?

>>:  21 Bitcoin Computer opens Bitcoin payment method

Recommend

Facial features of poor relationship between mother-in-law and daughter-in-law

Facial features of poor relationship between moth...

Canadian regulators approve the first legal ICO project. What’s going on?

ICOs have been outlawed in China, but on the othe...

What is the success line?

Most of the scholars who study palmistry do not d...

What does BTC breaking through 6,000 mean for the market?

FXStreet analyst: After half a year, BTC official...

Coin Zone Trends: Bitcoin Price Trends Based on Big Data This Week (2017-05-15)

The bullish pattern remains unchanged and waits f...

What is the future of digital currency as regulation continues to increase?

Digital currency is ushering in the long-awaited ...

Numbers Don’t Lie: Bitcoin Short Selling Pressure Is Easing

Last week, the cryptocurrency market saw a surge ...

Physiognomy teaches you what kind of people will have unexpected wealth

From a person's face, you can really tell whe...

How to tell your fortune from your feet

How is a person's fortune from the feet? What...

How to read the face and what does the hooked nose represent

People with hooked noses are usually more insidio...

Is it a good fortune for a person with whorls on his hairline?

Everyone is born with his or her own hairline, un...

Judging the gender of a pregnant woman from her facial features

Is the baby in my belly a boy or a girl? From the...