โ† Wiki Index / Computation & Algorithms / Oblivious RAM
๐Ÿ’ป Computation & Algorithms

Oblivious RAM

Oblivious RAM (ORAM) is a cryptographic compiler and memory-access obfuscation primitive introduced by Oded Goldreich and Rafail Ostrovsky in 1996 that conceals a program's read/write memory access pattern from an untrusted storage server or hardware bus observer with polylogarithmic bandwidth overhead.

Oblivious RAM (ORAM) is a cryptographic compiler and data-structuring primitive within computation and algorithms introduced by Oded Goldreich in 1987 and formalized by Oded Goldreich and Rafail Ostrovsky in 1996 that enables a trusted client processor with a small local memory to execute arbitrary Random Access Machine (RAM) programs over an untrusted remote memory (or untrusted system DRAM) of N blocks without leaking any information through its memory access pattern. Even when every data block stored in untrusted memory is encrypted with semantically secure encryption, observing the sequence of physical memory addresses read and written by the client constitutes a powerful side-channel attack capable of revealing secret cryptographic keys (such as scalar bits in elliptic-curve cryptography), database query predicates, control-flow branches, and genomic or medical records.

An ORAM compiler eliminates access-pattern leakage by continuously re-encrypting and randomly relocating every accessed logical block to a fresh physical location so that any two logical access sequences of the same length T induce physical address distributions that are computationally or statistically indistinguishable (within negligible failure probability 2โˆ’ฮป). Within computational complexity theory, ORAM bridges theoretical cryptography, randomized data structures, and secure processor architectures through a tight ฮฉ(log N) bandwidth lower bound and modern tree-based constructions such as Path ORAM.

Threat Model and Formal Security Definition

Consider a client CPU or cloud tenant that wishes to outsource an array of N logical data blocks (indexed 0, 1, ..., N โˆ’ 1, each of size B bits) to an honest-but-curious (or active malicious) storage server while retaining only a small trusted local memory (the client stash) of O(1) to O(polylog N) blocks. Each logical request takes the form (op, a, data), where op โˆˆ {Read, Write}, a โˆˆ {0, ..., N โˆ’ 1} is the logical address, and data is the payload written on a write operation.

To execute a sequence of T logical requests y = ((op1, a1, d1), ..., (opT, aT, dT)), the ORAM simulator translates each logical access into a sequence of physical reads and writes to the untrusted server, producing an observable physical access trace A(y) (consisting of the physical addresses accessed, the read/write flags, and the ciphertexts transmitted). An ORAM construction is secure if for any two logical request sequences y1 and y2 of equal length |y1| = |y2| = T, the resulting physical access distributions A(y1) and A(y2) are indistinguishable to any polynomial-time adversary:

  • Hides Read vs. Write Type: Every logical access (whether a read or a write) executes an identical physical read-modify-write sequence.
  • Hides Repeated vs. Distinct Accesses: Reading the same logical block a ten times in a row produces ten statistically independent uniform random physical access patterns, completely indistinguishable from reading ten distinct blocks a1, ..., a10.
  • Hides Spatial and Temporal Locality: Sequential array scans, binary search probes in a B-tree or AVL tree, and data-dependent hash table lookups all look identical on the physical memory bus.

Goldreich-Ostrovsky Hierarchical ORAM and the ฮฉ(log N) Lower Bound

Trivial Baselines vs. Hierarchical Levels

Without ORAM, hiding which of the N blocks is accessed requires linearly scanning and re-encrypting all N physical blocks on every logical access, incurring an O(N) bandwidth blowup. Conversely, permuting the N blocks once at initialization via a secret random permutation ฯ€ fails the second time any logical block a is read, because the adversary observes the same physical address ฯ€(a) accessed twice.

