Hamsi Explained: The SHA-3 Candidate With a Message That Expands

Hamsi explained in plain terms means understanding the hash that entered the race to replace SHA-1 and SHA-2 with a compression function that stretches every message block before it is mixed, a design from 2008 that reached the second round of NIST’s SHA-3 competition before falling short. The central question is why a hash would expand its message instead of compressing it straight away, and the answer is that Hamsi’s expansion gives the mixing step far more material to work with, so a small change in the message spreads further, and that spreading is the whole point of the design.

Hamsi is a cryptographic hash function submitted to the NIST hash function competition in 2008 by Özgül Küçük. It turns a message of any length into a fixed-size fingerprint of 224, 256, 384 or 512 bits, and it is built around a compression function that first expands each 32-bit message block into a much larger form, which means the design does its hardest work before the mixing even starts, and that order of operations is what makes it unusual.

This article makes the case for Hamsi, explains what it is, how it works, and where its ideas still earn their keep.

Key takeaways

  • Hamsi is a SHA-3 candidate from 2008.
  • It expands each message block before mixing it.
  • It reached the second round of the NIST competition.
  • It offers digests from 224 to 512 bits.
  • It is used in research and in hash history today.

What Hamsi is

Hamsi is a hash that turns a message into a short fingerprint, and that fingerprint is what lets software check whether a file or a message has changed. A user feeds in a document of any size, Hamsi processes it in blocks, and out comes a fixed-length digest, which means two different files should never produce the same digest, and that promise is the whole point of a hash function.

Its signature feature is the message expansion. Most hashes feed each block straight into the compression function, but Hamsi first stretches a 32-bit block into a far larger set of words, which means the mixing step sees many versions of the same message, and because those versions are all tied together, changing one bit changes the expansion everywhere.

The design was a reaction to the SHA-1 crisis. By 2008, researchers knew SHA-1 was weakening and SHA-2 might share its flaws, so NIST asked the world for a replacement, and the Hamsi design answered with a hash that trusted a simple expansion and a familiar S-box, because parts that have been studied for years are easier to trust than parts invented for the occasion.

It became one of the best-known second-round candidates in the world, and it is named in the histories of the SHA-3 competition. Hamsi was one of fourteen designs chosen for the second round from sixty-four submissions, it was studied intensely for a year, and it was eliminated when NIST picked its five finalists, which means the design reached the last sixteen of a global contest and fell just short of the final.

Its most famous property is the S-box at the heart of the compression function. Hamsi’s mixing step uses a small substitution table applied again and again, which means the design gets its confusion from repetition rather than complexity, and because the table is fixed and public, anyone can study exactly what the hash does.

Our guide to SHA-3 explains the standard that won the contest Hamsi entered, and our guide to HAVAL explains another hash that varied its design by digest size.

How Hamsi works

Everything starts with the state, a set of words that carries the running fingerprint from one block to the next. Hamsi initialises that state from the requested digest size, which means the same algorithm can produce a 224-bit or a 512-bit digest, and because the initial state depends on the size, the two versions behave like different hashes from the first step.

Each block begins with the expansion, which stretches the 32-bit message block into many more words. The expansion mixes the block with itself at different offsets, which means the expanded form carries the block’s information several times over, and because the expansion is fixed, the same block always expands the same way.

The compression is what makes the design work as a whole. The expanded message is combined with the state and passed through rounds of substitution and diffusion, which means every word of the expanded message meets the state, and because the rounds repeat, a single changed bit fans out across the whole state.

The S-box spreads the effect further. It takes small groups of bits and replaces them according to a fixed table, which means the relationship between input and output stays non-linear, and because the S-box runs on every word, the non-linearity is spread evenly through the whole computation.

The finalisation is what turns the state into a digest. After the last block, Hamsi runs its compression function several more times with no new message, which means the state is stirred clean of any trace of the padding, and because the finalisation uses the full state, the digest depends on the whole message and nothing else.

The digest comes from the final state, trimmed to the length the user asked for. Hamsi takes the state words and outputs as many bits as requested, from 224 to 512, which means one algorithm serves every digest size, and that shared core is what makes the variable output possible.

A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it
A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it, shows how Hamsi works: message blocks take turns expanding and mixing, round after round, until a fingerprint emerges.

Comparing Hamsi with other SHA-3 candidates

