Blockchain I Keccak-256 hashing algorithm

Gepubliceerd op 10 september 2023 om 10:08

Anyone sending Ethereum from A to B will be using the Ethereum blockchain. Each transaction will use the Keccak-256 hashing algorithm. This algorithm is used when a transaction is signed.

Keccak-256 is an algorithm that allows information to be converted to an unreadable hash. By an unreadable hash, we mean a string of letters and numbers that can be thought of as a secret code. An input can be converted into a set of characters through Kecccak-256, leaving the original text unreadable.


The hash in short

For completeness, a hash is the process of converting an input into an output. The input can be anything, a transaction, text, etc. The output is a string of letters and numbers that doesn't say much. Someone who sees the hash cannot tell what the transaction or text was.

Hashing is encoding data (input) to a hash (output). This means that you can convert a text into a kind of secret code. At first glance, such a hash appears to consist of a number of randomly chosen characters. But in reality, it is not so random at all. What the hash looks like is determined by the hashing algorithm that is used. Such an algorithm converts a transaction to a hash according to a certain logic. Therefore, the same content will always look like the same hash.

With a secure hashing algorithm, no one knows how the algorithm actually works. This ensures that while you can convert the content to a hash, you cannot determine the content from the hash. There are also some algorithms that have been broken over time, such as MD5. With these algorithms, they managed to crack the logic behind the algorithm so that the outcome could be converted into the input. Why is that such a bad thing? It is then no longer possible to actually secure data. After all, anyone can see the data (the input). There are several tools available on the Internet that allow you to convert MD5 hashes back to its original content (input).

Keccak-256
Keccak-256 is a hashing algorithm that stems from the SHA-3 family. This means that in many ways it is similar to the SHA hashing algorithm. Yet there are differences.

With Keccak-256, it is possible to convert an input to a hash output. This output always has a fixed length: the length consists of 256 bits. Keccak-256 is a one-way hash function. This means that the hash only works one way. So you can convert the input to a hash, but it is not possible to determine the content from the hash.

The creation of the hash is not done using keys. When data is secured with a public and private key, we talk about encryption or cryptography. Cryptography is often confused with hashing. However, both techniques are used for cryptocurrencies. Keccak-256 is in fact the hashing algorithm of Ethereum (ETH) and thus quite different from cryptography and the public and private keys. However, they are two essential parts of blockchain technology and you need both for the network to function properly. Read here for more about public and private keys and cryptography!

Hashing: do it yourself!

What a hash looks like is determined by the content we are hashing. Click here

Example: we are hashing consensus based:

8723b4ff6d15f1c54512b28b6d6ec4b455acc781a5ccab1fe7d9735d3235d20d

Or we hash: Consensus Based with the C and B as capital letters:

02fb1d812deb8e798b4de71c6ca5428202007ad8515158f5f2fc07a885942c0e

What is Keccak-256 used for?
Keccak-256 is primarily used by Ethereum. We see that not only centralized systems use hashing algorithms. Decentralized systems, to which the blockchain belongs, also use hashing protocols. This is highly necessary because sensitive data is stored on the blockchain, just like on any other central server or computer.

If data were stored on a blockchain without a hash, it would be possible for anyone to see the data. That would mean that the data is not stored 100 percent secure. Instead, it is better to store data encrypted: you will only see a hash. From this hash you cannot determine what the content looks like. As an outsider, this hash is of no use to you.

Whereas algorithms such as SHA-256 are often used for storing passwords and checking the integrity of data, Keccak-256 is mainly and only used by Ethereum's blockchain. Keccac-256 is considered one of the most secure algorithms. 

Digital signatures
When a transaction is performed on the blockchain, we sign it with a digital signature. For such a digital signature, you need a public key and a private key. Combining these together creates a new outcome. This outcome is secured with Keccak-256.

How secure is Keccak-256?
Currently, Keccak-256 is a secure hashing algorithm. In fact, the algorithm has never been broken. This means that no one has been able to reverse a hash to its contents. Therefore, the moment data is converted to a hash using the Keccak-256 algorithm, the hash can be stored securely.

Why is Keccak-256 so secure?

  • Works one way - You can convert information to a hash, but it is impossible to convert a hash back to its contents. This means you can safely store the hash and no one can do anything malicious with it.
  • One change creates a completely different hash - Even if you change just one bit, letter or character, the hash looks completely different. This makes it impossible to unravel the logic behind the algorithm.

Keccak-256 vs. SHA-256

  • Keccak-256 is used by Ethereum, while SHA-256 is used by Bitcoin (BTC). They are both used as a hashing algorithm, although they differ from each other.
  • SHA-256 stems from the SHA-2 standard with a 256-bit key, while Keccak-256 is a feature within Solidity (Solidity is the programming language of Ethereum) and stems from the SHA-3 family.
  • SHA-256 generates an SHA-256 hash, while Keccak-256 generates a Keccak-256 hash.

Pros of Keccak-256

  • It has infinite input space. This makes it possible for developers to hash large amounts of text with Keccak-256 (for example, SHA-256 has a maximum space of 264 bits).
  • The entire hash appears different when even one bit of data within the input changes. This makes a hash extremely secure because it is impossible to find the logic behind the hashing algorithm.
  • Computers and machines can create Keccak-256 hashes at lightning speed, so the algorithm contributes to the rapid operation of decentralized applications running on the blockchain.
  • Keccak-256 is used within Solidity. Solidity is most widely used and popular programming language for dApps. This means that the majority of blockchain developers can use a secure hashing algorithm such as Keccak-256.

Cons of Keccak-256

  • It is not 100% certain that Keccak-256 will always remain secure. In the future, a computer could break the algorithm because computers are getting smarter and faster. So it remains to be seen if we can always use Keccak-256 for Ethereum. Also, we don't know what happens when the algorithm breaks. On the other hand, if Keccak-256 breaks, we already have a new hashing algorithm that is better and faster than Keccak-256. 

Reactie plaatsen

Reacties

Er zijn geen reacties geplaatst.