Goldreich and Ostrovsky (1996) resolved this dilemma with the Hierarchical (Square-Root and Logarithmic) ORAM architecture:

  1. Square-Root ORAM: Partition the server memory into a permuted main array of N blocks plus a small shelter cache of โˆšN blocks. On each logical access, the client scans the entire shelter of size โˆšN: if the target block a is already in the shelter (because it was accessed recently), the client reads a random dummy slot in the main array; if a is not in the shelter, the client fetches ฯ€(a) from the main array and appends the re-encrypted block to the shelter. After every โˆšN accesses, when the shelter fills up, the client executes an oblivious sorting network (such as Batcher's bitonic sort or the Ajtai-Komlรณs-Szemerรฉdi sorting network) to reshuffle all N blocks under a fresh random permutation ฯ€โ€ฒ, achieving O(โˆšN log N) amortized bandwidth overhead.
  2. Logarithmic Hierarchical ORAM: Replacing the single shelter with a geometric hierarchy of L = โŒˆlog2 NโŒ‰ hash-table levels H1, H2, ..., HL where level Hi holds 2i buckets of size O(log N) eliminates the โˆšN scan: each access probes one pseudorandom bucket per level (O(log N) levels) and reshuffles level i into level i + 1 after every 2i accesses (analogous to a logarithmic merge tree), achieving O(log3 N) amortized bandwidth overheadโ€”later refined to O(log2 N / log log N) by Eyal Kushilevitz, Steve Lu, and Rafail Ostrovsky (2012) using cuckoo hashing.

The Goldreich-Ostrovsky and Larsen-Nielsen ฮฉ(log N) Lower Bound

Goldreich and Ostrovsky (1996) proved in the balls-and-bins model (where the client may only Shuffle, Move, and Re-encrypt atomic blocks without combining multiple blocks via algebraic coding) that any ORAM with client memory of c blocks must incur at least ฮฉ(logc N) amortized physical block accesses per logical access. In 2018, Kasper Green Larsen and Jesper Buus Nielsen proved using the chronogram information-transfer technique from computational complexity theory that the ฮฉ(log N) bandwidth blowup lower bound holds unconditionally for all online ORAMsโ€”even for computationally bounded adversaries and arbitrary non-balls-and-bins bit encodings.

ORAM ArchitectureClient Memory (Blocks)Server SpaceBandwidth Overhead (Blocks / Access)Worst-Case vs. AmortizedUnderlying Data Structure
Linear Scan (Trivial ORAM)O(1)N blocksO(N)Worst-caseFlat array
Square-Root ORAM (Goldreich 1987)O(1)N + โˆšN blocksO(โˆšN log N)AmortizedPermuted array + โˆšN shelter
Hierarchical ORAM (Goldreich-Ostrovsky 1996)O(1)O(N log N)O(log3 N)AmortizedO(log N) hashed levels
Panorama / OptORAMa (Asharov et al. 2020)O(1)O(N)O(log N) (optimal)AmortizedLinear-time oblivious tight compaction
Binary Tree ORAM (Shi et al. 2011)O(1)O(N log N)O(log2 N)Worst-caseBinary tree of O(log N)-block buckets
Path ORAM (Stefanov et al. 2013)O(log N) stash4N to 8N blocks2Z log2 N = O(log N) (Z = 4)Worst-caseBinary tree with Z = 4 buckets
Ring ORAM (Ren et al. 2015)O(log N) stash4N to 8N blocks~2.5 log2 N (1 block / level read)Amortized / de-amortizedBinary tree + XOR path eviction

Tree-Based ORAM and Path ORAM

A major breakthrough in practical ORAM efficiency occurred in 2011 when Elaine Shi, T.-H. Hubert Chan, Emil Stefanov, and Mingfei Li replaced hierarchical hash tables (which suffer from expensive periodic reshuffles) with a binary tree of buckets, culminating in Emil Stefanov, Marten van Dijk, Elaine Shi, Christopher Fletcher, Ling Ren, Xiangyao Yu, and Srinivas Devadas's Path ORAM (2013)โ€”the simplest and most widely deployed ORAM in hardware and cloud systems.

Structural Invariants of Path ORAM

In Path ORAM, the untrusted server stores a complete binary tree of height L = โŒˆlog2 NโŒ‰ having 2L leaves (labeled 0 to 2L โˆ’ 1), structurally analogous to the tree layout of a segment tree. Every node of the binary tree is a fixed-capacity bucket holding exactly Z encrypted blocks (where Z = 4 or Z = 5 is a small constant; unused slots in a bucket hold indistinguishable encrypted dummy blocks).

The client maintains two local data structures:

  1. Position Map (pos): A lookup table mapping each logical block a โˆˆ {0, ..., N โˆ’ 1} to a uniformly random leaf label x = *pos*[a] โˆˆ {0, ..., 2L โˆ’ 1}.
  2. Client Stash (S): A small local overflow buffer holding at most O(log N) blocks in trusted processor memory (or registers).

Path ORAM maintains a single Path Invariant: at every instant, every logical block a is stored either in the local client stash S or inside one of the L + 1 buckets lying along the unique root-to-leaf path P(*pos*[a]) from the root of the binary tree to leaf *pos*[a].

The Four-Step Path ORAM Access Protocol

To read or write logical block a:

  1. Remap Leaf Position: Look up the block's current assigned leaf x โ† *pos*[a], and assign a a freshly sampled, independent uniform random leaf xโ€ฒ โ† Uniform({0, ..., 2L โˆ’ 1}), setting *pos*[a] โ† xโ€ฒ.
  2. Read Path P(x): Read all (L + 1) ยท Z encrypted blocks along the root-to-leaf path P(x) from the server into the client stash S, decrypting them and discarding dummy blocks. By the Path Invariant, block a is guaranteed to be in S.
  3. Update Block Payload: If the operation is a Read, return the data of block a; if it is a Write, overwrite block a's payload in S with the new data.
  4. Greedy Path Eviction (Write Back P(x)): Iterate bottom-up from the leaf bucket at depth L up to the root bucket at depth 0 along P(x). For each bucket at depth d on P(x), greedily pack up to Z blocks from the stash S whose assigned leaf paths P(*pos*[b]) intersect P(x) at depth d, pad any remaining slots up to Z with freshly encrypted dummy blocks, re-encrypt all Z blocks under semantic encryption, and write the bucket back to P(x).

Because x was chosen uniformly at random the previous time a was accessed and is replaced by an independent random leaf xโ€ฒ, the sequence of accessed root-to-leaf paths P(x1), P(x2), ... is a sequence of independent, uniformly distributed random leavesโ€”independent of the logical request sequence. Moreover, Stefanov et al. proved that for bucket capacity Z โ‰ฅ 4, the probability that the client stash S exceeds R blocks decays exponentially in R (*Pr*[|S| > R] โ‰ค 14 ยท (0.6002)R), so an on-chip stash of 60โ€“100 blocks achieves a stash-overflow probability below 2โˆ’80 while transferring 2Z log2 N = 8 log2 N blocks per access in the worst case.

Recursive Position Map Compression

When N is large, storing the N-entry position map *pos*[0..N โˆ’ 1] on the client would require O(N log N) bits of local memory. To reduce client storage to O(1) blocks, the position map itself is packed into blocks of ฯ‡ โ‰ฅ 2 leaf pointers and stored inside a smaller secondary Path ORAM of N/ฯ‡ blocks on the server, recursing O(logฯ‡ N) times until the top-level position map fits in a single client register.

Applications in Secure Hardware Enclaves and Oblivious Cloud Databases

In secure processor architecturesโ€”such as the MIT Ascend and Phantom processors and hardening defenses for Intel SGX and AMD SEVโ€”an adversary with physical access to the motherboard can attach a logic analyzer to the off-chip DDR memory bus to record every physical cache-line address requested by the CPU. Integrating a hardware Path ORAM or Ring ORAM controller into the on-chip memory controller (storing the tiny stash and recursive position map caches inside on-chip SRAM) guarantees that off-chip DRAM bus traffic reveals zero information about program execution. In cloud databases and multiparty computation, combining ORAM with oblivious B-tree and AVL tree indices (where every tree node's child pointer stores the child's random ORAM leaf label directly inside the parent block, eliminating recursive position-map lookups) enables encrypted SQL range queries with O(log2 N) total communication.

Frequently Asked Questions

Why is semantic encryption of memory blocks insufficient without Oblivious RAM?

Semantic encryption (such as AES-GCM or AES-CTR with fresh initialization vectors) hides only the contents (payload) of each memory block, not the address (index) at which the block is stored. For example, if a binary search or square-and-multiply modular exponentiation algorithm branches on secret key bits by reading table entry T[0] when bit k = 0 and T[1] when bit k = 1, or if a hospital database queries an encrypted patient index by disease code, an adversary observing which physical addresses are fetched and how frequently they repeat can reconstruct secret keys and plaintext queries with high accuracy via statistical inference and side-channel attack analysis.

How can an Oblivious B-Tree avoid the recursive position map overhead of Path ORAM?

In a standard Path ORAM supporting arbitrary random array indexing A[i], the client does not know the current random leaf *pos*[i] without consulting the position map. However, when storing a pointer-based tree with bounded branching factorโ€”such as a B-tree, AVL tree, or red-black treeโ€”every search begins at the root node. By storing each child node's current random Path ORAM leaf label xchild directly inside the encrypted payload of its parent node (and updating that pointer in the parent whenever the child is fetched and assigned a new leaf xโ€ฒchild), the client only needs to remember the single leaf label of the tree root in O(1) registers, eliminating the recursive position map entirely.

References

  1. Goldreich, O., & Ostrovsky, R. (1996). "Software protection and simulation on oblivious RAMs." Journal of the ACM, 43(3), 431โ€“473. https://doi.org/10.1145/233551.233553
  2. Shi, E., Chan, T.-H. H., Stefanov, E., & Li, M. (2011). "Oblivious RAM with O((log N)^3) worst-case cost." Advances in Cryptology โ€“ ASIACRYPT 2011, LNCS 7073, 197โ€“214. https://doi.org/10.1007/978-3-642-25385-0_11
  3. Stefanov, E., van Dijk, M., Shi, E., Fletcher, C., Ren, L., Yu, X., & Devadas, S. (2013). "Path ORAM: an extremely simple oblivious RAM protocol." Proceedings of the 2013 ACM SIGSAC Conference on Computer & Communications Security (CCS), 299โ€“310 (Journal version in Journal of the ACM, 65(4), 18:1โ€“18:26, 2018). https://doi.org/10.1145/2508859.2516660
  4. Larsen, K. G., & Nielsen, J. B. (2018). "Yes, there is an oblivious RAM lower bound!" Advances in Cryptology โ€“ CRYPTO 2018, LNCS 10992, 523โ€“542. https://doi.org/10.1007/978-3-319-96881-0_18
  5. Asharov, G., Komargodski, I., Lin, W.-K., Nayak, K., Peserico, E., & Shi, E. (2020). "OptORAMa: optimal oblivious RAM." Advances in Cryptology โ€“ EUROCRYPT 2020, LNCS 12106, 403โ€“432. https://doi.org/10.1007/978-3-030-45724-2_14
๐Ÿงฌ Support Open Science
Explore interactive science games on LowKey Games or browse scientific apparel & accessories in the CRV Science Shop.
๐Ÿ’ก Spot an inaccuracy or have primary literature to expand this article?
Submit a citation or revision note using your shared CRV Science / LowKey Games profile ID.
Suggest Revision