Hamsi is one of several hashes that entered the SHA-3 competition, and each was built with a different emphasis. Keccak is the sponge that won the contest with a simple absorbing design, Grøstl is the wide-pipe finalist built from AES-like permutations, and Hamsi is the one built on message expansion with a small S-box, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect Hamsi Keccak Grøstl
Construction Expansion-based Sponge Wide pipe
Output sizes 224 to 512 bits 224 to 512 bits 224 to 512 bits
Core step S-box rounds Permutation Permutation
Contest round Round 2 Winner Finalist
Best for Hash history Standard use Research

The practical result is that Hamsi is the right choice for hash history, Keccak suits standard use everywhere else, and Grøstl fits research instead.

Where Hamsi is used

Research uses it as a case study in message expansion. Cryptographers still cite Hamsi when they discuss designs that stretch the message before mixing it, because it is the clearest example of the idea in a practical hash, and that lesson shapes how new compression functions are judged today.

Teaching uses it to show the SHA-3 contest. Cryptography courses introduce Hamsi when they explain how NIST ran its competition, because it is a strong design that still lost, and a student who understands Hamsi understands that a contest is won on the whole package, not on one clever idea.

History uses it to tell the story of 2008. The SHA-3 competition is one of the great stories of modern cryptography, and Hamsi is remembered wherever that story is told, which means it survives as history long after it stopped being a serious tool.

Benchmarks use it to measure expansion-based hashes. When someone builds a new library or a new piece of hardware, Hamsi is one of the designs they test, because its expansion step exercises different parts of a processor than other hashes do, and a platform that runs Hamsi well is likely to run most expansion designs well.

Standards history uses it to mark the expansion path. Hamsi was part of the international effort that produced the world’s hash standard, and it represents the message-expansion approach that contest explored, which means historians of the field return to it whenever they ask what else the contest could have chosen.

Strengths and limits

The greatest strength of Hamsi is its thorough mixing. A hash that expands its message before compressing it gives every bit many chances to influence the state, and that thoroughness is real, measured in the diffusion that analysts praised and confirmed by the year of study it survived.

It is also a strength that the design is built from familiar parts. A compression function made of an S-box and a linear layer is easy to implement and easy to analyse, and that simplicity is worth more than cleverness in a field where hidden complexity usually means hidden flaws.

The limits are real, though, and the biggest is that it lost the contest. NIST chose Keccak as SHA-3, and Hamsi has never earned the deployment or the review that a standard enjoys, which means Hamsi must never be used for anything that needs real protection today, and its value is entirely as a lesson.

Hamsi checklist

  • Use Hamsi for study and history, never for new security.
  • Remember it is a SHA-3 candidate from 2008.
  • Study its message expansion to understand thorough mixing.
  • Compare it with Keccak to see the contest trade-off.
  • Note it reached round two but not the final five.
  • Try its variable output to see one design serve many sizes.
  • Keep real secrets behind standard hashes, not Hamsi.
  • Read the contest story to see how SHA-3 was chosen.
  • Choose SHA-3 for any system that needs a standard today.

Frequently asked questions

What is Hamsi in simple terms?

It is a hash function from 2008 that turns any message into a fingerprint, built around a compression function that first expands each small message block into a much larger form before mixing it.

Who designed Hamsi?

Özgül Küçük, who submitted it to NIST’s SHA-3 competition in 2008 as one of sixty-four entries.

How is Hamsi different from Keccak?

Both entered the SHA-3 contest, but Hamsi expands each message block and mixes it through S-box rounds, while Keccak is a sponge that absorbs the message and squeezes out the digest.

Is Hamsi still secure?

Yes, no practical attack against it has been published, though it lost the SHA-3 contest and has never had the review or deployment of a standard, so it is not a safe choice for new systems.

Where is Hamsi used?

In research, in teaching about the SHA-3 competition, and in hash history, wherever a strong design that still lost is needed as an example.

When should I use Hamsi?

When you study message-expansion hashes, when you tell the story of the SHA-3 contest, or when you want a candidate that reached the second round.

The bottom line

Hamsi explained in one line is this: the expanding hash, a 2008 design that stretched every message block before mixing it and reached the second round of the race for SHA-3.

It is proof that expansion can carry a design a long way, and the reason it still matters is that every hash designed since has been judged partly by the lesson Hamsi taught.

This article is general information about how Hamsi works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top