ArticleslgStudy

computer science

SipHash

SipHash is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand SipHash rather than just read about it. In short: SipHash is an add–rotate–xor (ARX) based family of pseudorandom functions created by Jean-Philippe Aumasson and Daniel J. Bernstein in 2012, in response to a spate of "hash flooding" denial-of-service attacks (HashDoS) in late 2011.

Key takeaways

  • SipHash belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect SipHash to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of SipHash from memory before moving on to harder problems.

Reference excerpt

SipHash is an add–rotate–xor (ARX) based family of pseudorandom functions created by Jean-Philippe Aumasson and Daniel J. Bernstein in 2012, in response to a spate of "hash flooding" denial-of-service attacks (HashDoS) in late 2011. SipHash is designed as a secure pseudorandom function and can also be used as a secure message authentication code (MAC). SipHash, however, is not a general purpose key-less hash function such as Secure Hash Algorithms (SHA) and therefore must always be used with a secret key in order to be secure. That is, SHA is designed so that it is difficult for an attacker to find two messages X and Y such that SHA(X) = SHA(Y), even though anyone may compute SHA(X). SipHash instead guarantees that, having seen Xi and SipHash(Xi, k), an attacker who does not know the key k cannot find (any information about) k or SipHash(Y, k) for any message Y ∉ {Xi} which they have not seen before.

Overview SipHash computes a 64-bit message authentication code from a variable-length message and 128-bit secret key. It was designed to be efficient even for short inputs, with performance comparable to non-cryptographic hash functions, such as CityHash; this can be used to prevent denial-of-service attacks against hash tables ("hash flooding"), or to authenticate network packets. A variant was later added which produces a 128-bit result. An unkeyed hash function such as SHA is collision-resistant only if the entire output is used. If used to generate a small output, such as an index into a hash table of practical size, then no algorithm can prevent collisions; an attacker need only make as many attempts as there are possible outputs. For example, suppose a network server is designed to be able to handle up to a million requests at once. It keeps track of incoming requests in a hash table with two million entries, using a hash function to map identifying information from each request to one of the two million possible table entries. An attacker who knows the hash function need only feed it arbitrary inputs; one out of two million will have a specific hash value. If the attacker now sends a few hundred requests all chosen to have the same hash value to the server, that will produce a large number of hash collisions, slowing (or possibly stopping) the server with an effect similar to a packet flood of many million requests. By using a key unknown to the attacker, a keyed hash function like SipHash prevents this sort of attack. While it is possible to add a key to an unkeyed hash function (HMAC is a popular technique), SipHash is much more efficient. Functions in SipHash family are specified as SipHash-c-d, where c is the number of rounds per message block and d is the number of finalization rounds. The recommended parameters are SipHash-2-4 for best performance, and SipHash-4-8 for conservative security. A few languages use SipHash-1-3 for performance at the risk of yet-unknown DoS attacks. The reference implementation was released as public domain-like software under the CC0.

Usage SipHash is used in hash table implementations of various software:

Programming languages JavaScript Node.js V8 (JavaScript engine) (available as a compile-time option) OCaml Perl 5 (available as a compile time option) Python (starting in version 3.4, SipHash 1-3 since 3.11) Raku Ruby (SipHash 1-3) Swift Rust Operating systems Linux systemd OpenBSD FreeBSD OpenDNS WireGuard The following programs use SipHash in other ways:

Bitcoin for short transaction IDs Bloomberg BDE as a C++ object hasher InterPlanetary File System (IPFS) for its seven Bloom filter hashes Implementations

C (reference implementation) C++ (Wassenberg & Alakuijala 2017, part of their "highwayhash" work) C# Common Lisp Crypto++ Go Haskell JavaScript PicoLisp Rust Swift Verilog VHDL

See also Bloom filter (application for fast hashes) Cryptographic hash function Hash function Message authentication code List of hash functions

References

External links Jean-Philippe Aumasson; Daniel J. Bernstein (2016-08-01). "SipHash: a fast short-input PRF – Project Page". GitHub. Jean-Philippe Aumasson; Daniel J. Bernstein (2012-09-18). "SipHash: a fast short-input PRF" (PDF). Jean-Philippe Aumasson; Daniel J. Bernstein (2012-08-15). "SipHash: a fast short-input PRF – Presentation slides" (PDF). Jean-Philippe Aumasson; Daniel J. Bernstein; Martin Boßlet (2012-12-29). "Hash-flooding DoS reloaded: attacks and defenses". "Hashing". The Rust Performance Book. – describes when SipHash is not fast enough

Worked examples

Example 1 — a first encounter with SipHash

Start with the simplest possible case. Write down what SipHash claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to SipHash before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about SipHash ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of SipHash

In research
SipHash appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses SipHash in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
SipHash is common in secondary-school and first-year university syllabi. It links to neighbouring topics Creative Commons-licensed works, Hash function (non-cryptographic), Public-domain software with source code, so understanding it makes those chapters shorter.
In everyday life
Look for SipHash outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “SipHash” →

How to study SipHash in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what SipHash means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain SipHash out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is SipHash in simple terms?

SipHash is an add–rotate–xor (ARX) based family of pseudorandom functions created by Jean-Philippe Aumasson and Daniel J. Bernstein in 2012, in response to a spate of "hash flooding" denial-of-service attacks (HashDoS) in late 2011.

Why does SipHash matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study SipHash?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on SipHash.

Tags

  • Creative Commons-licensed works
  • Hash function (non-cryptographic)
  • Public-domain software with source code

Keep exploring