How to Create a Hashing Algorithm using Ethereum

2/19/2023, 8:05:06 AM - Eddu Oz
How to Create a Hashing Algorithm using Ethereum

What is Hashing?

Hashing is a concept that has its origin in software engineering that is now used in cryptography to secure or encrypt confidential information. This term is used to create hashing algorithms such as Ethash, SHA-256, Cryptonight, X11, and Scrypt.  

Practically, a hash is a fixed-length alphanumeric string that can be used to uniquely identify a text (e.g. a message, a program code, a name, etc.). Algorithms are used to compute a hash.

There are many hashing algorithms. To help you understand the concept better, I’ll create a dummy hashing algorithm to explain this concept later.

When a cryptocurrency holder initiates a transaction (sends payment), there are typically hundreds of thousands of miners competing to validate the transaction.

SEE ALSO: How to Mine Ethereum and Earn Better than Bitcoin

SEE ALSO: 5 Best Ethereum Wallets for Safe trading and Storage

SEE ALSO: 3 Key Things to Look out for When Buying a Hardware Wallet

The miner’s computer attempts to solve the mathematical puzzle through a process known as hashing.

The higher the hashing power, the higher the chances of guessing or solving the mathematical puzzle correctly.

The validation process is complete when a miner successfully adds the transaction and secures it to the blockchain network.

Before explaining hashing rate and how it is calculated, let’s see what happens behind the scene when a Bitcoin or altcoin is sent from one wallet to the another.

How a bitcoin wallet works

The miner earns a fraction of the mined token as a reward.

What differentiates one miner from another is the hashing rate or power.

How to Determine Hashing Rate of a Miner

Hashing rate is the power a mining computer hardware requires to solve complex mathematical algorithms.

Hashing power is measured in gigahertz per second (GH/s). The higher the GH/s, the more algorithms it can solve per second.

This ability translates into the miner’s ability to mine more coins and earn more tokens in the process.

The example below from ASIC Miner Value shows different Ethereum & Bitcoin mining models, their hash rate, algorithm, and profitability.

ASIC Miner Value

Let’s see an example of the volume of transactions validated by Ethereum miners daily.

Ethereum transactions per day

YCharts revealed that there were appropriately 1.716 million Ethereum transactions on May 10, 2021, and 1.183 million Ethereum transactions on June 11, 2021, which means that miners validated and earned a fraction from the value of those transactions.

To determine which of the computers will process the transaction, without being biased, all computers are open to compete and solve these huge volume, only a few will succeed.

Whoever completes the puzzle first gets the reward after the network confirms the miner’s proof of work.

SEE ALSO: How to Choose a Bitcoin Miner that Saves Electricity

SEE ALSO: How to Add Bitcoin Payment to Your Online Business

SEE ALSO: 10 Most Popular Ways to Earn Bitcoin for Free

How to Create a Hashing Algorithm

My dummy hashing algorithm is going to create 4-character alpha-numeric character identifications for texts.

My hash algorithm is made up of the following steps:

— Step 1: Get the numeric value of each character in the text

— Step 2: Sum up the numeric values

— Step 3A: If the sum doesn’t have up to 8 digits, repeatedly append “0” to it until it becomes 8 digits in length

— Step 3B: If the sum has up to 8 digits, select the first 8 digits, and discard the rest

— Step 4: Change the sum into its hexadecimal form

— Step 5: Select the first 4 characters in the hexadecimal form

Example:

If we’re to use my algorithm, to compute the hash of the text “Ethereum”, this is how it will go:

— Step 1: Get the numeric value of each character in the text

Using the table below, the numeric values of the characters in this text are:

— 5 for “E”,

— 20 for “t”,

— 8 for “h”,

— 5 for “e”,

— 18 for “r”,

— 5 for “e”,

— 21 for “u”, and

— 13 for “m”.

A1
B2
C3
D4
E5
F6
G7
H8
I9
J10
K11
L12
M13
N14
O15
P16
Q17
R18
S19
T20
U21
V22
W23
X24
Y25
Z26

— Step 2: Sum up the numeric values

5 + 20 + 8 + 5 + 18 + 5 + 21 + 13 = 95.

— Step 3A: If the sum doesn’t have up to 8 digits, append “0” to it until it becomes 8 digits in length

95 and “000000” gives “95000000”.

— Step 3B: If the sum has up to 8 digits, select the first 8 digits, and discard the rest

This step is not applicable since “95” is less than 8 digits in length.

— Step 4: Turn the sum into its hexadecimal form

The hexadecimal value of “95000000” is “5A995C0”.

— Step 5: Select the first 4 characters in the hexadecimal form

The first 4 character of “5A995C0” is “5A99”.

So, using my algorithm, the hash of “Ethereum” is “5A99”. Using SHA 256 (the hash algorithm used in Ethereum).

The hash of “Ethereum” is

“A13BEBEB57E1EA699BD4D2D9AC7E58399644E884B8A8783D96F6D146083F2430”.

Hashing Puzzle

Now, let’s return to hashing puzzle.

Ethereum typically gives out hashing puzzles that involve giving computers a text; the computers are expected to come up with a modification of that text that is —

  • just a single character different from the given text; and
  • has a hash that is smaller or equal to that of the given text.

For instance, you may be given a text like “Ethereum”, and you’ll be expected to come up with something like “Ethereum and “Ethereum” will be expected to have a hash value smaller or equal to

“A13BEBEB57E1EA699BD4D2D9AC7E58399644E884B8A8783D96F6D146083F2430”.

How to Create a Hashing Algorithm using Ethereum

To win this type of puzzle, a computer will have to modify the given value continuously, until the hash value of the new modification meets the desired criteria.

The number of times a computer can modify the given text and check the hash of the modification, per second, is what is known as “hash rate” or “hash power”.

Read More