Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM...

28
Secure Computation of MIPS Machine Code Gordon, Katz, McIntosh, Wang

Transcript of Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM...

Page 1: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Secure Computation of MIPS Machine Code

Gordon, Katz, McIntosh, Wang

Page 2: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Efficiency vs. Generality

2

generality efficiency

Domain specific languages that approximate certain high

level languages. Constructions tailored towards particular

applications.Machine code / legacy code

Page 3: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Legacy Code

Moving to the RAM model offers the possibility of securely emulating real architectures.

In theory, we can support “real” languages, their existing libraries, and existing compilers.

What would this take in practice?

Ideal world: the programmer has never heard the words “secure computation”.

Page 4: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Oblivious RAM [GO96,…]

(v1, d1), (v2, d2) …. , (vn, dn)

4

(r, v5), (r, v2), (w, v2 ,d1) …. , (w, v7, d2)

client server

access pattern 1:

(r, v1), (r, v1), (r, v1) …. , (r, v1)access pattern 2:

ANY 2 access patterns are indistinguishable

Page 5: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

ORAM

ORAM in secure computation

x yF(x,y)

Who should hold the ORAM?Recall, the client fetches items from the server.

Alice shouldn’t see Bob’s items, and Bob Shouldn’t see Alice’s.

Page 6: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

ORAM

ORAM in Secure Computation

x yF(x,y)

But even if Alice sees which of her own items are fetchedshe learns something about y.

(Consider a binary search for y among the items in X)

ORAM

Page 7: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Oblivious RAM (abstraction)

ORAM(READ)

V

v(1), … ,v(logn)

V

D

ORAMv(1)

state(0)

state(1)

ORAMv(2)

state(1)

state(2)

ORAMv(logn)

state(logn-1)

state(logn)

1 of the log n willmatch, output D

Page 8: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

CCS 2012v1

D1

ORAMv(1)

state1(0)

state2(0)

state1(1)

ORAMv(2)

state1(2)

ORAMv(logn)

state1(logn)

…v2

state1(1)

state2(1)

state1(log n-1)

state2(log n-1)

state2(1)

state2(2)

state2(logn)

D2

“secret shares”v1 v2 = v

state1 state2 = state⊕

⊕YAO

YAO

YAO

Page 9: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

CCS 2012

RAMPROGRAM

(BINARY SEARCH)

(state1(0), inst1)

(state2(0), inst2)

(state1(log n), D1)

(state2(log n), D2)

inst1(0)

ORAMv(1)

state1(0)

state2(0)

state1(1)

ORAMv(2)

state1(2)

ORAMv(logn)

state1(logn)

…inst2

(0)

state1(1)

state2(1)

state1(log n-1)

state2(log n-1)

state2(1)

state2(2)

state2(logn)

YAO

YAO

YAO

YAO

D1

D2

Page 10: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Current Work (DARPA: PROCEED)

CPUMIPS ARCHITECTURE

new 32-registersnew progCounter

new 32-registersinstructionprogCounter

YAO

INSTRUCTIONFETCH

LOAD/STOREWORD

progCounter

YAO

YAO

new instruction32-registers

ObliVM

Page 11: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Current Work

CPUMIPS ARCHITECTURE

new 32-registersnew progCounter

new 32-registersinstructionprogCounter

YAO

INSTRUCTIONFETCH

LOAD/STOREWORD

progCounter

YAO

YAO

new instruction32-registers

Page 12: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Current Work

CPUMIPS ARCHITECTURE

new 32-registersnew progCounter

new 32-registersinstructionprogCounter

YAO

Why MIPS?

• Fixed register space = fixed circuit.

• With approximately 15 instructions, we can compute: Djikstra, longest common sub-string, set-intersection, stable marriage, binary search, decision trees…

• Easy to implement!

• 15 instructions = small circuit.

• We first proposed LLVM, but instructions in LLVM are polymorphic objects.

On the other hand:

• ARM or x86 would give bigger circuits, but smaller programs. Ultimately, I don’t know which is best.

Page 13: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Current Work

CPUMIPS ARCHITECTURE

new 32-registersnew progCounter

new 32-registersinstructionprogCounter

YAO

INSTRUCTIONFETCH

LOAD/STOREWORD

progCounter

YAO

YAO

new instruction32-registers

Page 14: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Component Run-Times

ALU

15 instructions 7K AND gates

Memory

Fetch from 1024 32-bit words 43K AND gates

Page 15: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Improvement #1: Instruction Mapping

Divide all instructions into separate “banks”

Banki contains instructions that could be executed in the ith cycle.

Page 16: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Instruction Mapping

If (x > 5)instr1instr2

elseinstr3instr4

If x is tainted:instr1 and instr3 must go in the same ORAM bank

andinstr2 and instr4 must go in the same ORAM bank

for (i = 1 to x)instr1instr2

end forinstr3instr4instr5

t = 1: instr1

t = 2: instr2

t = 3: instr1 or instr3

t = 4: instr2 or instr4

t = 5: instr1 or instr3 or intsr5

loop size t, program length n: n/t banks, each of size t.

Page 17: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Instruction Mapping

CPUMIPS ARCHITECTURE

YAO

INSTRUCTIONFETCH

LOAD/STOREWORD

YAO

YAO

skip this on MANY steps!

Reduce the number of instructions!

Wade through fewer instructions!

Page 18: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

CPUMIPS ARCHITECTURE

YAO

Reduce the number of instructions!

Instruction Mapping

Set Intersection: Reduces the average ALU size from

6727 to 1848 AND gates. (3.5X)

Page 19: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

INSTRUCTIONFETCHY

AO

Wade through fewer instructions!

Instruction Mapping

Set Intersection:The full program has about 150 instructions. The largest instruction bank after mapping has 31 instructions.More than half the instruction banks have fewer than 20 instructions.

Page 20: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

LOAD/STOREWORD

YAO

skip this on MOST steps!

Instruction Mapping

Unfortunately, even after instruction mapping, load/store operations still might occur

in almost every time step.

Page 21: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Improvement #2: padding

for (i = 1 to x)If (x > 5)

instr1instr2

elseinstr3instr4instr5

If two branches are relatively prime, one of length k1, the other k2, then in less than k1k2 time-steps, we will cover the entire loop.

By padding branches such that the lengths are relatively composite, we can greatly reduce the number of instructions per bank:

for set intersection, we go from 40 down to 4.

Page 22: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

LOAD/STOREWORD

YAO

skip this on MOST steps!

Padding

We padded 2 of 3 branches that appear in the main loop using a total of 6 NOP instructions.

Before padding we found that a load/store operation might be executed in almost every time step.

After padding, we find that for only 1/10 of all time steps require a load/store operation.

Page 23: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Set Intersection

Run-time decomposition for computing set-intersection size when each party's inputconsists of 64 32-bit integers.

Run-time decomposition for computing set-intersection size when each party's inputconsists of 1024 32-bit integers.

Page 24: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Set Intersection

Page 25: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Binary Search

Comparing the performance of secure binary search. One party holds an array of 32-bit integers, while the other holds a value to search for.

Page 26: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Decision Trees

Page 27: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

A True Universal Circuit

One more benefit of the general approach:We have a true universal circuit!

1. Compile the private input function to MIPS,

2. Supply a function pointer as input to the emulator.

3. Our optimizations no longer apply: the analysis leaks information.

Page 28: Secure Computation of MIPS Machine Codedimacs.rutgers.edu/Workshops/RAM/Slides/gordon.pdfORAM ORAM in Secure Computation x F(x,y) y But even if Alice sees which of her own items are

Thanks!