Cuckoo hashing is a collision resolution technique that guarantees worst-case constant lookup time by using two hash functions to place each key in one of two possible buckets. When a collision occurs, the existing key is evicted and rehashed to its alternate location, potentially displacing another key in a cascading process until all keys find a stable position or the table is rehashed.
Glossary
Cuckoo Hashing

What is Cuckoo Hashing?
A hashing scheme that resolves collisions by relocating existing keys using multiple hash functions, commonly used in PSI protocols to optimize storage and reduce communication complexity.
In private set intersection protocols, cuckoo hashing maps elements into bins to reduce the number of comparisons required, enabling sublinear communication complexity. The KKRT protocol leverages this structure to achieve highly efficient semi-honest PSI by ensuring each bin contains at most one element, allowing the use of oblivious transfer instead of more expensive circuit-based comparisons.
Key Features of Cuckoo Hashing
Cuckoo hashing is a collision resolution strategy offering worst-case constant-time lookups and efficient use of memory, making it a critical building block for high-performance Private Set Intersection (PSI) protocols.
Two-Table Architecture
Cuckoo hashing maintains two separate hash tables, each with its own independent hash function. An element x can only reside in one of two possible locations: Table 1 at index h1(x) or Table 2 at index h2(x). This deterministic placement guarantees that lookups require checking at most two positions, achieving worst-case O(1) constant-time retrieval.
The Eviction Mechanism
When inserting an element x and both candidate slots are occupied, the algorithm evicts the existing occupant and re-inserts it using its alternate hash function. This triggers a chain of relocations:
- Evicted element
ymoves to its alternate slot - If that slot is occupied,
zis evicted and re-inserted - The process continues until a vacant slot is found
This cascading behavior is the origin of the name, inspired by the brood parasitism of cuckoo birds that evict other eggs from nests.
Cycle Detection and Rehashing
An insertion sequence can enter an infinite loop where evictions cycle through the same set of occupied slots. To handle this, implementations enforce a maximum eviction threshold (typically O(log n)). If the threshold is exceeded, the entire data structure is rebuilt from scratch using two new randomly selected hash functions. This rehashing operation is amortized over many insertions, preserving expected constant-time insertion performance.
Space Efficiency and Load Factor
With two tables of size (1+ε)n each, Cuckoo hashing achieves a load factor exceeding 95% while maintaining constant-time operations. The space overhead is tunable:
- Higher ε reduces insertion failures and rehash frequency
- Lower ε maximizes memory utilization
- Practical PSI implementations often use ε ≈ 0.2 to 0.4 to balance speed and space
This efficiency is critical for PSI protocols where hash tables must fit within tightly constrained communication budgets.
Role in Private Set Intersection
Cuckoo hashing is a core component of modern PSI protocols like KKRT and PSZ. It enables efficient oblivious transfer (OT)-based membership testing:
- The sender inserts their set into a Cuckoo table
- The receiver uses OT to probe specific table positions without revealing which element they are querying
- The deterministic two-slot placement ensures each receiver element requires only a small, fixed number of OT operations
This reduces communication complexity from linear to sublinear in the sender's set size.
Cuckoo Hashing Variants
Several optimized variants extend the basic scheme:
- d-ary Cuckoo Hashing: Uses
d > 2hash functions and tables, reducing eviction chains at the cost of more lookup probes - Cuckoo Hashing with a Stash: A small auxiliary storage for elements that fail to insert, eliminating rehashing entirely at the cost of a bounded stash size
- Bucketized Cuckoo Hashing: Each table slot holds a small bucket of
belements, improving load factor and reducing insertion failures
Bucketized variants are particularly popular in PSI for their cache-friendly memory access patterns.
Frequently Asked Questions
Explore the mechanics and cryptographic role of Cuckoo Hashing, a pivotal data structure for optimizing storage and slashing communication complexity in modern Private Set Intersection protocols.
Cuckoo Hashing is a collision resolution scheme that achieves worst-case constant lookup time by using two (or more) distinct hash functions to map each key to two possible buckets. When inserting a new key x, if its primary bucket is occupied, the existing key is evicted and relocated to its own alternative bucket. This cascading eviction process continues until a vacant slot is found or a cycle is detected, triggering a rehash. This guarantees that every key resides in one of its two designated positions, eliminating linear probing chains and ensuring deterministic O(1) retrieval performance.
Cuckoo Hashing vs. Other Collision Resolution Schemes
Comparison of Cuckoo Hashing against chaining, linear probing, and double hashing across key performance and security dimensions relevant to PSI protocols.
| Feature | Cuckoo Hashing | Chaining | Linear Probing | Double Hashing |
|---|---|---|---|---|
Worst-case lookup time | O(1) - exactly 2 probes | O(n) - list traversal | O(n) - cluster scan | O(n) - probe sequence |
Average load factor achievable | Up to 50% (2 functions) | 90%+ | 70-80% | 70-80% |
Insertion determinism | ||||
Memory overhead per slot | None (in-place) | Pointer per node (8 bytes) | None (in-place) | None (in-place) |
Cache locality | Good (2 random accesses) | Poor (pointer chasing) | Excellent (sequential) | Moderate (strided) |
Deletion complexity | O(1) worst-case | O(1) average | Complex (tombstones) | Complex (tombstones) |
Resistant to timing side-channels | ||||
Suitable for circuit-based PSI |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Cuckoo hashing is a foundational data structure in modern high-performance Private Set Intersection (PSI) protocols. Understanding its relationship to these core cryptographic primitives and protocol variants is essential for grasping how PSI achieves both speed and security.
Oblivious Transfer (OT)
A foundational cryptographic primitive where a sender inputs two messages and a receiver selects one, with the sender learning nothing about the choice and the receiver learning nothing about the unchosen message. In Cuckoo hashing-based PSI, OT is the core building block used to compare hashed items bin-by-bin without revealing non-matching elements, with the Cuckoo table structure minimizing the total number of OT invocations required.
OT Extension
A cryptographic technique that efficiently generates a large number of Oblivious Transfers from a small number of base OTs using only fast symmetric-key operations. When combined with Cuckoo hashing, OT extension enables PSI protocols to scale to sets with millions of items while maintaining practical execution times, as the Cuckoo table's bin count determines the number of extended OTs needed.
Unbalanced PSI
A PSI variant optimized for scenarios where one party's set is significantly larger than the other's, such as a client with a small contact list querying a server with millions of users. Cuckoo hashing is particularly advantageous here, as the smaller sender set can be placed into a compact Cuckoo table while the larger receiver set uses simple hashing, minimizing the computational burden on the resource-constrained client.
Bloom Filter
A space-efficient probabilistic data structure for set membership testing with a controllable false-positive rate. While Bloom filters are used in some PSI constructions, Cuckoo hashing offers a deterministic alternative with no false positives and constant-time worst-case lookups. Modern protocols often prefer Cuckoo hashing for its exact matching guarantees, though Bloom filters remain relevant for bandwidth-constrained applications.
Communication Complexity
A critical performance metric measuring the total data exchanged between parties during protocol execution. Cuckoo hashing directly optimizes communication complexity in PSI by reducing the number of OT comparisons from O(n) to O(n/β) where β is the bin size, effectively slashing bandwidth requirements and making PSI viable in bandwidth-constrained environments like mobile networks.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us