*Publicidad pagada. No es asesoramiento financiero. RugDoc no se hace responsable de los proyectos aquí expuestos. DYOR y mantente seguro.

Introduction to Ethereum’s Keccak-256 Algorithm

Introduction to KECCAK-256 (1)

Have you ever executed a transaction on the Ethereum (ETH) blockchain? Then you have used the Keccak-256 hashing algorithm. You might ask yourself: huh, did I really do that? Yes, because you use Keccak-256 to sign a transaction on Ethereum.

Keccak-256 is an algorithm that allows us to convert information into an unreadable hash. By an unreadable hash we mean a string of characters that you can see as a kind of secret code. We can convert a text with Kecccak-256 into a set of characters so that the original text remains secret.

There are many reasons to use a hashing algorithm on a blockchain like Ethereum. Let’s take a quick look at what Keccak-256 is and how this hashing algorithm works.

How does hashing work? #

Hashing is encoding data into a hash. This means that we 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’s not that random at all. What the hash looks like is determined by the hashing algorithm used. Such an algorithm converts a string into a hash according to a certain logic. Therefore, the same content will always look like the same hash.

With a secure hashing algorithm, nobody knows how the algorithm actually works. This ensures that you can convert the content to a hash, but that you cannot determine the content based on the hash. There are also some algorithms that have been broken over time, such as MD5. With these algorithms, we succeeded in cracking the logic behind the algorithm, so that the outcome could be converted into the input. Why is that so bad? It is then no longer possible to actually secure data. Everyone can view the data. There are several tools available on the internet that allow you to convert MD5 hashes back to the content.

Keccak logo

What is Keccak-256? #

Keccak-256 is a hashing algorithm that comes from the SHA-3 family. This means that in many ways it resembles the SHA hashing algorithm. Yet there are also differences, which is why the name between the algorithms also differs. What these differences are, we will explain further in this article.

With Keccak-256 it is possible to convert an input to a hash output. This output is always a fixed length: it consists of 256 bits (bytes32). 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 based on the hash.

The hash is not created using keys. When data is secured with a public and private key, we speak of encryption or cryptography. Cryptography is often confused with hashing. However, both techniques are used for cryptocurrencies. Keccak-256 is the hashing algorithm of Ethereum (ETH).

The Keccak family #

Keccak-256 is part of the Keccak family. In addition to Keccak-256, there are a number of other hashing protocols that fall within the Keccak family. These are:

  • Keccak-224;
  • Keccak-384;
  • Keccak-512.

What is Keccak-256 used for? #

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

If we were to store raw data on a blockchain, it would be possible for everyone to view the data. That would mean that the data is not stored 100% securely. Instead, it is better to store data encrypted: you will then only see a hash. You cannot determine what the content looks like from this hash. As an outsider, this hash is therefore of no use to you.

While 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 the Ethereum blockchain.

Keccak-256: The hashing algorithm of Ethereum (ETH) #

The Ethereum blockchain uses the Keccak-256 hashing algorithm. Specifically, Keccak-256 is used within Ethereum’s Ethash engine. That already starts with Solidity; this is the programming language that developers use on the Ethereum blockchain. Within this programming language, a hash function must encode the data input. This is necessary to encode all ‘contract calls’ (invoking a smart contract) to the EVM. The EVM (Ethereum Virtual Machine) is the machine where developers develop their decentralized applications (dApps).

Digital signatures

When we perform a transaction on the blockchain, we sign it with a digital signature. For such a digital signature you need a public key and a private key. By combining these with each other, a new outcome is created. This outcome is secured with Keccak-256. The algorithm therefore has a very important role in the execution of transactions.

The blockchain #

A block consists of a large number of transactions. These transactions have been validated by the validators in the Ethereum network. The transactions are then aggregated and converted to a hash. This is done by means of Keccak-256.

Before that happens, the hash of the last block is first added to the new block. Only then is the new block converted to a hash. What the hash looks like is determined by the content of the block. Should a criminal/hacker ever want to change the history of the blockchain by modifying a block, the block’s hash will change. Then all the hashes of the blocks added next will change. There is clearly a break in the chain.

The moment this happens, all nodes in the network will notice the break. The version of the blockchain that has been modified is then not adopted by the nodes. Hashing therefore plays an important role in the security of the blockchain.

The pros and cons of Keccak-256 #

This hashing algorithm has its own advantages and disadvantages. The algorithm is therefore more suitable for one application than for another.

Pros #

  • It has infinite input space. This allows developers to hash large amounts of text using Keccak-256 (for example, SHA-256 has a maximum space of 264 bits).
  • The entire hash comes out different when even one bit of data within the input changes. This makes a hash extremely secure, as it is virtually impossible to find the logic behind the hashing algorithm.
  • It is virtually impossible for the output of data to be the same, which makes performing a brute-force attack on Keccak-256 pointless.
  • Computers and machines can create Keccak-256 hashes at lightning speed, so that the algorithm contributes to the fast operation of the decentralized applications that run on the blockchain.
  • Keccak-256 is used within Solidity. Solidity is the most used and most popular programming language for dApps. This means that the majority of blockchain developers can use a secure hashing algorithm such as Keccak-256.

Cons #

It is not 100% sure that Keccak-256 will always be safe. In the future, a computer could break the algorithm, as computers become smarter and faster. So the question is whether we can always continue to use Keccak-256 for Ethereum. Also, we don’t know what happens when the algorithm breaks.

How safe is Keccak-256? #

At the moment, Keccak-256 is a secure hashing algorithm. The algorithm has never been broken. That means no one has been able to reverse a hash to its contents. The moment data is converted to a hash using the Keccak-256 algorithm, the hash can therefore be safely stored.

The fact that Keccak-256 is so safe is of course not entirely without reason. There are several reasons why Keccak-256 is so safe:

  • Double output virtually impossible – The chance of a so-called ‘collision’ occurring is virtually nil. The number of possible outcomes is greater than the number of atoms in our universe. This indicates how low the probability of a collision is.
  • Works one way – You can convert information to a hash, but it is impossible to convert a hash back to the content. This means that you can safely store the hash and no one can do anything malicious with it.
  • One change makes a completely different hash – Even if you change just one bit, 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. Let’s take a look at the main differences between Keccak-256 and SHA-256.

  • SHA-256 stems from the SHA-2 standard with a 256 bit key, while Keccak-256 is a function within Solidity and stems from the SHA-3 family.
  • Keccak-256 is stronger than SHA-256.
  • SHA-256 generates a SHA-256 hash, while Keccak-256 generates a Keccak-256 hash.
  • Ethereum uses Keccak-256 within its Ethash consensus engine, while Bitcoin uses SHA-256 for transaction hashes and BTC mining.

Conclusión #

Keccak-256 is the hashing algorithm of the Ethereum blockchain. This algorithm secures the data on Ethereum. A hashing algorithm ensures that information is converted into a hash. This hash looks like a set of random characters, although it’s actually not that random at all. An algorithm determines what the hash looks like.

It is impossible to convert a hash back to the content. Therefore, we can only use hashing to compare its output (the hash) with each other. This way we know whether the content is the same, without actually retrieving the content. When even one bit looks different, the whole hash looks different too. This makes a hashing algorithm like Keccak-256 secure.

Actualizado el noviembre 30, 2022
¿Qué sientes respecto a éste artículo?

Dejar una Respuesta

*Publicidad pagada. No es asesoramiento financiero. RugDoc no se hace responsable de los proyectos aquí expuestos. DYOR y mantente seguro.