What is hashcash?, What is a hash function? What is its application?

In the White Paper of Satoshi Nakamoto said he used the idea of ​​Merkle Tree and Hashcash developed at least 10 years earlier. Merkle Tree applies the properties of hash functions (hash function) to concatenate chunks of information of any size into a fixed-length string of numbers. Since those “hash functions” are one-way, the information cannot be changed once it is “hashed” and that is the basis of the Blockchain that Nakamoto later invented.

What is Hashcash?

Hashcash is the first proof-of-work principle that is also based on the one-way nature of hash functions. But Hashcash has an interesting use in fighting spam mails. An email system if integrated with Hashcash will only allow sending emails to a certain address after the sender proves he has successfully solved the proof-of-work problem, similar to Nakamoto later forcing miners (miners). miner) prove to be rewarded with Bitcoin. In a nutshell, Hashcash is a form of electronic stamp that the email sender must “paste” in before the email is sent. The cost of stamping, ie solving the hashing problem, for an email is very small (<1 second) but spammers sending tens of thousands of emails will be very laborious.

In short, Kai Stinchcombe is not necessarily right when he thinks that blockchain technology has no application. But because the bitcoin craze and ICOs are so hot, no one cares about Merkle Tree and Hashcash anymore.

What is a hash function?

Hash function (hash function) is an algorithm to generate hash values ​​corresponding to each block of data (which can be a string of characters, an object in object-oriented programming, etc.). The hash value acts as a key to distinguish data blocks, however, people accept the phenomenon of key duplication or collision and try to improve the algorithm to minimize such collisions. Hash functions are often used in hash tables to reduce the computational cost of finding a block of data in a set (because comparing hashes is faster than comparing large blocks of data).

Because of the popularity of hash tables, today, most programming languages ​​provide an application library of hash tables, often called collection libraries, which have problems such as: collection, list ( list), table (table), mapping (mapping), dictionary (dictionary)). Usually, programmers just need to write hash functions for objects to integrate with the built-in hash table library.

A good hash function must satisfy the following conditions:

Fast calculation.
The keys are evenly distributed in the table.
There are few collisions.
Handles keys of different data types.

Applications of Hash Functions

Hash functions are used in many fields, and they are often tailored to each application. For example, cryptographic hash functions assume the existence of an adversary who can deliberately find inputs with the same hash value. A good hash function is a “one-way” transformation, that is, without a practical method to compute some input corresponding to the desired hash value, then tampering would be very difficult. . A typical cryptographic one-way function is not monomorphic and produces an efficient hash function; A typical cryptographic trapdoor function is one-to-one and produces an efficient random function.

Hash tables, an important application of hash functions, allow a quick lookup of a data record given the record’s key (Note: these keys are usually not as secret as in cryptography, but both Both are used to “unlock” or to access information.) For example, keys in an English-English electronic dictionary might be English words, the corresponding records of which contain definitions. . In this case, the hash function must map the alphanumeric strings to the indexes of the hash table’s internal array.

Hash functions for centralized error detection and correction distinguish the cases where data has been corrupted by random processes. When hash functions are used for checksums, a relatively small hash value can be used to verify that an arbitrary size data file has not been modified. The hash function is used to detect data transmission errors. At the sender, a hash is calculated for the data sent, this hash is sent with the data. At the receiving end, the hash is calculated again, if the hashes do not match then an error occurred somewhere in the transmission. This is called a redundancy check.

Hash functions are also used in audio recognition, such as determining whether an MP3 file matches a file in a list of another file type.

The Rabin-Karp string search algorithm is a relatively fast string search algorithm, with an average running time of O(n). This algorithm is based on using hashes to compare strings.

Nour

According to Tapchibitcoin