Secure Computation of MIPS Machine Code

Xiao Wang, S. Dov Gordon, Allen McIntosh, Jonathan Katz

This paper, presented by researchers from the University of Maryland and George Mason University, introduces a system for the Secure Computation of MIPS Machine Code. It bridges the gap between high-level programming and low-level cryptographic protocols, allowing developers to run standard programs securely without needing to learn specialized "oblivious" programming languages.

TL;DR

The authors developed a system that securely executes native MIPS machine code using a combination of Garbled Circuits and Oblivious RAM (ORAM). By applying clever offline static analysis to minimize the complexity of the "virtual CPU" at each step, they achieved a 30x performance boost, making general-purpose secure emulation competitive with specialized domain-specific languages.

What Problem Does This Paper Address?

Secure Two-Party Computation (2PC) allows two parties to compute a function on their private inputs without revealing anything but the result. Historically, this required representing the program as a massive boolean circuit—a nightmare for complex logic—or using Domain-Specific Languages (DSLs) like Obliv-C or Wysteria.

These DSLs have significant drawbacks:

  1. High Barrier to Entry: Programmers must learn new, often restrictive syntax.
  2. No Legacy Support: You cannot simply "securely run" existing C or C++ code.
  3. Inefficiency in Control Flow: Standard circuit-based MPC must evaluate every possible branch of an if-else statement, whereas a RAM-based model only needs to execute the path actually taken.

The authors tackle the challenge of building a system that accepts standard MIPS binaries (compiled from ordinary C code) and executes them securely while maintaining the efficiency of the RAM model of computation.

Methods

The system functions as a secure emulator for a MIPS CPU. The state of the machine—registers, program counter, and memory—is secret-shared between the two parties.

  • Garbled Circuits (GC): Used to implement the logic of the CPU's Arithmetic Logic Unit (ALU). In each "clock cycle," the parties evaluate a garbled circuit that performs the instruction's logic and updates the registers.
  • Oblivious RAM (ORAM): Used for two purposes:
  • Instruction Fetch: To get the next instruction without revealing which part of the code is being executed.
  • Data Memory: To perform load and store operations without revealing the memory addresses being accessed.
  • Static Analysis (The Core Innovation): Instead of using one giant "Universal Circuit" that supports every possible MIPS instruction at every step, the system performs an offline analysis of the binary. It identifies which specific instructions could possibly be executed at each time step. This allows the system to generate a tiny, specialized ALU circuit and a smaller instruction ORAM for each specific step, drastically reducing the number of AND gates (the primary cost metric in GC).
  • Padding with NOPs: To prevent "state explosion" in loops with branches of different lengths, the authors manually insert No-Operation (NOP) instructions to balance the paths, ensuring the set of possible instructions at any given time step remains small.

Datasets

The system was evaluated using several classic algorithmic benchmarks compiled from C to MIPS:

  • Set Intersection: Computing the number of common elements in two private sets.
  • Hamming Distance: Calculating bitwise differences between two arrays.
  • Binary Search: Searching for a private key in a private sorted array.
  • Binary Decision Trees: Evaluating a tree-based model on private data.
  • Dijkstra’s Algorithm: Finding the shortest path in a graph.

Key Insights and Ideas

  • The RAM Model Advantage: By emulating a CPU, the total work is proportional to the actual number of instructions executed in an insecure run. This is a massive win over circuit-based MPC for algorithms like Binary Search, where a circuit would require $O(N)$ gates, but this system only requires $O(\log N)$ ORAM accesses.
  • Specialization is Efficiency: The "Aha!" moment is that while a CPU can do anything, at any specific point in a program's execution, it is only likely to do a few things. Mapping instructions to specific time steps allows the "hardware" to shrink and grow as needed.
  • Amortizing Communication: The authors found that checking if a program has terminated in every single cycle created a communication bottleneck. By checking for termination only every $C$ cycles, they significantly reduced round-trip latency.

Key Results

  • Massive Speedups: The optimizations (instruction mapping and padding) improved performance by up to 30x compared to a baseline "universal" emulator.
  • Competitive Performance: For set intersection, the system was only ~25% slower than ObliVM (a state-of-the-art DSL), proving that the overhead of general-purpose emulation is manageable.
  • Scalability: In Binary Search, the system outperformed linear scans once the array size exceeded $2^{19}$ elements, demonstrating the power of the RAM model for large datasets.
  • Gate Reduction: For Hamming distance, the optimized system used only 481K AND gates total, compared to 3.76M in TinyGarble (a hardware-optimized competitor).

Limitations and Future Work

  • Timing Leaks: The system leaks the total number of instructions executed. While this can be mitigated by padding the execution to a fixed maximum time, it remains a side-channel concern.
  • Manual Padding: Currently, the NOP padding required to optimize loops with branches is done manually. The authors note that automating this via a compiler pass is a non-trivial future challenge.
  • Instruction Support: The prototype supports 37 MIPS instructions. While this covers most common algorithmic needs, a full production system would need to implement the entire MIPS I instruction set.
  • Static Analysis Complexity: For very complex programs with highly irregular control flow, the static analysis might fail to significantly prune the instruction sets, leading to larger circuits.

Summary updated

BibTeX
@inproceedings{wang2016secure,
  author = {Xiao Wang and S. Dov Gordon and Allen McIntosh and Jonathan Katz},
  title = {{Secure Computation of MIPS Machine Code}},
  booktitle = {ESORICS},
  year = {2016},
  doi = {10.1007/978-3-319-45741-3\_6},
}
Figure