<<

Succinct Garbled RAM from Indistinguishablity Obfuscation by Justin Lee Holmgren S.B., Massachusetts Institute of Technology (2013) Submitted to the Department of Electrical Engineering and in partial fulfillment of the requirements for the degree of Master of Engineering in Electrical Engineering and Computer Science at the MASSACHUSETTS INSTITUTE OF TECHNOLOGY February 2015 ○c Massachusetts Institute of Technology 2015. All rights reserved.

Author...... Department of Electrical Engineering and Computer Science February 1, 2015

Certified by...... RSA Professor of Electrical Engineering and Computer Science Thesis Supervisor

Accepted by ...... Professor Albert R. Meyer Chairman, Masters of Engineering Thesis Committee 2 Succinct Garbled RAM from Indistinguishablity Obfuscation by Justin Lee Holmgren

Submitted to the Department of Electrical Engineering and Computer Science on February 1, 2015, in partial fulfillment of the requirements for the degree of Master of Engineering in Electrical Engineering and Computer Science

Abstract In this thesis, I give the first construction of a succinct garbling scheme forRAM programs. For a program requiring space 푆 and time 푇 to compute, the size of its garbling is 푂˜(푆) instead of poly(푇 ). This construction relies on the existence of indistinguishability obfuscation, as well as the existence of injective one-way functions. As a building block, I introduce and construct a primitive called asymmetrically constrained encryption (ACE). This primitive is an encryption system for which keys can be punctured on succinctly described sets of plaintexts. For programs acting on ACE-encrypted values, I give a natural and general condition for their obfuscations to be indistinguishable, using the fact that the encryption and decryption keys can be separately punctured. This succinct garbling scheme serves as a drop-in replacement for the ubiquitous garbled circuits of Yao, but with better asymptotic parameters. In some cases, these improved parameters allow qualitatively new applications.

Thesis Supervisor: Shafi Goldwasser Title: RSA Professor of Electrical Engineering and Computer Science

3 4 Acknowledgments

First, I wish to thank Shafi Goldwasser for being a caring and helpful advisor. Thank you for setting me straight when I was lost, and for letting me switch into the magical world of . I thank my coauthors Ran Canetti, Abhishek Jain, and Vinod Vaikuntanathan for their helpful collaboration. In particular, I thank Ran for his continued mentorship and for all the free food and I thank Abhishek for initiating a research project with me when I had nothing to prove myself. I thank Elette Boyle for teaching me about Path ORAMs, without which this thesis would only garble iterated functions. Finally, I thank my family. Any and all of my success is, ultimately, due to my upbringing.

5 6 Contents

1 Introduction9 1.1 Our techniques...... 13 1.1.1 RAM Garbling from Weak Garbling and Oblivious Ram... 13 1.1.2 Weak Garbling from Verifiable Reads...... 15 1.2 Previous Work...... 17 1.3 Other Related Work...... 18

2 Background 21 2.1 Injective Non-interactive Bit Commitment...... 21 2.2 Puncturable Pseudorandom Functions...... 22 2.3 Indistinguishability Obfuscation for Circuits...... 23 2.4 Garbling Schemes...... 24

3 Techniques Overview 27 3.1 Asymmetrically Constrained Encapsulation...... 27 3.1.1 Construction...... 28 3.2 Garbled RAM Overview...... 30 3.2.1 Weak Garbling...... 30 3.2.2 Full Garbling Construction...... 32 3.2.3 Overview of the Security Proof...... 32 3.2.4 Optimizations...... 33

4 Asymmetrically Constrained Encryption 35

7 4.1 Definition...... 35 4.2 Construction...... 39 4.3 Proof of Security...... 41

5 How to use ACE 53 5.1 Blocks...... 53 5.2 Preliminary Definitions...... 55 5.3 Diamond Theorem...... 57

6 Garbling Iterated Functions 63 6.1 Construction...... 63 6.2 Security Proof...... 64

7 Weak RAM Garbling 69 7.1 Definitions...... 69 7.1.1 RAM program...... 69 7.1.2 Weak Garbling...... 70 7.2 Construction...... 71 7.3 Security Proof...... 72

8 Full RAM Garbling 77 8.1 Oblivious RAM (ORAM)...... 77 8.2 Construction of Garble:...... 78 8.3 Security Proof...... 78

A Oblivious RAM 87 A.1 Construction...... 87 A.2 Security Property...... 89

8 Chapter 1

Introduction

The ability to cryptographically obfuscate general programs holds great prospects for securing the future digital world. However, current general-purpose obfuscation mechanisms are highly inefficient. One of the main sources of inefficiency isthefact that the existing mechanisms work in different models of computation than those used to write modern computer programs. Specifically, the candidate indistinguishability obfuscator of Garg et al. [GGH+13a] and most other general purpose obfuscators in the literature are designed for boolean circuits, and incur a polynomial overhead in both the size and the depth of the circuit. Assuming circuit obfuscators that satisfy a stronger security property (differing input obfuscation), Boyle et al. [BCP14] and Ananth et al. [ABG+13a] show how to transform these obfuscators to act directly on Turing machines. However, working in either the circuit model or the Turing machine model does not take advantage of the fact that realistic computations are invariably the result of relatively short programs written for RAM machines, where the program is ex- ecuted on CPU with random access to large amounts of memory. When applying obfuscators to a RAM program (ie a program written for a RAM machine), one has to first translate the program to a circuit or a Turing machine. Such translation may incur unreasonable overhead in of itself, even before applying the obfuscator. Furthermore, since the obfuscated program is now a circuit or a Turing machine, one cannot meaningfully exploit the advantages of the RAM model in running it.

9 We show how to obfuscate RAM programs directly, without paying the overhead associated with transforming to Turing machines or circuits. The central piece of our construction and the focus of this thesis is an efficient method for garbling RAM programs.

Garbled RAM programs. Garbling is a way to take a function 푓 and an input 푥, and encode them as 푓,˜ 푥˜ ← Garble(푓, 푥) in a way which reveals nothing more than 푓(푥). One obviously desirable property is efficiecy: computing 푓˜ and 푥˜ should be easier than just computing 푓(푥). The efficiency of a scheme depends onthe representation of 푓; if 푓 is given as a circuit, then just reading 푓 takes as much time as computing 푓(푥). We give the first construction of an efficient garbling scheme in which functions are represented as RAM programs. As one of several easy applications, we then show how to transform circuit obfuscators into RAM program obfuscators. Given a RAM program Π, a memory configuration 푥, and security parameter 휆, Garble outputs a RAM program Π˜ of size poly(|Π|, 휆) and an encoded input 푥˜ of size 푂(|푥| · log1+휖(휆)) (for any positive constant 휖). Running Π˜ with 푥˜ as initial memory gives Π(푥), and Π˜ and 푥˜ reveal nothing more than Π(⃗푥) and the running time (as well as the sizes of Π and ⃗푥). More precisely, there is an efficient probabilistic algorithm

Sim such that, for any Π and any 푥, Garble(Π, 푥) ≈ Sim(Π(푥), |푥|, |Π|, 푇Π,푥), where

푇Π,푥 is the running time of Π on 푥. Our construction uses as building blocks an injective one way function and an indistinguishability obfuscator for circuits.

Applicability. Our garbling scheme for RAM programs can be used in practically any place where garbling schemes for circuits have been used, with commensurate efficiency gains. We remark that our garbling scheme represents RAM program inputs as memory configurations. While this is the most general case, we do incur alossof efficiency when the input is smaller than the computation’s memory usage. However, many computations (particularly in crytography) have low memory requirements (say, linear in the input size), thus making the dependence on space less critical. Below we

10 give a brief overview of some applications.

Indistinguishability obfuscation for RAM programs. Our main application of our RAM garbling scheme is in converting an indistinguishability obfuscator for circuits to one for RAM programs. An indistinguishability obfuscator takes a func- tion description 푓 and outputs a functionally equivalent 풪(푓). If 푓0 and 푓1 are

functionally equivalent and have equally sized representations, then 풪(푓0) and 풪(퐹1) must be indistinguishable. For RAM programs, there is another prerequisite: the two RAM programs must have the same running time on every input. Indistinguish- ably obfuscation was introduced as a weak notion of obfuscation to circumvent the impossibility results of Barak et al. [BGI+01], and a candidate indistinguishability obfuscator for circuits (which we will denote by i풪) was recently given by Garg et al. [GGH+13a]. Since then, indistinguishability obfuscation for circuits has been shown to have extensive applications [SW14].

Our obfuscator (i풪푅퐴푀 ) has the following parameters. It relies on, as build- ing blocks, subexponentially-hard indistinguishability obfuscators for circuits and subexponentially-hard injective one-way functions.1 Suppose the input is a RAM

program Π taking 푛-bit inputs and using 푆 ≥ 푛 bits of space. i풪푅퐴푀 outputs a circuit Π′ of size poly(푆, |Π|, 휆), where 휆 is the security parameter. Evaluating Π(푥)

′ ′ given only Π and 푥 takes time |Π | + 푇Π,푥 · poly(푛, 휆), where 푇Π,푥 is the running time of Π on 푥.

Publicly Verifiable Delegation of Computation: Our garbled RAM scheme yields a simple 2-round publicly verifiable delegation scheme: to delegate the com- putation of Π(푥) for a RAM program Π and input 푥, the delegator first samples a pair (푠푘, 푣푘) of signature and verification keys of a digital signature scheme. Hethen garbles a RAM program Π′ that on input 푥, runs Π to obtain Π(푥), and then outputs (Π(푥), 푆푖푔푛(푠푘, Π(푥))). Finally he sends Garble(Π′, 푥) to the worker and publishes 푣푘. The worker will evaluate the garbling to obtain 푦, 휎. This result is verified by

1Subexponential hardness assumptions essentially state that an adversary cannot win a security game with substantially better probability than guessing the secret key (or randomness).

11 checking that 휎 is a valid signature of 푦 with respect to 푣푘. Soundness follows im- mediately from the security of the garbled RAM and unforgeability of the signature scheme.

Functional Encryption Functional encryption is a strengthening of public-key encryption, in which restricted decryption keys 푆퐾푓 can be issued, associated with a function 푓. Dec(푆퐾푓 , Enc(푚)) yields 푓(푚), and 퐷퐾푓 does not allow the computation of anything else. Gentry et al. [GHRW14] show how a RAM garbling scheme can be used to construct a functional encryption scheme in which functions are represented by RAM programs. With our RAM garbler, this gives the following parameters.

The key generation time and size of a decryption key 푆퐾Π for a RAM program Π is

(poly(|Π|) + 푆Π) · poly(휆, log 푇Π, log 푆Π). Here 푇Π is the worst-case run-time of Π and

푆Π is the space usage of Π. Decrypting a ciphertext corresponding to a plaintext 푥 using 푆퐾Π takes time (푆Π + 푇Π,푥) · poly(휆, log 푇Π, log 푆Π) where 푇Π,푥 is the run-time of Π on input 푥.

Reusable Garbled RAM Gentry et al. [GHRW14] also gave a reduction showing that functional encryption for RAM programs can be used to build a reusable garbling scheme for RAM programs. When this is built using our RAM garbler, the resulting reusable garbled RAM scheme is also succinct.

Multiparty Computation of RAM Programs. Gentry et al. [GHRW14] ob- served that any efficient garbled RAM can be used in any standard MPC protocol to obtain a new protocol with improved efficiency. To compute a functionality 푓 on inputs ⃗푥, the parties jointly compute Garble(Π, ⃗푥), where Π is a RAM program com- puting 푓. One party then evaluates the garbling and sends the result to all the other parties. When this protocol is instantiated with our RAM garbler, the evaluator takes ˜ time which is 푂(푆Π +푇Π,⃗푥), where 푆Π is space used by Π and 푇Π,⃗푥 is the running time on ⃗푥.

12 1.1 Our techniques

1.1.1 RAM Garbling from Weak Garbling and Oblivious Ram

Our ultimate goal is to fully garble a RAM program Π on an input 푥, revealing nothing more than the final output Π(푥). We will build a full RAM garbling scheme out of another primitive, which we call weak garbling, and an oblivious RAM.

Weak Garbling We first construct a somewhat weaker primitive which we call weak garbling. Weak garbling is syntactically the same as garbling: it takes a program Π ˜ ˜ ˜ and an input 푥, and outputs Π, 푥˜. Weak garbling guarantees that Π0, 푥˜0 and Π1, 푥˜1 are indistinguishable if Π0 and Π1 on 푥0 and 푥1 access exactly the same locations, which are succinctly described by a circuit for the first 푗 steps, and if after these 푗 steps, they have the same internal state and external memory configuration. We then apply weak garbling to a RAM program which has been transformed to be oblivious with special additional properties.

Oblivious RAM An oblivious RAM program Π′ on input 푥′ simulates execution of an underlying program Π on an underlying input 푥, such that the addresses accessed by Π′ are independent of the underlying addresses accessed by Π. We require two other natural properties:

1. For all 푗, the distribution of addresses accessed by Π′ on the 푗푡ℎ underlying access is independent of the previously accessed addresses and the underlying access pattern, and is efficiently sampleable.

2. For any fixed underlying access pattern, one can efficiently sample the distri- bution of ORAM states (including external memory) that are consistent with a preceding sequence of accessed addresses.

We show that the ORAM of Shi et al. [SCSL11], simplified by Chung and Pass [CP13] has these properties. We denote Π′, 푥′ by AddORAM(Π, 푥).

13 Construction and Reduction Garble is constructed by composing our weak gar- bling scheme with such an oblivious RAM. That is,

Garble(Π, 푥) ≡ WkGarble(AddORAM(Π, 푥)).

We show that Garble(Π, 푥) ≈ Sim(Π(푥)) by a simple hybrid argument. The 푖푡ℎ hy-

′ ′ ′ ′ ′ brid is WkGarble(Π푖, 푥푖) for some Π푖, 푥푖. Π푖 is a program which does 푖 dummy steps accessing addresses 퐼1, . . . , 퐼푖. Each 퐼푗 consists of several addresses and is sampled independently according to the distribution of addresses accessed by the ORAM on

′ ′ time 푗. Π푖 then runs Π through the ORAM until Π halts. 푥푖 is the memory config- uration of Π when executed for 푖 steps on 푥, encoded to be compatible with ORAM accesses. This memory configuration could be encoded in a number of ways, each resulting from some random ORAM setup, and randomness used for each ORAM ac- cess. We pick the encoding at random, conditioned on the ORAM accesses accessing locations 퐼1, . . . , 퐼푖. Our extra ORAM properties allow us to efficiently sample this distribution.

In order to switch from the 푖푡ℎ hybrid to the 푖 + 1푡ℎ hybrid in the proof of security

′ 푡ℎ for Garble, we need to indistinguishably change the behavior of Π푖 on the 푖+1 access. We proceed in three steps.

First, weak garbling allows us to hard-code the locations accessed at the 푖 + 1푡ℎ

′ timestep: if the time is 푖 + 1, Π푖 accesses a hard-coded list of addresses 퐼푖+1, without ′ writing new values to these locations. We simultaneously switch 푥푖 to an encoding of the memory configuration resulting from executing Π for 푖 + 1 steps on 푥. This change is easily seen to satisfy the conditions under which weak garbling guarantees indistinguishability.

Next, we sample 퐼푖+1 according to OSample(푖 + 1) independently of the rest of ′ ′ Π푖, and we sample 푥푖+1 to be consistent with this 퐼푖+1 (and 퐼1, . . . , 퐼푖). Our ORAM ′ properties guarantee that changing 퐼푖+1 and 푥푖+1 in this way is indistinguishable. Finally, we apply weak garbling again to remove the hard-coding of the locations accessed at time 푖 + 1.

14 1.1.2 Weak Garbling from Verifiable Reads

We will weakly garble a RAM program Π with input 푥 by first applying a verifiable reads transformation to obtain a different RAM program Π′ and memory 푥′. Then we encrypt each word of 푥′, yielding 푥˜, and we augment Π′’s transition function so that it acts on encrypted state and encrypted memory words. Finally, we i풪-obfuscate Π′’s transition function to obtain Π˜. The weak garbling WkGarble(Π, 푥) is defined as Π˜, 푥˜.

Verifiable Reads Suppose one is given an external memory which is semi-malicious: on any access, the memory can return any value previously written to memory, not necessarily the most recent value. Then one can simulate a semi-malicious memory up to aborts by storing message authentication codes (MACs) with every value written to a fully malicious memory which is computationally bounded. A natural question is whether one can also simulate an honest external memory. This seems to be a necessary component of a secure RAM garbler, because a distinguisher might “eval- uate” the garbled RAM program by answering memory accesses arbitrarily. Indeed, Gentry et al. [GHL+14] give a method for simulating an honest external memory up to aborts, given a semi-mqqalicious external memory. While this abstraction suffices to prove security of Gentry et al.’s non-succinct garbled RAM construction, our proof relies on specific properties of their construction. We describe this construction further, as well as the properties we need, in Chapter 7.

Asymmetrically Constrained Encryption This construction involves an indis- tinguishability obfuscated circuit that has encryption and decryption keys hard-coded. We only prove security with a special type of encryption which we call Asymmetrqi- cally Constrained Encryption (ACE). ACE is a secret-key deterministic encryption system in which either an encryption key or a decryption key can be punctured at a succinctly-described set - that is, a set for which membership in the set can be decided by a small circuit. ACE must also satisfy a few security properties. A decryption key punctured on

15 a set 푆 should be indistinguishable from an unpunctured key. However, using such a punctured decryption key to decrypt should never yield a message in 푆. Finally, given keys punctured at a set 푆, encryptions of messages in 푆 should be indistinguishable.

Security of Weak Garbling To show security of weak garbling, we will indistin- guishably change the weak garbling WkGarble(Π, 푥) into the obfuscation of a program which only executes “dummy” steps for the first 푗 steps of computation.

Consider the transition function 훿Π′ for the verifiable reads-transformed RAM program Π′. This transition function takes a state 푞 and a memory word 푤 as input, and produces (among other things) a state 푞′ and a memory word 푤′ as output.

′ Suppose that 푆푄 and 푆푊 are “invariant” sets of Π : whenever 푞 is in 푆푄 and 푤 is ′ ′ in 푆푊 then 푞 is also in 푆푄 and 푤 is also in 푆푊 . If 푆푄 and 푆푊 are also succinctly described, then we show that we can indistinguishably change Π′ so that it outputs ⊥

whenever 푞∈ / 푆푄 or 푤∈ / 푆푊 . The indistinguishability of this change relies crucially on the properties of ACE; we alternately puncture encryption keys using i풪 and then apply ACE’s indistinguishability of punctured decryption keys.

We will change 훿Π′ on the first 푗 steps into a dummy computation’s transition function, one timestep at a time. We use the so-called “punctured programming” technique of Sahai and Waters [SW14], for which we need the above property of ACE. The idea of punctured programming is the following steps for changing the

behavior of 훿Π′ at some time 푗. Hard code the behavior of 훿Π′ when its inputs are the “correct” (ciphertext) inputs at time 푗. Similarly, hard-code these ciphertexts as outputs instead of ever actually encrypting the corresponding messages. Then puncture the encryption and decryption keys at all messages corresponding to time 푗, and use ciphertext indistinguishability to change the hard-coded ciphertexts to encryptions of something else. Finally, unpuncture the encryption and decryption keys and un-hard-code the ciphertexts. One may then raise an objection. We can’t puncture the encryption and decryp- tion keys at all possible messages corresponding to time 푗, because we have only hard-coded ciphertexts for one pair of messages. To resolve this, we construct invari-

16 ant sets 푆푄 and 푆푊 such that when we restrict our attention to 푆푄 and 푆푊 , 훿Π′ has the desired properties. Namely, there is only one state 푞 at time 푗 and one corre- sponding 푤 such that 훿Π′ (푞, 푤) ̸= ⊥. By first indistinguishably restricting 훿Π′ to 푆푄 and 푆푊 , the punctured programming argument can be made to work. The proof of security for our weak garbling scheme is presented in more detail in Chapter 7.

1.2 Previous Work

Garbling schemes were first introduced by Yao [Yao82] to implement secure two- party computation. Yao’s construction allowed 푛 parties holding inputs 푥1, . . . , 푥푛 to evaluate a function 푓(푥1, . . . , 푥푛), while learning nothing about each other’s inputs. The complexity of Yao’s protocol is proportional to the size of the circuit computing 푓. Subsequent multiparty computation protocols [GMW87, BOGW88, AL11] have for the most part continued to represent functionalities as circuits. One notable exception is the work of Boyle et al. [BGT13] which focuses on multiparty RAM computations with sublinear running times. Many other areas of cryptography study computing on encrypted data. For ex- ample, there has been a large body of work on fully [Gen09, vDGHV09, BV11, BGV12], attribute-based encryption [SW05, GPSW06, GVW13, GGH+13b] and functional encryption [SS10, AGVW13], all of which use the Boolean circuit model of computation. An exception is the work of Waters [Wat12] that constructs an attribute-based encryption scheme for finite state machines, a uniform model of computation. Barak et al. [BGI+01] showed that a strong notion of program obfuscation known as virtual black-box obfuscation is unconditionally impossible to achieve. One def- inition of obfuscation they proposed as possibly achievable was indistinguishability obfuscation. In 2013, Garg et al. [GGH+13a] introduced a candidate construction of an indistinguishability obfuscator for circuits. Subsequently, many applications [SW14, CGP14, Wat14, BPR14, GGG+14] of indistinguishability obfuscation for cir-

17 cuits have been found. In a recent paper, [GLOS14] show how to transform a RAM machine with worst- case running time 푡 into a garbled RAM program whose size and running time are polynomially related to 푡. Their construction only relies on the existence of one-way functions. In our work we reduce the size of the garbled RAM program to depend only logarithmically on 푡, at the cost of assuming not only one-way functions, but also indistinguishability obfuscators for circuits. We also achieve input-specific running times instead of worst-case. [GHRW14] assume the existence of various types of obfuscators, and construct reusable garbled RAM schemes. Our succinct garbled RAM strictly improves upon their construction based on only indistinguishability obfuscation.

1.3 Other Related Work

The work in this thesis was first published in [CHJV14] as joint work with Ran Canetti, Abhishek Jain, and Vinod Vaikuntanathan. Concurrently and indepen- dently, Bitansky et al. [BGT14] and Lin and Pass [LP14] gave constructions for garbling and indistinguishability obfuscation of Turing machines, assuming only in- distingushability obfuscation and one way functions. While the general thrusts of the three works is similar, the technical approaches taken are very different. Fur- thermore, the specific results obtained are incomparable. Specifically, they provide a generic mechanism for using indistingushability obfuscation to transform any “lo- cally computable” garbling mechanism (i.e., a garbling mechanism where each portion of the garbled program can be generated “locally”, without knowledge of the other portions) into a succinct one. The mechanism is essentially the same as our garbling- to-obfuscation transformation: they obfuscate a circuit that generates a portion of the garbled program, where the randomness for the garbling mechanism is obtained by applying a puncturable PRF to the input. They then apply this simple-but-powerful general mechanism to the Yao garbling scheme for circuits. These two approaches achieve very similar parameters, but are still incomparable.

18 Our scheme is slightly more succinct, while their scheme relies on a slightly weaker assumptions. In our scheme a garbled RAM program is of size poly(휆, log 푇, log 푆) and an encoded input is of size 푂(푆·log1+휖(휆)). In their scheme a garbled RAM program is of size 푆 ·poly(휆, log 푇, log 푆) and an encoded input is of size 푆 ·poly(휆). In our scheme we need to i풪-obfuscate circuits with depth 푂(log(휆)) and input length 푂(log1+휖(휆)). In Bitansky et al.’s scheme, they i풪-obfuscate circuits with depth 푂(log(휆)) and input length 푂(log(휆)). Our scheme also requires injective one-way functions, while their scheme uses any one-way function. Another difference between the two approaches, which is perhaps more significant than the difference in parameters, is the approach: while their approach is toapply obfuscation on top of existing garbling mechanisms (which may in of themselves be composed of multiple components), our approach is to try to use the power of obfuscation to the fullest, with few other primitives, and with minimal modification to the structure of the underlying program. Indeed, our resulting garbled program has a very similar structure to the original program and can potentially be run on a standard random access computer with minimal adjustments. In a follow-on work, Koppula et al. [KLW14] apply techniques somewhat similar to ours to construct a fully succinct garbling scheme for Turing machines - that is, their garblings are of size 푂˜(1) · poly(휆), and their runtime is 푂˜(푇 ) · poly(휆), where 푇 is the Turing machine runtime. Notably, they do not achieve RAM runtimes for a garbling scheme.

19 20 Chapter 2

Background

In this chapter we review some standard cryptographic primitives, as well as the definition of i풪 obfuscation. We will use 휆 to denote the security parameter. Two

distribution ensembles 풜 = {퐴휆}휆>0 and ℬ = {퐵휆}휆>0 are computationally indistin- guishable if for every probabilistic polynomial time (PPT) distinguisher 퐷, there is a negligible function negl(·) such that for all 휆,

[︀ 휆 ⃒ ]︀ 1 Pr 퐷(1 , 푥푏) = 푏⃒푥0 ← 퐴휆, 푥1 ← 퐵휆, 푏 ← {0, 1} ≤ + negl(휆). 2

In this case, we say that 풜 ≈ ℬ.

2.1 Injective Non-interactive Bit Commitment

An injective non-interactive bit commitment scheme is a pair of polynomials 푛(·)

and 푚(·) and an ensemble of efficiently computable injective functions Commit휆 : {0, 1} × {0, 1}푛(휆) → {0, 1}푚(휆) such that for all polynomial time adversaries 풜,

[︀ 휆 ⃒ 푛(휆)]︀ 1 Pr 풜(1 , Commit휆(푏; 푟)) = 푏⃒푏 ← {0, 1}, 푟 ← {0, 1} < + negl(휆) 2

We can construct an injective non-interactive commitment scheme given an injec- tive one-way function 푓 : 푛′(휆) → 푚′(휆), and we give the construction here without proof. Without loss of generality 푓 has a hard-core bit because the Goldreich-Levin

21 [GL89] transformation of a one-way function into one with an explicit hard-core bit preserves injectivity. Then define 푛(휆) = 푛′(휆), 푚(휆) = 푚′(휆) + 1, and

Commit휆(푏; 푟) = 푓(푟)‖(푏 ⊕ ℎ(푟))

2.2 Puncturable Pseudorandom Functions

A puncturable family of PRFs are a special case of constrained PRFs [BW13, BGI14, KPTZ13], where the PRF is defined on all input strings except for a set ofsize polynomial in the security parameter. Below we recall their definition, as given by [SW14].

Syntax A puncturable family of PRFs is defined by a tuple of algorithms

(GenPRF, PuncturePRF, EvalPRF) and a pair of polynomials 푛(·) and 푚(·) :

∙ Key Generation GenPRF is a PPT algorithm that takes as input the security parameter 휆 and outputs a PRF key 퐾

∙ Punctured Key Generation PuncturePRF(퐾, 푆) is a PPT algorithm that takes as input a PRF key 퐾, a set 푆 ⊂ {0, 1}푛(휆) and outputs a punctured key 퐾{푆}

∙ Evaluation EvalPRF(퐾, 푥) is a deterministic algorithm that takes as input a (punctured or regular) key 퐾, a string 푥 ∈ {0, 1}푛(휆) and outputs 푦 ∈ {0, 1}푚(휆)

Definition 1. A family of PRFs (GenPRF, PuncturePRF, EvalPRF) is puncturable if it satisfies the following properties :

∙ Functionality preserved under puncturing. Let 퐾 ← GenPRF, and 퐾{푆} ←

PuncturePRF(퐾, 푆). Then, for all 푥∈ / 푆, EvalPRF(퐾, 푥) = EvalPRF(퐾{푆}, 푥).

∙ Pseudorandom at punctured points. For every PPT adversary (퐴1, 퐴2) 휆 푛(휆) such that 퐴1(1 ) outputs a set 푆 ⊂ {0, 1} and 푥 ∈ 푆, consider an experiment

where 퐾 ← GenPRF and 퐾{푆} ← PuncturePRF(퐾, 푆). Then

⃒ ⃒ ⃒푃 푟[퐴2(퐾{푆}, 푥, EvalPRF(퐾, 푥)) = 1] − 푃 푟[퐴2(퐾{푆}, 푥, 푈푚(휆)) = 1]⃒ ≤ negl(휆)

22 where 푈ℓ denotes the uniform distribution over ℓ bits.

As observed by [BW13, BGI14, KPTZ13], the GGM construction [GGM86] of PRFs from one-way functions yields puncturable PRFs.

Theorem 1 ([GGM86, BW13, BGI14, KPTZ13]). If one-way functions exist, then for all polynomials 푛(휆) and 푚(휆), there exists a puncturable PRF family that maps 푛(휆) bits to 푚(휆) bits.

Remark 1. In the above construction, the size of the punctured key 퐾{푆} grows linearly with the size of the punctured set 푆.

Remark 2. We will also use statistically injective puncturable PRF families in our con- structions. These are families of PRFs for which with high probability over the choice

푛 2푛+휔(log 휆) of 퐾, EvalPRF(퐾, ·) is injective. Any PRF family mapping {0, 1} → {0, 1} can be made statistically injective with high probability by XOR-ing with a family of pairwise independent hash functions [SW14].

2.3 Indistinguishability Obfuscation for Circuits

Here we recall the notion of indistinguishability obfuscation that was defined by Barak

+ et al. [BGI 01]. Intuitively speaking, we require that for any two circuits 퐶1 and 퐶2

that are “functionally equivalent” (i.e., for all inputs 푥 in the domain, 퐶1(푥) = 퐶2(푥)),

the obfuscation of 퐶1 must be computationally indistinguishable from the obfuscation + of 퐶2. Below we present the formal definition following the syntax of[GGH 13a].

Definition 2 (Indistinguishability Obfuscation for all circuits). A uniform PPT ma- chine i풪 is called an indistinguishability obfuscator if the following holds:

∙ Correctness: For every 휆 ∈ N, for every circuit 퐶, for every input 푥 in the domain of 퐶, we have that

Pr[퐶′(푥) = 퐶(푥): 퐶′ ← i풪(1휆, 퐶)] = 1.

23 ∙ Efficiency: There exists a polynomial 푃 such that for every 휆 ∈ N, for every circuit 퐶, |i풪(퐶)| ≤ 푃 (휆, |퐶|).

∙ Indistinguishability: For every 휆 ∈ N, for all pairs of circuits 퐶0, 퐶1, if

퐶0(푥) = 퐶1(푥) for all inputs 푥 and |퐶0| = |퐶1|, then

휆 휆 i풪(1 , 퐶0) ≈ i풪(1 , 퐶1)

2.4 Garbling Schemes

A garbling scheme is an algorithm Garble which takes as inputs a function 푓, an input 푥, and the security parameter 1휆 in unary. Garble outputs a garbled function 푓˜ and a garbled input 푥˜. The representation of functions and their inputs will be important when we discuss succinctness. Classical garbling schemes represent 푓 as a circuit and 푥 as a bitstring; more recent ones and the construction of this work represent 푓 as a RAM program. In this work we represent inputs as an initial memory configuration for the RAM program.

Garble must satisfy the following properties:

– Correctness: For all functions 푓 and inputs 푥,

[︁ ⃒ ]︁ ˜ ⃒ ˜ 휆 Pr 푓(˜푥) = 푓(푥)⃒ 푓, 푥˜ ← Garble(푓, 푥, 1 ) = 1

– Security: There is a PPT algorithm Sim such that for all functions 푓 and inputs 푥, Sim(푓(푥), |푓|, |푥|, 1휆) ≈ Garble(푓, 푥, 1휆)

Garbling schemes (including ours) commonly have another property:

– Separability: Garble can be decomposed into three algorithms: KeyGen,

Garble푃 푟표푔 and Garble퐼푛. KeyGen takes the security parameter in unary and gen-

24 erates a garbling key, which is shared between Garble푃 푟표푔 and Garble퐼푛. Condi-

tioned on 퐾, Garble푃 푟표푔 garbles the function independently of Garble퐼푛 garbling the input.

That is,

휆 Garble(푓, 푥, 1 ) ≡ Garble푃 푟표푔(퐾, 푓), Garble퐼푛(퐾, 푥)

when 퐾 ← KeyGen(1휆).

Remark 3. Separability is a property which can apply to any transformation of a RAM program and corresponding input. The other transformations we use in this work – namely, an Oblivious RAM and a weak garbling scheme – will also satisfy separability. One can easily see that the composition of two separable transformations is itself separable.

The last property of our RAM garbling scheme, and the one most unique to our work, is succinctness. This is nothing more than requiring that Garble푃 푟표푔

and Garble퐼푛 both run in polynomial time, when functions are represented as RAM programs.

25 26 Chapter 3

Techniques Overview

3.1 Asymmetrically Constrained Encapsulation

One of the contributions of this work is the definition of a primitive that we call Asym- metrically Constrained Encryption (ACE), which greatly enhances our ability to show indistinguishability of obfuscated programs. Informally, this is a deterministic and secret-key encryption scheme which guarantees both confidentiality and authenticity. Crucially, in addition to this, the scheme allows to constrain both the encryption key 퐸퐾 and the decryption key 퐷퐾. That is, for a set 푆, one can compute a constrained encryption key 퐸퐾{푆} that can encrypt all messages outside of 푆, and a constrained decryption key 퐷퐾{푆} that can decrypt all ciphertexts that decrypt to messages outside 푆.

Using ACE. Our constructions are i풪-obfuscations of circuits that decrypt their inputs (which are ciphertexts) and encrypt their outputs. We would like to argue that the i풪 obfuscation of two circuits 퐶0 and 퐶1 are indistinguishable if they differ only on a set of “bad inputs” 푆 which the adversary cannot encrypt. But i풪 is not that strong a notion. It guarantees indistinguishability only if encryptions of bad inputs do not exist. Previous works avoid this issue by assuming a stronger notion of obfuscation called extractability obfuscation [BCP14] or differing inputs obfuscation [ABG+13b], which we wish to avoid.

27 Our solution tries to achieve non-existence of bad ciphertexts to the extent pos- sible. Correctness of the encryption scheme means that every input, even a bad one, must have a valid encryption. Our first idea is to puncture the decryption key so ciphertexts of bad messages never decrypt. To move between these two worlds unnoticeably, we also require that the real decryption key 퐷퐾 is computationally indistinguishable from a “punctured” decryption key 퐷퐾{푆}.

However, this last requirement seems to raise concerns. If the set of bad inputs is known and the encryption key is known, then a punctured decryption key cannot be indistinguishable from an unpunctured one. Unfortunately, our obfuscated circuits contain the encryption key 퐸퐾, which makes this a real concern. Our second idea is to puncture the encryption key also, so that it cannot encrypt bad inputs any more. Once this is done, one can expect indistinguishability of punctured versus unpunctured decryption keys. Indeed, this is exactly what we achieve. Namely, the punctured decryption key 퐷퐾{푆} and the real decryption key 퐷퐾 are indistinguishable given the punctured encryption key 퐸퐾{푆′} for any set 푆′ ⊇ 푆, as well as ciphertexts of any messages that lie outside of 푆.

Finally, the set of bad inputs cannot be arbitrary if we require the encryption and decryption keys to be small. Indeed, the keys could otherwise be used to compress arbitrary data, which is information theoretically impossible. Our solution is to only consider sets of bad inputs 푆 for which set membership is decidable by a small circuit

퐶푆 that takes as input 푥 and decides if 푥 ∈ 푆.

3.1.1 Construction

Our ACE construction is heavily inspired by the “hidden sparse triggers” technique of Sahai and Waters [SW14], and is identical to the “puncturable deterministic en- cryption” of Waters [Wat14]. In particular, our ciphertexts for a message 푚 are of the form (︀ 퐶 = 퐹1(푚), 퐹2(퐹1(푚)) ⊕ 푚)

28 where 퐹1 and 퐹2 are puncturable pseudorandom functions (PPRFs). Despite these similarities, ACE is a much more demanding primitive. In particular, ACE is different from puncturable deterministic encryption inat least two respects. First, we define and crucially use the fact that the encryption and decryption keys can be punctured separately, on different sets. Secondly, and perhaps more importantly, a punctured decryption key 퐷퐾{푆} is indistinguishable from 퐷퐾{푆′} as long as one does not have access to ciphertexts of messages in the symmetric difference 푆 ∆ 푆′.

Indistinguishability of Punctured Decryption: A Sketch. We will show how to puncture a decryption key at one additional point, and then use an easy sequence of hybrids to puncture the entire set 푆. Here we suffer a security loss of |푆|, but in our applications 푆 and in fact the entire message space 푀 will have polynomially bounded size, so this is acceptable. To puncture at a point 푚*, we use an injective bit-commitment (constructed from an injective OWF) to indistinguishably sabotage a check in Dec. This check asserts that for a ciphertext 훼‖훽, 훼 = 퐹1(푚), where 푚 is the tentative decrypted value. We will make this (i풪-obfuscated) check always fail by making the following indistinguishable changes.

1. If 푚 = 푚*, the check is replaced by Commit(0; 훼) = 푧, where 푧 is hard-coded

* as Commit(0; 퐹1(푚 )). The indistinguishability of this change uses i풪, where functional equivalence follows from Commit’s injectivity.

* * 2. The key for 퐹1 is punctured at 푚 giving 퐾{푚 }. Indistinguishability is by i풪,

where functional equivalence follows because 퐹1 is no longer ever evaluated at 푚*.

3. 푧 is hard-coded as Commit(0; 푟), where 푟 is chosen uniformly at random. Indis-

tinguishability is by the pseudorandomness at punctured points of 퐹1. We note

in order for this step to work, all copies of 퐹1 seen by the adversary must be

29 punctured at 푚*. In particular, this is where the argument breaks down if the adversary is given 퐸퐾 or an encryption of 푚*.

4. 푧 is hard-coded as Commit(1; 푟). Indistinguishability is by the computationally hiding property of the commitment.

5. The check that Commit(0; 훼) = 푧 is replaced by False. Indistinguishability is by i풪, since by injectivity 푧 is not in the image of Commit(0, ·), so no 훼 will make the check return True.

* 6. The key for 퐹1 is unpunctured at 푚 by i풪.

3.2 Garbled RAM Overview

Our main application of ACE is the construction of a succinct garbled RAM. We give an overview of the construction and the proof ideas here. We refer the reader to Chapter 8 for formal definitions and proofs. Our construction is greatly simplified by defining a weaker primitive which we call weak garbling of RAM programs.

3.2.1 Weak Garbling

Definition

Syntactically, a weak garbling scheme (parameterized by 푠) is an algorithm WkGarble. As input, WkGarble takes a RAM program Π and an initial memory ⃗푥, and as output it produces another RAM program Π′ and initial memory ⃗푥′. In addition to correctness (Π(⃗푥) = Π′(⃗푥′)) and efficiencyΠ ( ′ must take roughly the same time and space as Π and ⃗푥′ must be roughly the same size as ⃗푥), WkGarble must satisfy the following security property:

Suppose 푖1, . . . , 푖푡 are a sequence of memory addresses describable by a circuit Γ with |Γ| ≤ 푠. Let Π0 and Π1 be RAM machines, and let ⃗푥0 and ⃗푥1 be initial memory

0 1 configurations such that first 푡 locations accessed in Π |⃗푥0 and Π |⃗푥1 are 푖1, . . . , 푖푡 (here 0 1 Π|⃗푥 denotes the execution of Π on ⃗푥). Suppose that after 푡 steps Π |⃗푥0 and Π |⃗푥1 both

30 output the same value, or they both have the same state and memory configuration. If Π0 and Π1’s transition functions are also functionally equivalent on all states with timestamp larger than 푡, then WkGarble(Π0, ⃗푥0) ≈ WkGarble(Π1, ⃗푥1).

Construction

WkGarble first transforms Π and ⃗푥 to have a “verifiable reads” property against “semi-malicious memories”. It then transforms the resulting ⃗푥′ and the transition function of Π′ so that every word of memory is encrypted using ACE. Similarly, the state of Π′ is also encrypted using ACE. Finally, the transition function is i풪- obfuscated, and WkGarble outputs (Π′′, ⃗푥′′). In the language of Chapter 5, Π′′, ⃗푥′′ is Harden((Π′, (푄, 푊 )), ⃗푥′), where 푄 denotes the universe of states of Π′ and 푊 denotes the universe of words in ⃗푥′. A semi-malicious memory is an adversarial external memory storing words from a universe 푊 at addresses in [푁]. When the semi-malicious memory receives a read request, rather than answering correctly, it can answer with any arbitrary previously written value. In order for this to differ meaningfully from a fully malicious memory (which can answer read requests completely arbitrarily), 푊 should be larger than {0, 1}. Indeed in our applications 푊 will be strings of 푂(log 휆) length. Π′ having verifiable reads means that Π′ can verify that the values read from memory are correct. Against a semi-malicious memory, this property is essentially the same as the predictably timed writes of [GHRW14], and in fact our construction uses basically the same generic transformation. A location tag and timestamp is added to each word written to memory. To ensure that each word read from memory has a predictable timestamp, we access memory via a binary tree structure, in which each node holds the timestamps of its children.

Security Proof

The security of the above construction would be straight-forward if instead of i풪- obfuscation we could use a much stronger obfuscator, such as virtual black-box obfus- cation. In Chapter 5, we develop general techniques for showing indistinguishability

31 of i풪-obfuscated programs which take ACE-encrypted inputs and outputs. The proof of security for WkGarble shows a sequence of indistinguishable hybrids, the 푖푡ℎ of which replaces the first 푖 steps of Π with dummy accesses, and gives as initial memory the memory configuration of Π after 푖 steps of execution on ⃗푥. Showing indistinguishability then consists of applying Theorem 2 with a suitable invariant.

3.2.2 Full Garbling Construction

We garble a RAM program Π and an initial memory ⃗푥 by applying two transforma- tions. We first apply the oblivious RAM transformation of Shi etal.[SCSL11], which was simplified by Chung and Pass [CP13]. We then weakly garble the result to obtain (Π˜, ⃗푥˜). We note that both the ORAM and our weak garbling scheme are separable – They consist of a key generation phase, after which the program and initial memory con- figuration can be transformed separately. This implies that the full garbling scheme is also separable.

3.2.3 Overview of the Security Proof

Simulator

We would like to simulate Garble(Π, ⃗푥) given only Π(⃗푥), 푇 (the running time of Π on ⃗푥). Sim(Π(⃗푥)) is defined as the weak garbling of (Π′, ⃗푥′), where

– Π′ first makes 푂˜(푇 ) dummy accesses, each of which “looks like” an ORAM executing a single underlying access. Then Π′ outputs Π(⃗푥).

– ⃗푥′ is a length-푁 ′ memory configuration containing just ⊥. Here 푁 ′ is the number of words that the ORAM needs to simulate a memory of size 푁.

We show that Sim(Π(⃗푥)) is indistinguishable from Garble(Π, ⃗푥) by a hybrid ar- gument. The main idea is that by using a suitable property of the oblivious RAM, we can bootstrap WkGarble into a full garbling scheme. In the hybrids, we replace

32 the real computation with a dummy computation one step at a time, starting at the beginning.

ORAM Properties

We require the following two natural properties from the ORAM:

1. The locations accessed by the ORAM at a time 푗 are independent of the un- derlying accesses, and can be efficiently sampled.

2. The ORAM’s state and memory configuration at time 푡 can be efficiently sam- pled given the initial memory configuration, the underlying accesses, and the real accesses made by the ORAM.

3. The ORAM has low worst-case overhead. In particular, the ORAM simulates each underlying access with only polylog(푁) physical accesses. Here 푁 is the size of the underlying memory.

The ORAM of Shi et al. [SCSL11], simplified by Chung and Pass [CP13], has all of these properties. These properties together with WkGarble allows us to move (in a long sequence of hybrids) to a hybrid in which all of the locations accessed by Π˜ are computable by a small circuit Γ. A last application of WkGarble indistinguishably switches the initial memory to encryptions of many ⊥s. This hybrid is then simulatable given only Π(⃗푥), |Π|, |⃗푥|, and the running time 푇 .

3.2.4 Optimizations

Eliminating double obfuscation In our construction as given, we have two layers of obfuscation - one to implement ACE, and an obfuscated circuit that contains ACE keys. This is only necessary for the modularity of our proof - the properties of ACE could be proved directly in our construction with only one layer of i풪 obfuscation.

33 Generating the encrypted initial memory We note that the 푂(푆) · poly(휆) dependence in our scheme is only in the running time of Encode, and does not use ob- fuscation. This is because this encryption can be done with the underlying PRF keys rather than the obfuscated encryption algorithm. In particular, we only obfuscate one small circuit.

34 Chapter 4

Asymmetrically Constrained Encryption

We define and construct a new primitive called Asymmetrically Constrained Encryp- tion (ACE). Essentially, an ACE scheme is a deterministic authenticated secret key encryption scheme, with the following additional properties:

1. For each message 푚 and key 퐾, there is at most a single string that decrypts to 푚 under key 퐾.

2. The full decryption algorithm is indistinguishable from a version which is punc- tured at a succinctly described set of messages (namely at some 푆 ⊂ ℳ which is decidable by a small circuit). Furthermore, indistinguishably holds even when given ciphertexts and a constrained encryption algorithm, as long as the trivial attack doesn’t work.

These properties will be central in our analysis of iterated circuit obfuscation.

4.1 Definition

An asymmetrically constrained encryption scheme consists of five polynomial-time algorithms (Setup, GenEK, GenDK, Enc, Dec) described as follows:

35 ∙ Setup: Setup(1휆, 1푛, 1푠) is a randomized algorithm that takes as input the security parameter 휆, the input length 푛, and a “circuit succinctness” parameter 푠, all in unary. Setup then outputs a secret key 푆퐾.

Let ℳ = {0, 1}푛 denote the message space, where 푛 = poly(휆). While 푛 and 푠 are arguments of Setup, we will generally think of them as given.

∙ (Constrained) Key Generation: Let 푆 ⊂ ℳ be any set whose membership

is decidable by a circuit 퐶푆. We say that 푆 is admissible if |퐶푆| ≤ 푠. Intu- itively, the set size parameter 푠 denotes the upper bound on the size of circuit description of sets on which encryption and decryption keys can be punctured.

– GenEK(푆퐾, 퐶푆) takes as input the secret key 푆퐾 of the scheme and the

description of circuit 퐶푆 for an admissible set 푆. It outputs an encryption key 퐸퐾{푆}. We write 퐸퐾 to denote 퐸퐾{∅}.

– GenDK(푆퐾, 퐶푆) also takes as input the secret key 푆퐾 of the scheme and

the description of circuit 퐶푆 for an admissible set 푆. It outputs a decryp- tion key 퐷퐾{푆}. We write 퐷퐾 to denote 퐷퐾{∅}.

Unless mentioned otherwise, we will only consider admissible sets 푆 ⊂ ℳ.

∙ Encryption: Enc(퐸퐾′, 푚) is a deterministic algorithm that takes as input an encryption key 퐸퐾′ (that may be constrained) and a message 푚 ∈ ℳ and outputs a ciphertext 푐 or the reject symbol ⊥.

∙ Decryption: Dec(퐷퐾′, 푐) is a deterministic algorithm that takes as input a decryption key 퐷퐾′ (that may be constrained) and a ciphertext 푐 and outputs a message 푚 ∈ ℳ or the reject symbol ⊥.

Correctness. An ACE scheme is correct if the following properties hold:

36 1. Correctness of Decryption: For all 푛, all 푚 ∈ ℳ, all sets 푆, 푆′ ⊂ ℳ s.t. 푚∈ / 푆 ∪ 푆′,

⎡ ⃒ ⎤ ⃒ 휆 ⃒ 푆퐾 ← Setup(1 ), ⎢ ⃒ ⎥ ⎢ ⃒ ⎥ Pr ⎢Dec(퐷퐾, Enc(퐸퐾, 푚)) = 푚⃒ 퐸퐾 ← GenEK(푆퐾, 퐶푆′ ), ⎥ = 1. ⎣ ⃒ ⎦ ⃒ ⃒ 퐷퐾 ← GenDK(푆퐾, 퐶푆)

Informally, this says that Dec ∘ Enc is the identity on messages which are in neither of the punctured sets.

2. Equivalence of Constrained Encryption: Let 푆퐾 ← Setup(1휆). For any message 푚 ∈ ℳ and any sets 푆, 푆′ ⊂ ℳ with 푚 not in the symmetric difference 푆∆푆′,

⎡ ⃒ ⎤ ⃒ 휆 ⃒ 푆퐾 ← Setup(1 ), ⎢ ⃒ ⎥ ⎢ ′ ⃒ ⎥ Pr ⎢Enc(퐸퐾, 푚) = Enc(퐸퐾 , 푚)⃒ 퐸퐾 ← GenEK(푆퐾, 퐶푆), ⎥ = 1. ⎣ ⃒ ⎦ ⃒ ′ ⃒ 퐸퐾 ← GenEK(푆퐾, 퐶푆′ )

3. Unique Ciphertexts: If Dec(퐷퐾, 푐) = Dec(퐷퐾, 푐′) ̸= ⊥, then 푐 = 푐′.

4. Safety of Constrained Decryption: For all strings 푐, all 푆 ⊂ ℳ,

[︁ ⃒ ]︁ ⃒ 휆 Pr Dec(퐷퐾, 푐) ∈ 푆⃒ 푆퐾 ← Setup(1 ), 퐷퐾 ← GenDK(푆퐾, 퐶푆) = 0

This says that a punctured key 퐷퐾{푆} will never decrypt a string 푐 to a message in 푆.

5. Equivalence of Constrained Decryption: If Dec(퐷퐾{푆}, 푐) = 푚 ̸= ⊥ and 푚∈ / 푆′, then Dec(퐷퐾{푆′}, 푐) = 푚.

Security of Constrained Decryption. Intuitively, this property says that for any two sets 푆0, 푆1, no adversary can distinguish between the constrained key 퐷퐾{푆0} and 퐷퐾{푆1}, even given additional auxiliary information in the form of a constrained ′ ′ encryption key 퐸퐾 and ciphertexts 푐1, . . . , 푐푡. To rule out trivial attacks, 퐸퐾 is

37 constrained at least on 푆0∆푆1. Similarly, each 푐푖 is an encryption of a message

푚∈ / 푆0∆푆1. Formally, we describe security of constrained decryption as a multi-stage game between an adversary 풜 and a challenger.

∙ Setup: 풜 choose sets 푆0, 푆1, 푈 s.t. 푆0∆푆1 ⊆ 푈 ⊆ ℳ and sends their circuit de-

scriptions (퐶푆0 , 퐶푆1 , 퐶푈 ) to the challenger. 풜 also sends arbitrary polynomially

many messages 푚1, . . . , 푚푡 such that 푚푖 ∈/ 푆0∆푆1.

The challenger chooses a bit 푏 ∈ {0, 1} and computes the following: (a) 푆퐾 ←

휆 Setup(1 ), (b) 퐷퐾{푆푏} ← GenDK(푆퐾, 퐶푆푏 ), (c) 퐸퐾 ← GenEK(푆퐾, ∅), (d) 푐푖 ←

Enc(퐸퐾, 푚푖) for every 푖 ∈ [푡], and (e) 퐸퐾{푈} ← GenEK(푆퐾, 퐶푈 ). Finally, it

sends the tuple (퐸퐾{푈}, 퐷퐾{푆푏}, {푐푖}) to 풜.

∙ Guess: 풜 outputs a bit 푏′ ∈ {0, 1}.

⃒ ′ 1 ⃒ The advantage of 풜 in this game is defined as adv풜 = ⃒Pr[푏 = 푏] − 2 ⃒. We require that adv풜(휆) ≤ negl(휆).

Remark 4. Looking ahead, in our construction of ACE, we have

adv풜(휆) = poly(|푆0∆푆1|, 휆) · (adv푂푊 퐹 (휆) + advi풪(휆))

for any 푆0, 푆1. When |푆0∆푆1| is super-polynomial, we require something like subex- ponential hardness of one-way functions as well as subexponential hardness of i풪 in

order for adv풜 to be negligible. As we will see later, our garbled RAM construction 푂(log 휆) has ℳ = {0, 1} , which means |푆0∆푆1| ≤ |ℳ| ≤ poly(휆) so we can rely on polynomial assumptions.

Selective Indistinguishability of Ciphertexts. Intuitively, this property says

that no adversary can distinguish between encryptions of 푚0 from encryptions of 푚1, even given additional auxiliary information. The auxiliary information corresponds to constrained encryption and decryption keys 퐸퐾′, 퐷퐾′, as well as some ciphertexts

38 ′ ′ 푐1, . . . , 푐푡. In order to rule out trivial attacks, 퐸퐾 and 퐷퐾 should both be punctured on at least {푚0, 푚1}, and none of 푐1, . . . , 푐푡 should be an encryption of 푚0 or 푚1.

* * Formally, we require that for all sets 푆, 푈 ⊂ ℳ, for all 푚0, 푚1 ∈ 푆 ∩ 푈, and all * * 푚1, . . . , 푚푡 ∈ ℳ ∖ {푚0, 푚1}, the distribution

* * 퐸퐾{푆}, 퐷퐾{푈}, 푐0, 푐1, 푐1, . . . , 푐푡

is indistinguishable from

* * 퐸퐾{푆}, 퐷퐾{푈}, 푐1, 푐0, 푐1, . . . , 푐푡

휆 where 푆퐾 ← Setup(1 ), 퐸퐾 ← GenEK(푆퐾, ∅), 퐸퐾{푆} ← GenEK(푆퐾, 퐶푆), * * 퐷퐾{푈} ← GenDK(푆퐾, 퐶푈 ), 푐푏 ← Enc(퐸퐾, 푚푏 ), and 푐푖 ← Enc(퐸퐾, 푚푖).

Definition 3. An ACE scheme is secure if it satisfies the properties of correctness, unique ciphertexts, security of constrained decryption and selective indistinguishabil- ity of ciphertexts.

4.2 Construction

We now present a construction of an asymmetrically constrainable encryption scheme. Our scheme is based on the “hidden triggers” mechanism in the deniable encryption scheme of [SW14], and additionally makes use of indistinguishability obfuscation.

Notation. Let ℱ1 = {퐹1,푘}푘∈{0,1}휆 be a puncturable injective pseudorandom func- 푛 2푛+log1+휖(휆) tion family, where 퐹1,푘 : {0, 1} → {0, 1} . Let ℱ2 = {퐹2,푘}푘∈{0,1}휆 be 2푛+log1+휖(휆) another puncturable pseudorandom function family, where 퐹2,푘 : {0, 1} → {0, 1}푛. Let i풪 be an indistinguishability obfuscator for all circuits. Let 푠 denote the set description size parameter for ACE. Let 푝 = poly(푛, 휆, 푠) be a parameter to be determined later.

39 Construction. We now proceed to describe our scheme 풜풞ℰ = (Setup, GenEK, GenDK, Enc, Dec).

휆 휆 Setup(1 ): The setup algorithm first samples fresh keys 퐾1 ← GenPRF(1 ) and 퐾2 ← 휆 GenPRF(1 ) for the puncturable PRF families ℱ1 and ℱ2 respectively. We will write

퐹푖 to denote the function 퐹푖,퐾푖 .

GenEK((퐾1, 퐾2), 퐶푆): The encryption key generation algorithm takes as input keys

퐾1, 퐾2 and the circuit description 퐶푆 of an admissible set 푆. It prepares a circuit representation of 풢enc (Algorithm1), padded to be of size 푝. Next, it computes the

encryption key 퐸퐾{푆} ← i풪(풢enc) and outputs the result.

Constants: 퐾1, 퐾2, circuit 퐶푆 Input: Message 푚 ∈ {0, 1}푛 1 if 퐶푆(푚) then return ⊥; 2 else 3 훼 ← 퐹1(푚); 4 훽 ← 퐹2(훼) ⊕ 푚; 5 return 훼‖훽 6 end

Algorithm 1: (Constrained) Encryption 풢enc

GenDK((퐾1, 퐾2), 퐶푆): The decryption key generation algorithm takes as input keys

퐾1, 퐾2 and the circuit description 퐶푆 of an admissible set 푆. It prepares a circuit

representation of 풢dec (Algorithm2), padded to be of size 푝. It then computes the

decryption key 퐷퐾{푆} ← i풪(풢dec) and outputs the result.

Constants: 퐾1, 퐾2, circuit 퐶푆 Input: Ciphertext 푐 ∈ {0, 1}3푛+log1+휖(휆) 푛 1 parse 푐 as 훼‖훽 with 훽 ∈ {0, 1} ; 2 푚 ← 퐹2(훼) ⊕ 훽; 3 if 퐶푆(푚) then return ⊥; 4 else if 훼 ̸= 퐹1(푚) then return ⊥; 5 else return 푚;

Algorithm 2: (Constrained) Decryption 풢dec

Enc(퐸퐾′, 푚): The encryption algorithm simply runs the encryption key program 퐸퐾′ on message 푚 to compute the ciphertext 푐 ← 퐸퐾′(푚).

40 Dec(퐷퐾′, 푐): The decryption algorithm simply runs the decryption key program 퐷퐾′ on the input ciphertext 푐 and returns the output 퐷퐾′(푐). This completes the description of our construction of 풜풞ℰ.

4.3 Proof of Security

Correctness. We first argue correctness:

1. Correctness of Decryption: This follow directly from the definitions of Algo- rithm1 and Algorithm2 and the perfect correctness of i풪.

2. Equivalence of Constrained Encryption: This follows directly from the definition of Algorithm1 and the perfect correctness of i풪.

3. Uniqueness of Encryptions: A ciphertext 푐 = 훼‖훽 decrypts to 푚 ̸= ⊥ only if

훼 = 퐹1(푚) and 훽 = 퐹2(훼). So there can be only one ciphertext which decrypts to 푚.

4. Safety of Constrained Decryption: This follows directly from the definition of Algorithm2 and the perfect correctness of i풪.

5. Equivalence of Constrained Decryption: This follows directly from the definition of Algorithm2 and the perfect correctness of i풪.

Security of Constrained Decryption. We now prove that 풜풞ℰ satisfies security of constrained decryption.

Lemma 1. The proposed scheme 풜풞ℰ satisfies security of constrained decryption.

푛 Proof. Let 푆0, 푆1, 푈 be arbitrary subsets of {0, 1} s.t. 푆0∆푆1 ⊆ 푈 and let 퐶푆0 , 퐶푆1 , 퐶푈

be their circuit descriptions. Let 푚1, . . . , 푚푡 be arbitrary messages such that every 휆 푚푖 ∈ 푀 ∖ (푆0∆푆1). Let 푆퐾 ← Setup(1 ), 퐸퐾 ← GenEK(푆퐾, ∅) and 퐸퐾{푈} ←

GenEK(푆퐾, 퐶푈 ). For every 푖 ∈ [푡], let 푐푖 ← Enc(퐸퐾, 푚푖). Further, for 푏 ∈ {0, 1}, let

41 퐷퐾{푆푏} ← GenDK(푆퐾, 퐶푆푏 ). We now argue that no PPT distinguisher can distin-

guish between (퐸퐾{푈}, 퐷퐾{푆0}, {푐푖}) and (퐸퐾{푈}, 퐷퐾{푆1}, {푐푖}) with advantage more than 휖푆0,푆1 = |푆0∆푆1| · (adv푂푊 퐹 (휆) + advi풪(휆)).

We will prove this via a sequence of |푆0∆푆1| indistinguishable hybrid experiments

퐻푖 where in experiment 퐻0, the decryption key is 퐷퐾{푆0} whereas in experiment

퐻|푆0Δ푆1|, the decryption key is 퐷퐾{푆1}. Without loss of generality, we will suppose that 푆0 ⊆ 푆1. The general case follows because

퐷퐾{푆0} ≈ 퐷퐾{푆0 ∩ 푆1} ≈ 퐷퐾{푆1}

where we have omitted the auxiliary information of encryption keys and ciphertexts.

푡ℎ We now proceed to give details. Let 푢푖 denote the lexicographically 푖 element of

푆1 ∖ 푆0. Throughout the experiments, we will refer to the encryption key and decryp- tion key programs given to the distinguisher as 퐸퐾′ and 퐷퐾′ respectively. Similarly, (unless stated otherwise) we will refer to the unobfuscated algorithms underlying 퐸퐾′

′ ′ ′ and 퐷퐾 as 풢enc and 풢dec, respectively.

푡ℎ ′ Hybrid 퐻푖: In the 푖 hybrid, the decryption key program 풢dec first checks whether

푚 ∈ 푆1 and 푚 ≤ 푢푖. If this is the case, then it simply outputs ⊥. Otherwise, it ′ behaves in the same manner as 퐷퐾{푆0}. The underlying unobfuscated program 풢dec is described in Algorithm3.

′ For notational simplicity, set 푢0 = −∞. Therefore, in experiment 퐻0, 풢dec has ′ the same functionality as 퐷퐾{푆0}, and in 퐻|푆1∖푆0|, 풢dec has the same functionality

as 퐷퐾{푆1}.

We now construct a series of intermediate hybrid experiments 퐻푖,0, . . . , 퐻푖,7 where

퐻푖,0 is the same as 퐻푖 and 퐻푖,7 is the same as 퐻푖+1. For every 푗, we will prove that

퐻푖,푗 is computationally indistinguishable from 퐻푖,푗+1, which will establish that 퐻푖

and 퐻푖+1 are computationally indistinguishable.

Hybrid 퐻푖,0: This is the same as experiment 퐻푖.

′ Hybrid 퐻푖,1: This is the same as experiment 퐻푖,0 except that we modify 풢dec as in

42 Input: ciphertext 푐 ∈ {0, 1}3푛+log1+휖(휆)

Constants: PPRF keys 퐾1, 퐾2, circuits 퐶푆0 , 퐶푆1 1 Parse 푐 as 훼‖훽; 2 푚 ← 퐹2(훼) ⊕ 훽; 3 if 푚 ≤ 푢푖 and 푚 ∈ 푆1 then return ⊥ ; 4 else if 푚 ∈ 푆0 then return ⊥; 5 else if 훼 ̸= 퐹1(푚) then return ⊥; 6 else return 푚; ′ Algorithm 3: (Constrained) Decryption 풢dec in Hybrid 푖

Algorithm4. If the decrypted message 푚 is 푢푖+1, then instead of checking whether ′ 훼 ̸= 퐹1(푚) in line 5, 풢dec now checks whether Commit(0; 훼) ̸= Commit(0; 퐹1(푢푖)), where Commit is a perfectly binding injective commitment.

Input: ciphertext 푐 ∈ {0, 1}3푛+log1+휖(휆)

Constants: PPRF keys 퐾1, 퐾2, circuits 퐶푆0 , 퐶푆1 , message 푢푖+1, 푧 = Commit(0; 퐹1(푢푖+1)) 1 Parse 푐 as 훼‖훽; 2 푚 ← 퐹2(훼) ⊕ 훽; 3 if 푚 ≤ 푢푖 and 푚 ∈ 푆1 then return ⊥ ; 4 else if 푚 ∈ 푆0 then return ⊥; 5 else if 푚 = 푢푖+1 and Commit(0; 훼) ̸= 푧 then return ⊥; 6 else if 훼 ̸= 퐹1(푚) then return ⊥; 7 else return 푚; ′ Algorithm 4: 풢dec in Hybrid 푖, 1

′ Hybrid 퐻푖,2: This is the same as experiment 퐻푖,1 except that we modify 풢dec as follows:

′ ∙ The PRF key 퐾1 in 풢dec is punctured at 푢푖+1, i.e., 퐾1 is replaced with 퐾1{푢푖+1} ←

PuncturePRF(퐾1, 푢푖+1).

Hybrid 퐻푖,3: This is the same as experiment 퐻푖,2 except that we modify the program ′ ′ ′ 풢enc underlying 퐸퐾 such that the PRF key 퐾1 hardwired in 풢enc is replaced with ′ the same punctured key 퐾1{푢푖+1} ← PuncturePRF(퐾1, 푢푖+1) as is used in 풢dec

Hybrid 퐻푖,4: This is the same as experiment 퐻푖,3 except that the hardwired value ′ 푧 in 풢dec is now computed as Commit(0; 푟) where 푟 is a randomly chosen string in

43 {0, 1}2푛+log1+휖(휆).

Hybrid 퐻푖,5: This is the same as experiment 퐻푖,4 except that the hardwired value 푧 in ′ 2푛+log1+휖(휆) 풢dec is now set to Commit(1; 푟) where 푟 is a randomly chosen string in {0, 1} .

′ Hybrid 퐻푖,6: This is the same as experiment 퐻푖,5 except that we now modify 풢dec such

that it outputs ⊥ when the decrypted message 푚 is 푢푖+1. An equivalent description ′ of 풢dec is that in line 3, it now checks whether 푚 ≤ 푢푖+1 instead of 푚 ≤ 푢푖.

Hybrid 퐻푖,7: This is the same as experiment 퐻푖,6 except that the PRF key corre- ′ ′ sponding to 퐹1 is unpunctured in both 풢enc and 풢dec. That is, we replace 퐾1{푢푖+1} ′ ′ with 퐾1 in both 풢enc and 풢dec. Note that experiment 퐻푖,7 is the same as experiment

퐻푖+1. This completes the description of the hybrid experiments. We now argue their indistinguishability.

Indistinguishability of 퐻푖,0 and 퐻푖,1. Since Commit is injective, we have that the following two checks are equivalent: 훼 ̸= 퐹1(푚) and Commit(0; 훼) ̸= Commit(0; 퐹1(푚)). ′ Then, we have that the algorithms 풢dec in 퐻푖,0 and 퐻푖,1 are functionally equivalent.

Therefore, the indistinguishability of 퐻푖,0 and 퐻푖,1 follows from the security of the indistinguishability obfuscator i풪.

′ ′′ Indistinguishability of 퐻푖,1 and 퐻푖,2. Let 풢dec (resp., 풢dec) denote the unobfuscated ′ algorithms underlying the decryption key program 퐷퐾 in experiments 퐻푖,1 (resp., ′ ′′ 퐻푖,2). We will argue that 풢dec and 풢dec are functionally equivalent. The indistin-

guishability of 퐻푖,0 and 퐻푖,1 then follows from the security of the indistinguishability obfuscator i풪.

Let 푐푖+1 = 훼푖+1‖훽푖+1 denote the unique ciphertext such that Dec(퐷퐾, 푐푖+1) = 푢푖+1 (where 퐷퐾 denotes the unconstrained decryption key program). First note that on

′ ′′ ′ any input 푐 ̸= 푐푖+1, both 풢dec and 풢dec have identical behavior, except that 풢dec uses the ′′ PRF key 퐾1 while 풢dec uses the punctured PRF key 퐾1{푢푖+1}. Since the punctured ′ ′′ PRF scheme preserves functionality under puncturing, we have that 풢dec(푐) = 풢dec(푐). ′ Now, on input 푐푖+1, after decrypting to obtain 푢푖+1, 풢dec computes Commit(0; 퐹1(푢푖+1)) ′′ and then checks whether Commit(0; 훼푖+1) ̸= Commit(0; 퐹1(푢푖+1)) whereas 풢dec simply

44 ′′ checks whether Commit(0; 훼푖) ̸= 푧. But since the value 푧 hardwired in 풢dec is equal ′ ′′ to Commit(0; 퐹1(푢푖+1)), we have that 풢dec(푐푖) = 풢dec(푐푖). ′ ′′ Thus we have that 풢dec and 풢dec are functionally equivalent.

′ ′′ Indistinguishability of 퐻푖,2 and 퐻푖,3. Let 풢enc (resp., 풢enc) denote the unobfus- ′ cated algorithms underlying the encryption key program 퐸퐾 in experiments 퐻푖,1 ′ ′′ and 퐻푖,2. Note that the only difference between 풢enc and 풢enc is that the former con- tains the PRF key 퐾1 while the latter contains the punctured PRF key 퐾1{푢푖+1}. ′ ′′ However, note that neither 풢enc nor 풢enc ever evaluate 퐹1 on 푢푖+1. Thus, since the ′ ′′ punctured PRF preserves functionality under puncturing, we have that 풢enc and 풢enc are functionally equivalent. The indistinguishability of 퐻푖,2 and 퐻푖,3 follows from the security of the indistinguishability obfuscator i풪.

Indistinguishability of 퐻푖,3 and 퐻푖,4. From the security of the punctured PRF, it follows immediately that 퐻푖,3 and 퐻푖,4 are computationally indistinguishable.

Indistinguishability of 퐻푖,4 and 퐻푖,5. 퐻푖,4 and 퐻푖,5 are computationally indistin- guishable because of the hiding properties of Commit.

′ ′′ Indistinguishability of 퐻푖,5 and 퐻푖,6. Let 풢dec (resp., 풢dec) denote the unobfuscated ′ algorithms underlying the decryption key program 퐷퐾 in experiments 퐻푖,5 and 퐻푖,6. ′ ′′ We will argue that with all but negligible probability, 풢dec and 풢dec are functionally equivalent. The indistinguishability of 퐻푖,5 and 퐻푖,6 then follows from the security of the indistinguishability obfuscator i풪.

Let 푐푖 denote the unique ciphertext corresponding to the message 푢푖. We note that with overwhelming probability, the random string 푧 (hardwired in both 퐻푖,5 and

퐻푖,6) is not in the image of the PRG. Thus, except with negligible probability, there does not exist an 훼푖 such that 푃 푅퐺(훼푖) = 푧. This implies that except with negligible ′ ′′ ′ ′′ probability, 풢dec(푐푖) = ⊥. Since 풢dec also outputs ⊥ on input 푐푖 and 풢dec, 풢dec behave ′ ′′ identically on all other input ciphertexts, we have that 풢dec and 풢dec are functionally equivalent.

Indistinguishability of 퐻푖,6 and 퐻푖,7. This follows in the same manner as the indistinguishability of experiments 퐻푖,2 and 퐻푖,3. We omit the details.

45 Completing the proof. Note that throughout the hybrids, we use the security of three cryptographic primitives: injective commitments, pseudorandom functions, and indistinguishability obfuscation. In total, (ignoring constant multiplicative factors) we have |푆0∆푆1| hybrids where 푆0∆푆1 is the symmetric set difference. Thus, overall, we get that no adversary can distinguish between

퐸퐾{푈}, 퐷퐾{푆0}, 푐1, . . . , 푐푡 and

퐸퐾{푈}, 퐷퐾{푆1}, 푐1, . . . , 푐푡 with advantage more than

휖푆0,푆1 = |푆0∆푆1| · (adv퐶푂푀 (휆) + adv푃 푅퐹 (휆) + advi풪(휆)).

Replacing adv퐶푂푀 (휆)+adv푃 푅퐹 (휆) with poly(휆)·adv푂푊 퐹 , where OWF is the injective one-way function used to construct the commitment and puncturable PRF, we get

휖푆0,푆1 = |푆0∆푆1| · poly(휆) · (adv푂푊 퐹 (휆) + advi풪(휆)) as required.

Selective Indistinguishability of Ciphertexts. We now prove that 풜풞ℰ satisfies indistinguishability of ciphertexts.

Lemma 2. The proposed scheme 풜풞ℰ satisfies selective indistinguishability of ci- phertexts.

Proof. The proof of the lemma proceeds in a sequence of hybrid distributions where we make indistinguishable changes to 퐸퐾{푈}, 퐷퐾{푆}, and the challenge ciphertexts

* * (푐0, 푐1). The “extra” ciphertexts 푐1, . . . , 푐푡 remain unchanged throughout the hybrids.

Hybrid 퐻0. This is the real world distribution. For completeness (and to ease the presentation of the subsequent hybrid distributions), we describe the sampling process

46 푛 here. Let 푆, 푈 ⊂ ℳ = {0, 1} be the sets chosen by the adversary and 퐶푆, 퐶푈 be * * their corresponding circuit descriptions. Let 푚0, 푚1 be the challenge messages in 푛 푆 ∩ 푈 and (푚1, . . . , 푚푡) be the extra messages in {0, 1} . Then

휆 휆 1. Sample PRF keys 퐾1 ← GenPRF(1 ), 퐾2 ← GenPRF(1 ), 푏 ← {0, 1}.

* * * * * * * 2. For 푏 ∈ {0, 1}, compute 훼푏 ← 퐹1(푚푏 ), 훾푏 ← 퐹2(훼푏 ) and 훽푏 = 훾푏 ⊕ 푚푏 . Let * * * 푐푏 = 훼푏 ‖훽푏 .

3. For every 푗 ∈ [푡], compute 훼푗 ← 퐹1(푚푗), 훾푗 ← 퐹2(훼푗) and 훽푗 = 훾푗 ⊕ 푚푗. Let

푐푗 = 훼푗‖훽푗.

′ ′ 4. Compute 퐸퐾{푈} ← i풪(풢enc) where 풢enc is described in Algorithm5.

′ ′ 5. Compute 퐷퐾{푆} ← i풪(풢dec) where 풢dec is described in Algorithm6.

6. Output the following tuple:

(︀ * * )︀ 퐸퐾{푆}, 퐷퐾{푈}, 푐푏 , 푐1−푏, 푐1, . . . , 푐푡 .

Constants: 퐾1, 퐾2, circuit 퐶푈 Input: message 푚 1 if 퐶푈 (푚) then return ⊥; 2 else 3 훼 ← 퐹1(푚); 4 훽 ← 퐹2(훼) ⊕ 푚; 5 return 훼‖훽 6 end ′ Algorithm 5: 풢enc in Hybrid 퐻0

′ Hybrid 퐻1. Modify 풢enc: the hardwired PRF key 퐾1 is replaced with a punctured * * * * key 퐾1{푚0, 푚1} ← PuncturePRF(퐾1, {푚0, 푚1}).

′ Hybrid 퐻2. Modify 풢dec: the hardwired PRF key 퐾1 is replaced with a punctured * * * * key 퐾1{푚0, 푚1} ← PuncturePRF(퐾1, {푚0, 푚1}).

47 Constants: 퐾1, 퐾2, circuit 퐶푆 Input: ciphertext 푐 1 Parse 푐 as 훼‖훽; 2 푚 ← 퐹2(훼) ⊕ 훽; 3 if 퐶푆(푚) then return ⊥; 4 else if 훼 ̸= 퐹1(푚) then return ⊥; 5 else return 푚; ′ Algorithm 6: 풢dec in Hybrid 퐻0

′ Hybrid 퐻3. Modify 풢dec: Perform the following check in the beginning. If input * ′ ciphertext 푐 = 푐푏 for 푏 ∈ {0, 1} then output ⊥. The modified 풢dec is described in Algorithm7

* * * * Constants: 퐾1{푚0, 푚1}, 퐾2, circuit 퐶푆, 푐0, 푐1 Input: ciphertext 푐 * 1 if 푐 = 푐푏 for 푏 ∈ {0, 1} then return ⊥; 2 Parse 푐 as 훼‖훽; 3 푚 ← 퐹2(훼) ⊕ 훽; 4 if 퐶푆(푚) then return ⊥; 5 else if 훼 ̸= 퐹1(푚) then return ⊥; 6 else return 푚; ′ Algorithm 7: 풢dec in Hybrid 3

* * * * Hybrid 퐻4. Modify challenge ciphertexts 푐푏 = 훼푏 ‖훽푏 : Generate each 훼푏 as a truly random string.

′ Hybrid 퐻5. Modify 풢enc: the hardwired PRF key 퐾2 is replaced with a punctured * * * * * * key 퐾2{훼0, 훼1} ← PuncturePRF(퐾2, {훼0, 훼1}). Here we assume the set {훼0, 훼1} is sorted lexicographically.

′ Hybrid 퐻6. Modify 풢dec: we change the check performed in line 1 of Algorithm7. * For any input ciphertext 푐 = 훼‖훽, if 훼 = 훼푏 for 푏 ∈ {0, 1}, then output ⊥. Note ′ * * ′ that 풢dec only has 훼푏 hardwired as opposed to 푐푏 . The modified 풢dec is described in Algorithm8.

′ Hybrid 퐻7. Modify 풢dec: the hardwired PRF key 퐾2 is replaced with the same a * * * * ′ punctured key 퐾2{훼0, 훼1} ← PuncturePRF(퐾2, {훼0, 훼1}) as was used in 풢enc.

* * * * Hybrid 퐻8. Modify challenge ciphertexts 푐푏 = 훼푏 ‖훽푏 : For 푏 ∈ {0, 1}, generate 훽푏 as

48 * * * * Constants: PPRF keys 퐾1{푚0, 푚1}, 퐾2, circuit 퐶푆, ciphertext prefixes 훼0, 훼1 Input: ciphertext 푐 1 parse 푐 as 훼‖훽; * 2 if 훼 = 훼푏 for 푏 ∈ {0, 1} then return ⊥; 3 푚 ← 퐹2(훼) ⊕ 훽; 4 if 퐶푆(푚) then return ⊥; 5 else if 훼 ̸= 퐹1(푚) then return ⊥; 6 else return 푚; ′ Algorithm 8: 풢dec in Hybrid 6 a truly random string. This completes the description of the hybrid experiments. We will now first prove indistinguishability of experiments 퐻푖 and 퐻푖+1 for every 푖. We will then observe that 1 no adversary can guess bit 푏 in the final hybrid 퐻8 with probability better than 2 . This suffices to prove the claim.

′ ′′ Indistinguishability of 퐻0 and 퐻1. Let 풢enc and 풢enc denote the algorithms un- derlying the encryption key program 퐸퐾{푈} in 퐻0 and 퐻1 respectively. Note that ′ ′′ due to the check performed in line 1, both 풢enc and 풢enc output ⊥ on each challenge * ′ ′′ message 푚푏 . In particular, line 4 is not executed in both 풢enc and 풢enc for every input * message 푚푏 . (In fact, line 4 is only executed when the input message 푚∈ / 푆.) Then, since the punctured PRF scheme preserves functionality under puncturing, we have

′ ′′ * * that 풢enc (using 퐾1) and 풢enc (using 퐾1{푚0, 푚1}) are functionally equivalent. The

indistinguishability of 퐻0 and 퐻1 follows from the security of the indistinguishability obfuscator i풪.

′ ′′ Indistinguishability of 퐻1 and 퐻2. Let 풢dec and 풢dec denote the algorithms un-

derlying the decryption key program 퐷퐾{푆} in 퐻1 and 퐻2 respectively. Note that ′ ′′ due to the check performed in line 3, both 풢dec and 풢dec output ⊥ on either challenge * ′ ′′ * ciphertext 푐푏 . In particular, line 4 is not executed in both 풢dec and 풢dec for either 푚푏 . Then, since the punctured PRF scheme preserves functionality under puncturing, we

′ ′′ * * have that 풢dec (using 퐾1) and 풢dec (using 퐾1{푚0, 푚1}) are functionally equivalent.

As a consequence, the indistinguishability of 퐻1 and 퐻2 follows from the security of the indistinguishability obfuscator i풪.

49 ′ ′′ Indistinguishability of 퐻2 and 퐻3. Let 풢dec and 풢dec denote the algorithms un-

derlying the decryption key program 퐷퐾{푆} in 퐻2 and 퐻3 respectively. Note that ′ ′′ ′′ the only difference between 풢dec and 풢dec is that 풢dec performs an additional check * whether the input ciphertext 푐 is equal to either challenge ciphertext 푐푏 . However, ′ ′ note that due to line 3, 풢dec also outputs ⊥ on such input ciphertexts. Thus, 풢dec ′′ and 풢dec are functionally equivalent and the indistinguishability of 퐻2 and 퐻3 follows from the security of the indistinguishability obfuscator i풪.

Indistinguishability of 퐻3 and 퐻4. This follows immediately from the security of

the punctured PRF family ℱ1. (Note that each ciphertext 푐1, . . . , 푐푡 can be generated * * using the punctured PRF key, because they are not encryptions of 푚0 or 푚1.)

Indistinguishability of 퐻4 and 퐻5. Note that with overwhelming probability, the * random strings 훼푏 are not in the range of the 퐹1. Therefore, except with negligible * probability, there does not exist a message 푚 such that 퐹1(푚) = 훼푏 for 푏 ∈ {0, 1}. ′ Since the punctured PRF scheme preserves functionality under puncturing, 풢enc (using ′′ 퐾2) and 풢enc (using 퐾2{Σ2}) behave identically on all input messages, except with

negligible probability. The indistinguishability of 퐻4 and 퐻5 follows from the security of the indistinguishability obfuscator i풪.

′ ′′ Indistinguishability of 퐻5 and 퐻6. Let 풢dec and 풢dec denote the algorithms under-

lying the decryption key program 퐷퐾{푆} in 퐻5 and 퐻6 respectively. Note that the ′ ′′ ′′ only difference between 풢dec and 풢dec is their description in line 1: 풢dec hard-codes an * ′ output of ⊥ for every ciphertext of the form 푐 =훼 ˜푏 ‖⋆ while 풢dec only hard-codes an * * * ′ output of ⊥ for ciphertexts 푐푏 = 훼푏 ‖훽푏 . In particular, the execution of 풢dec continues * * onward from line 2 for every 푐 = 훼푏 ‖훽 such that 훽 ̸= 훽푏 . However, note that with * overwhelming probability, each of the random strings 훼푏 is not in the range of the ′ * 퐹1. Thus in line 5, 풢dec will also output ⊥ on every 푐 = 훼푏 ‖훽, except with negligible ′ probability. As a consequence, we have that except with negligible probability, 풢dec ′′ and 풢dec have identical input/output behavior, and therefore, the indistinguishability of 퐻5 and 퐻6 follows from the security of the indistinguishability obfuscator i풪.

′ ′′ Indistinguishability of 퐻6 and 퐻7. Let 풢dec and 풢dec denote the algorithms un-

50 derlying the decryption key program 퐷퐾{푆} in 퐻6 and 퐻7 respectively. Note that due to the check performed in line 2 (see Algorithm8), line 3 is not executed in both

′ ′′ * 풢dec and 풢dec whenever the input ciphertext 푐 is of the form 훼 ‖⋆. Then, since the ′ the punctured PRF scheme preserves functionality under puncturing, 풢dec (using 퐾2) ′′ * * and 풢dec (using 퐾2{훼0, 훼1}) are functionally equivalent and the indistinguishability

of 퐻6 and 퐻7 follows from the security of the indistinguishability obfuscator i풪.

Indistinguishability of 퐻7 and 퐻8. This follows immediately from the security

of the punctured PRF family ℱ2 (note that with overwhelming probability, each * ciphertext 푐1, . . . , 푐푡 can be generated with the punctured 퐹2, because the 훼˜푏 are chosen randomly).

푏 Finishing the proof. Observe that in experiment 퐻8, every challenge ciphertext 푐푖 * * consists of independent uniformly random strings 훼푏 ‖훽푏 that information theoretically hide the bit 푏. Further, 퐸퐾{푈} and 퐷퐾{푆} are also independent of bit 푏. Therefore,

1 the adversary cannot guess the bit 푏 with probability better than 2 .

Remark 5. In our discussion, we used the security properties of i풪 somewhat loosely.

We basically said that if 퐶0 ≡ 퐶1 then i풪(퐶0) ≈ i풪(퐶1). In particular, we ignored

the constraint that |퐶0| = |퐶1|. To formalize the proof, we pad 풢enc to be as large

as 풢enc is in any of our hybrids, and we do a similar thing for 풢dec. One can check

that 풢enc and 풢dec are not too large in any of our hybrids. |풢enc| and |풢dec| are both bounded by poly(푛, 휆, 푠). Here 푛 is the message length, 휆 is the security parameter, and 푠 is the “succinctness” parameter – the maximum admissible size for a set’s circuit description.

51 52 Chapter 5

How to use ACE

We’ll develop techniques using ACE to garble computations consisting of repeated identical steps - for example, a Turing machine’s transition function. The garbled functionality will consist of an obfuscated “hardened block” which executes this step, acting on an encrypted intermediate state. If one uses ACE to encrypt the state and i풪 to obfuscate the block, then this chapter develops a useful condition for two hardened blocks to be indistinguishable.

5.1 Blocks

We aim to instantiate a computational “block”, to which we can apply a Harden transformation.

Definition 4. We say that 퐵 = (퐶, (ℳ1,..., ℳℓ)) is a block mapping

ℳ푖1 × · · · × ℳ푖푛 → ℳ푗1 × · · · × ℳ푗푚

if 퐶 is a circuit also mapping ℳ푖1 × · · · × ℳ푖푛 → ℳ푗1 × · · · × ℳ푗푚 . Here each ℳ푘

is a message space, and we say that ℳ1,..., ℳℓ are the encapsulated types of 퐵.

Example 1. The principle block we will harden in our RAM garbling construction is (훿, (푄, 푊 )), where 훿 : 푄 × 푊 → 푄 × 푊 × [푁] × 푌 is the transition function for a RAM program.

53 Definition 5. Given a block 퐵 = (퐶, (ℳ1,..., ℳℓ)) mapping ℳ푖1 × · · · × ℳ푖푛 → 푖 * 휆 1 ℓ ℳ푗1 × · · · × ℳ푗푚 as well as inputs ⃗푥 ∈ ℳ푖 , we define Harden(1 , 퐵, ⃗푥 , . . . , ⃗푥 ) as:

휆 1. Let 퐸퐾푖, 퐷퐾푖 ← Setup퐴퐶퐸(1 ) for 푖 = 1, . . . , 푙 such that 퐸퐾푖 can be used to

encrypt messages in ℳ푖.

Let ⎧ ⎨⎪Dec(퐷퐾푗, 푥) if 푗 ∈ {1, . . . , 푙} 퐷푗(푥) = ⎩⎪푥 otherwise

and ⎧ ⎨⎪Enc(퐸퐾푗, 푥) if 푗 ∈ {1, . . . , 푙} 퐸푗(푥) = ⎩⎪푥 otherwise

′ 2. Define 퐶 = (퐸푗1 ‖···‖퐸푗푚 ) ∘ 퐶 ∘ (퐷푖1 ‖···‖퐷푖푛 ) (here 푓‖푔 denotes parallel composition of functions, defined as (푓‖푔)(푥, 푦) = 푓(푥), 푔(푦)).

휆 ′ * 1 * ℓ * 3. Harden outputs i풪(1 , 퐶 ), Enc (퐸퐾1, ⃗푥 ),..., Enc (퐸퐾ℓ, ⃗푥 ), where Enc de- notes component-wise encryption.

For ease of notation, we will often omit the security parameter and even ⃗푥1, . . . , ⃗푥ℓ, just write Harden(퐵) instead.

Remark 6. Harden is separable. Shared randomness can be used to compute the set

ℓ of keys {퐸퐾푖, 퐷퐾푖}푖=1, and then 퐵 can be hardened independently of the inputs ⃗푥1, . . . , ⃗푥ℓ.

Example 2. When Π is a RAM program with transition function 훿 : 푄 × 푊 → 푄 ×

푊 ×[푁]×푌 and ⃗푥 is an initial memory configuration (푥1, . . . , 푥푁 ), Harden((훿, (푄, 푊 ), ⃗푥) consists of two parts. First is the i풪 obfuscation of the circuit depicted in Figure 5-1. The other is the ACE-encrypted initial memory:

Enc(퐸퐾푊 , 푥1),..., Enc(퐸퐾푊 , 푥푁 )

54 Output 푦

푞 CPU: 푞′ 푞˜ Dec Enc 푞˜′ 훿

푤 푤′ Address 푎

Dec Enc

푤˜ 푤˜′

Encapsulated Memory

Figure 5-1: This circuit takes an encrypted state 푞˜ and an encrypted word 푤˜ as input. As outputs it may produce an encrypted state 푞˜′, an encrypted word 푤˜′, and a memory address 푎 to access next. Alternatively, it may produce a final output 푦. 푤 is interpreted as the word read from memory by 푞, while 푤′ is the word written to memory by 푞. 푎 is the location accessed by 푞′.

5.2 Preliminary Definitions

In this section we prove a general theorem giving conditions under which

휆 1 ℓ Harden(1 , (퐶0, (ℳ1,..., ℳℓ)), (⃗푥0, . . . , ⃗푥0)

is indistinguishable from

휆 1 ℓ Harden(1 , (퐶1, (ℳ1,..., ℳℓ)), (⃗푥1, . . . , ⃗푥1),

when 퐶0 and 퐶1 both map from the same domain ℳ푖1 ×· · · ℳ푖푛 to the same codomain

ℳ푗1 × · · · × ℳ푗푚 .

Definition 6 (Invariant Set). Given a block 퐵 with encapsulated types ℳ1,..., ℳℓ,

55 * *1 as well as vectors ⃗푥1 ∈ ℳ1, . . . , ⃗푥ℓ ∈ ℳℓ , we say that sets (푆1 ⊂ ℳ1, . . . , 푆ℓ ⊂ ℳℓ) are invariant if:

1. For 푖 ∈ {1, . . . , ℓ}, 푆푖 contains each element of ⃗푥푖

2. 퐵(푇푖1 × · · · × 푇푖푛 ) ⊂ 푇푗1 × · · · 푇푗푚 , where we define

⎧ ⎨⎪푆푘 if 푘 ∈ {1, . . . , ℓ} 푇푘 = ⎩⎪ℳ푘 othrwise

Remark 7. The minimal invariant sets are called the reachable sets, and have an intuitive definition: 푆푘 is the set of all possible elements of ℳ푘 that can be reached by applying 퐵 to previously obtained inputs, if the unencapsulated inputs are allowed to be freely chosen. The essential limitation of i풪 compared to VBB obfuscation in our techniques is that we can only reason about succinctly described invariant sets, rather than precisely the reachable set. This is because we want our garbled programs to be succinct, and their size is determined by the size of the largest hybrid.

Definition 7. We say that a set 푆 is 푠-succinct if membership in 푆 is decidable by circuits with total size 푠.

Informally, the main condition for Harden(퐵0) and Harden(퐵1) to be indistinguish- able is that 퐵0 and 퐵1 are in some sense “isomorphic” – that is, functionally equivalent up to permutations of the encapsulated types. Actually our theorem will apply when the isomorphism is succinctly described; we shall see that more interesting cases follow as a corollary by repeatedly applying this basic case.

Definition 8. We say that 퐵0 and 퐵1 with encapsulated types ℳ1,... ℳℓ are iso- morphic on invariant sets 푆1, . . . , 푆ℓ by injections 휄푗 : 푆푗 ˓→ ℳ푗 if on 푇푖1 × · · · × 푇푖푛 , if

(휄푗1 × · · · × 휄푗푚 ) ∘ 퐵0 ≡ 퐵1 ∘ (휄푖1 × · · · × 휄푖푛 )

1The notation 푆* denotes the set of all finite sequences of elements in 푆.

56 where for 푗∈ / {1, . . . , ℓ}, 휄푗 is defined as the identity function mapping ℳ푗 → ℳ푗.

푇푘 is again defined as in Definition 6.

We will prove that Harden(퐵0) and Harden(퐵1) are indistinguishable if 퐵0 and 퐵1 are isomorphic on succinct invariant sets, with one caveat: each encapsulated type must have a timestamp, which is bounded by some polynomial in 휆 and increases on

every execution of 퐵0 or 퐵1.

Definition 9. We say that a block 퐵 with encapsulated types ℳ1,... ℳℓ is ascending if each encapsulated type has a timestamp attribute, and for all inputs to 퐵, the encapsulated outputs always have larger timestamp than any encapsulated input. We say that 퐵 is 푇 -bounded if 퐵 outputs ⊥ whenever any of its inputs have timestamp greater than 푇 .

5.3 Diamond Theorem

Theorem 2. Suppose blocks 퐵0 and 퐵1 are isomorphic on 푠-succinct sets 푆1, . . . , 푆ℓ

by “singleton” injections 휄1, . . . , 휄ℓ. That is, each 휄푗 differs from the identity on at most

one point. Suppose further that 퐵0 and 퐵1 are ascending and poly(휆)-bounded, and

|ℳ푗| = poly(휆) for each encapsulated type ℳ푗. Then

Harden(퐵0, ⃗푥1, . . . , ⃗푥ℓ) ≈ Harden(퐵1, 휄¯1(⃗푥1),..., 휄¯ℓ(⃗푥ℓ)

where 퐵0 and 퐵1’s circuits are both padded by an amount 푝 which is polynomial in the succinctness parameter 푠, the security parameter 휆, and the input / output lengths.

Proof. We give several indistinguishable hybrid distributions 퐻0 through 퐻6, starting with the left-hand side and ending with the right-hand side.

Hybrids Overview Let 푆1, . . . , 푆ℓ be 푠-succinct invariant sets of 퐵0 and 휄1, . . . , 휄ℓ

be injections such that such that (휄푗1 × · · · × 휄푗푚 ) ∘ 퐵0 ≡ 퐵1 ∘ (휄푖1 × · · · × 휄푖푛 ) on

푇푖1 × · · · × 푇푖푛 .

57 1. First, we puncture the ACE keys (both encryption and decryption) for each

encapsulated type ℳ푗 at ℳ푗 ∖ 푆푗. This is an indistinguishable change by Lemma 3.

2. For each 푗 ∈ {1, . . . , ℓ}, suppose 휄푗 maps 푥푗 ↦→ 푦푗. We also puncture 퐸퐾푗 and

퐷퐾푗 at 푥푗 and 푦푗. Where necessary to preserve functionality, we hard-code the

correspondence 푥푗 ↔ 푥푗 and 푦푗 ↔ 푦푗 . Here 푥푗 and 푦푗 denote Enc(퐸퐾푗, 푥푗)

and Enc(퐸퐾푗, 푦푗) respectively. If 푦푗 ∈/ 푆푗, we only hard-code 푥푗 ↔ 푥푗 (not

푦푗 ↔ 푦푗 ). This change is indistinguishable by i풪.

3. In the hard-coded correspondence, we swap 푥푗 and 푦푗 . We apply the same

substitution to the element-wise encryptions of ⃗푥1,..., ⃗푥ℓ. This is indistin- guishable by ACE’s ciphertext indistinguishability, applied ℓ times – once for each encapsulated type.

4. In each hard-coded correspondence, we swap 푥푗 and 푦푗. Simultaneously, we

replace 퐵0 by 퐵1. This is indistinguishable by i풪 because this is functionally equivalent to replacing 퐵 by 휄−1 × · · · × 휄−1 ∘ 퐵 ∘ 휄 × · · · × 휄 , where all 0 푗1 푗푚 1 푖1 푖푛

encapsulated inputs inputs are guaranteed to be in the appropriate 푆푗.

5. For each 푗 ∈ {1, . . . , ℓ}, we reduce the puncturing of 퐸퐾푗 and 퐷퐾푗 so that

the keys for type ℳ푗 are punctured at ℳ푗 ∖ 휄푗(푆푗) and remove the hard-coded

correspondence 푥푗 ↔ 푥푗 and 푦푗 ↔ 푦푗 . This is indistinguishable by i풪.

6. For each 푗 ∈ {1, . . . , ℓ}, we unpuncture 퐸퐾푗 and 퐷퐾푗. Since (휄1(푆1), . . . , 휄ℓ(푆ℓ))

must be invariant sets of 퐵1 containing 휄¯1(⃗푥1),..., 휄¯ℓ(⃗푥ℓ), this is indistinguish- able by Lemma 3. Now the distribution is exactly that of the right-hand side.

It now remains to prove indistinguishability of step 1 (and similarly, of step 6).

58 Lemma 3. If 퐵 is an ascending block with 푠-succinct invariant sets 푆1, . . . , 푆ℓ are containing ⃗푥1, . . . , ⃗푥ℓ, then

˜ * * ˜ * * 퐵, Enc (⃗푥1),..., Enc (⃗푥ℓ) ≈ 퐵{ℳ푗 ∖ 푆푗}, Enc (⃗푥1),..., Enc (⃗푥ℓ)

˜ ˜ Here 퐵 is constructed as in Harden(퐵), and 퐵{ℳ푗 ∖ 푆푗} is the same but with the

ACE keys for each encapsulated type ℳ푗 punctured at ℳ푗 ∖ 푆푗.

Proof. We give a sequence of hybrid distributions starting with the left-hand side and ending with the right-hand side. In these hybrids we puncture the ACE keys on an increasing sequence of sets.

Definition of 퐻푖. Define

푍푗,푖 = {푚 ∈ ℳ푗 : 푚’s timestamp is less than 푖 and 푚∈ / 푆푗}

Then 퐻푖 is defined as:

˜ * * 퐵{푍1,푖, . . . , 푍ℓ,푖}, Enc ( ⃗푥1),..., Enc (⃗푥ℓ)

It is easy to see that 퐻0 is the left-hand side of our desired indistinguishability, while 퐻푇 +1 (where 푇 is the maximum possible timestamp) is the right-hand side. So we just need to show that 퐻푖 is indistinguishable from 퐻푖+1. This follows from the following two indistinguishable steps:

1. For each encapsulated type ℳ푗, we puncture its encryption key 퐸퐾푗 at 푍푗,푖+1.

This is indistinguishable because in 퐻푖, the decryption keys are punctured so

that every input passed to 퐵 with timestamp less than 푖 is in 푆푘 for the appro- priate 푘. By the invariance of 푆, every output of 퐵 with timestamp less than

푖 + 1 must also be in 푆푗. So nothing in 푍푗,푖+1 is ever encrypted. By ACE’s equivalence of punctured encryption keys, puncturing the encryption key does not change functionality and is hence indistinguishable by i풪.

59 2. For each encapsulated type ℳ푗, we puncture its decryption key 퐷퐾푗 at 푍푗,푖+1. This is indistinguishable by ACE’s indistinguishability of punctured decryption

keys, since the encryption key 퐸퐾푗 is already punctured at 푍푗,푖+1.

As stated earlier, isomorphism by singleton injections is a basic case which extends to isomorphism by other succinctly described injections. In particular, we have the following corollaries.

Corollary 1. Let 휄1, . . . , 휄ℓ be injections of size 푝 = 푂(1), meaning 휄푗(푥) ̸= 푥 for

푝 values of 푥. If ascending blocks 퐵0 and 퐵1 are such that (휄푗1 × · · · × 휄푗푚 ) ∘ 퐵0 ≡

퐵1 ∘ (휄푖1 × · · · × 휄푖푛 ) on 푠-succinct invariant sets of 퐵0, then

Harden(퐵0, ⃗푥1, . . . , ⃗푥ℓ) ≈ Harden(퐵1, 휄¯1( ⃗푥1),..., 휄¯ℓ(⃗푥ℓ))

where the padding of 퐵0 and 퐵1 is proportional to 푠 + 푝.

Proof. This follows from the fact that any injection changing 푝 points can be written as 휄1 ∘ · · · ∘ 휄푝 for injections 휄1, . . . , 휄푝, and then applying Theorem 2 푝 times.

Corollary 2. Suppose for each 푗 ∈ {1, . . . , ℓ}, 휄푗 is an injection which is equal to

휃1 ∘ · · · ∘ 휃푝, where each 휃푖 is an injection of size 푂(1) and 푝 is poly(휆). Suppose further that for each 푖, 휃푖 ∘ · · · ∘ 휃푝 can be computed and inverted by circuits of size 푠. ′ If ascending blocks 퐵0 and 퐵1 are isomorphic on 푠 -succinct invariant sets 푆1, . . . , 푆ℓ by 휄1, . . . , 휄ℓ, then

Harden(퐵0, ⃗푥1, . . . , ⃗푥ℓ) ≈ Harden(퐵1, 휄¯1( ⃗푥1),..., 휄¯ℓ(⃗푥ℓ))

˜ ˜ ′ where the padding of 퐵0 and 퐵1 is proportional to 푂(푠 + 푠 ).

Proof. This follows from applying Corollary 1 푝 times.

Remark 8. While we have presented the diamond theorem for a single block, an analogous version for multiple blocks is provable using the same techniques. In spirit,

60 this is almost the same as combining the multiple blocks into a single block with an unencapsulated input selecting the block to execute.

61 62 Chapter 6

Garbling Iterated Functions

Our techniques are best understood in the application of garbling iterated functions, which may be of independent interest. In Chapter 8, we generalize the techniques presented here to garble RAM programs. We want to garble a function of the form 푓(푥) = 푔푇 (푥), where 푔푇 denotes 푔 composed with itself 푇 times. Garbling means encoding 푓 as 푓˜ and 푥 as 푥˜ such that:

1. (Correctness) One can compute 푓(푥) from 푓,˜ 푥˜.

2. (Security) 푓,˜ 푥˜ does not reveal side information other than 푇 , |푔|, and |푥|. More precisely, there is a probabilistic polynomial-time algorithm Sim such that 푓,˜ 푥˜ is computationally indistinguishable from Sim(푓(푥), 푇, |푔|, |푥|).

푓 and 푥 are chosen selectively, which is why we can speak of 푓,˜ 푥˜ as a distribution which depends only on 푓 and 푥. We will use the language of computational blocks which we developed in Chapter 5. An iterated function is just a computational block (푔) repeated 푡 times; our garbling will be the hardening of this block, along with the initial input 푥 .

6.1 Construction

Given a function 푓 = 푔푇 (푥), we first define a block 퐵 : 푄 → 푄 × 푋,where 푋 is the domain (and codomain) of the inner function 푔, and 푄 is [푇 ] × 푋. The notation

63 푄 → 푄 × 푋 simply means that 푄 is the only encapsulated type.

⎧ ⎨⎪(푡 + 1, 푔(푥)), ⊥ if 푡 < 푇 퐵((푡, 푥)) = ⎩⎪⊥, 푞 otherwise

The garbling of 푓 is Harden(퐵, (0, 푥)) with 푂(푛 + log 푇 ) padding, where 푛 is the bit-length of elements of 푋. Correctness of this construction follows because evidently given 퐵˜ and 0, 푥 , one can repeatedly evaluate 퐵˜ obtaining 1, 푔(푥) ,..., 푇, 푔푇 (푥) , and finally 푔푇 (푥) = 푓(푥).

6.2 Security Proof

Theorem 3. Assuming sub-exponentially secure i풪 and sub-exponentially secure in- jective one-way functions, there is a PPT algorithm Sim such that for all circuits 푔, all 푇 , all 푥, and all PPT 풜,

⎡ ⃒ ⎤ ⃒ 푏 ← {0, 1}; 푓˜ , 푥˜ ← Garble(푔, 푇 ); ˜ ⃒ 0 0 1 Pr ⎣풜(푓푏, 푥˜푏) = 푏⃒ ⎦ < + negl(휆) ⃒ ˜ 푇 2 ⃒ 푓1, 푥˜1 ← Sim(푔 (푥), 푇, |푥|, |푔|);

푖 Proof. Let 푥푖 denote 푔 (푥). We show a sequence of indistinguishable hybrid distribu- tions:

퐻0 ≈ 퐻1 ≈ · · · ≈ 퐻푇 ,

푇 where 퐻푇 is efficiently sampleable given 푔 (푥), |푥|, |푔|, and 푇 .

Hybrid 퐻푖. 퐻푖 is defined as Harden(퐵푖, (0, 푥푖)), where

⎧ ⎪(푡 + 1, 푥), ⊥ if 푡 < 푖 ⎪ ⎨⎪ 퐵푖((푡, 푥)) = (푡 + 1, 푔(푥)), ⊥ if 푖 ≤ 푡 < 푇 ⎪ ⎪ ⎩⎪⊥, 푥 otherwise

64 To show 퐻푖 ≈ 퐻푖+1, we introduce 푖 + 1 intermediate hybrids 퐻푖,푖 through 퐻푖,0.

Hybrid 퐻푖,푗. 퐻푖,푗 is defined as Harden(퐵푖,푗, (0, 푥푖)), where

⎧ ⎪(푡 + 1, 푥), ⊥ if 푡 < 푗 or 푗 < 푡 < 푖 + 1 ⎪ ⎨⎪ 퐵푖,푗((푡, 푥)) = (푡 + 1, 푔(푥)), ⊥ if 푡 = 푗 or 푖 + 1 ≤ 푡 < 푇 ⎪ ⎪ ⎩⎪⊥, 푥 otherwise

Claim 1. For each 푖 ∈ {0, . . . , 푇 − 1}, 퐻푖 ≈ 퐻푖,푖.

Proof. This follows from i풪 because 퐵푖,푖 is functionally equivalent to 퐵푖.

Claim 2. For each 푖 ∈ {0, . . . , 푇 − 1} and 푗 ∈ {1, . . . , 푖}, 퐻푖,푗 ≈ 퐻푖,푗−1.

Proof. We apply Theorem 2.

∙ Define

푆 = {(푡, 푥) ∈ 푄 : if 푡 ≤ 푗 then 푥 = 푥푖 and if 푡 = 푗 + 1 then 푥 = 푥푖+1}

푆 is clearly 푂(푛 + log 푇 )-succinct, and also (0, 푥푖) ∈ 푆.

∙ Let 휄 : 푆 ˓→ 푄 be the injection which maps (푗, 푥푖) to (푗, 푥푖+1), and is the identity elsewhere.

Invariance of 푆 푆 is an invariant of 퐵푖,푗, as can be seen by casework. Suppose ′ that (푡, 푥) ∈ 푆 and that 퐵푖,푗(푡, 푥) is 푞 , ⊥.

′ 1. If 푡 < 푗, then 푥 must be 푥푖. By definition of 퐵푖,푗, 푞 is (푡 + 1, 푥푖). 푡 + 1 is at most 푗, so 푞′ is in 푆.

′ 2. If 푡 = 푗, then 푥 must be 푥푖. By definition of 퐵푖,푗, 푞 is (푗 + 1, 푥푖+1), which is in 푆.

3. If 푡 > 푗, then 푞′ has a timestamp whic is greater than 푗 + 1, so 푞′ is vacuously in 푆.

65 Isomorphism of 퐵푖,푗 and 퐵푖,푗−1 on 푆 For all (푡, 푥) ∈ 푆, ((휄 × id) ∘ 퐵푖,푗)(푡, 푥) =

(퐵푖,푗−1 ∘ 휄)(푡, 푥), as can be seen by casework.

1. If 푡 < 푗 − 1, then 퐵푖,푗 and 퐵푖,푗−1 are functionally identical, and outputs in 푄 that either produce have timestamp 푡′ < 푗. This means that 휄 has no effect

on either the input or the output to 퐵푖,푗−1, so 퐵푖,푗 ∘ 휄 and (휄 × id) ∘ 퐵푖,푗−1 are functionally identical.

2. If 푡 = 푗 − 1, then 푥 = 푥푖. ((휄 × id) ∘ 퐵푖,푗)(푡, 푥) = (푗, 푥푖+1), ⊥. On the right-

hand side, we compute (퐵푖,푗−1 ∘ 휄)(푡, 푥). 휄(푡, 푥) = 푗 − 1, 푥푖. 퐵푖,푗−1(푗 − 1, 푥푖) =

(푗, 푥푖+1), ⊥

3. If 푡 = 푗, then 푥 = 푥푖. ((휄 × id) ∘ 퐵푖,푗)(푡, 푥) = (푗 + 1, 푥푖+1), ⊥. On the right-

hand side, we compute (퐵푖,푗−1 ∘ 휄)(푡, 푥). 휄((푡, 푥)) = 푗, 푥푖+1. 퐵푖,푗−1(푗, 푥푖+1) =

(푗 + 1, 푥푖+1), ⊥.

4. If 푡 > 푗, then 퐵푖,푗 and 퐵푖,푗−1 are functionally identical, and outputs in 푄 that either produce have timestamp 푡′ > 푗. This means that ¯휄 has no effect on

either the input or the output to 퐵푖,푗−1, so 퐵푖,푗 and ¯휄 ∘ 퐵푖,푗−1 ∘ ¯휄 are functionally identical.

Theorem 2 thus implies that 퐻푖,푗 ≈ 퐻푖,푗−1.

Claim 3. For each 푖 ∈ {0, . . . , 푇 − 1}, 퐻푖,0 ≈ 퐻푖+1.

Proof. This follows from Theorem 2.

∙ Define

푆 = {(푡, 푥): if 푡 = 0 then 푥 = 푥푖}.

푆 is clearly 푂(푛 + log 푇 )-succinct, and also (0, 푥푖) ∈ 푆.

∙ Let 휄 : 푆 ˓→ 푄 be the injection which maps (0, 푥푖) to (0, 푥푖+1) and is the identity elsewhere.

Invariance of 푆. 푆 is an invariant set of 퐵푖,0 because 퐵푖,0 never outputs an element of 푄 with timestamp 0, so 퐵푖,0’s outputs in 푄 are always vacuously in 푆.

66 Isomorphism of 퐵푖,0 and 퐵푖+1 on 푆. For all (푡, 푥) in 푆, ((휄 × id) ∘ 퐵푖,0)(푡, 푥) =

(퐵푖+1 ∘ 휄)(푡, 푥), as can be seen by casework.

1. If 푡 = 0, then 푥 = 푥푖. Then (휄×id)(퐵푖,0(푡, 푥)) = (1, 푥푖+1), ⊥. On the other hand,

we compute (퐵푖+1 ∘ 휄)(푡, 푥). 휄((푡, 푥)) = (0, 푥푖+1). 퐵푖+1(0, 푥푖+1) = (1, 푥푖+1), ⊥.

2. If 푡 > 0, 퐵푖,0 and 퐵푖+1 are functionally equivalent and 휄 is the identity, so the equality is clear.

Theorem 2 then implies the claim.

This concludes the security proof.

67 68 Chapter 7

Weak RAM Garbling

In this chapter, we begin to consider RAM programs. We generalize the techniques from Chapter 6 to construct a weak notion of RAM garbling.

7.1 Definitions

7.1.1 RAM program

There are several ways to formalize what a RAM program is, usually by defining some succinct transition function. This transition function will have an input state and an output state, along with several inputs and outputs for reading or writing to memory. We simplify the transition function’s definition by assuming that each memory access of the RAM program consists of a read followed by a write to the same address. Defining the asymptotic behavior of a RAM program as input sizes grow istricky, so we will suppose a RAM program is given with a fixed memory size 푁. The words stored at a memory address come from a word set 푊 . 푊 is commonly {0, 1}, but when transforming RAM machines (as when garbling a RAM program), it will be useful to support a more general word set. When a RAM program terminates, it outputs an answer 푦 ∈ 푌 . 푌 can be any set, but is often taken to be {0, 1}. Formally, we say that a RAM program Π is an integer 푁, finite sets 푄, 푊 , and

푌 , and a transition function 훿Π : 푄 × 푊 → 푄 × 푊 × [푁] ⊔ 푌 . A RAM program may

69 have an initial state 푞0 ∈ 푄, but without loss of generality, we will say that 푞0 is ⊥

(the real initial state can always be hard-coded in 훿Π).

7.1.2 Weak Garbling

Before constructing our full RAM garbling scheme, we will first construct a weak notion of garbling, satisfying the following property.

Definition 10. A weak garbling scheme is an algorithm WkGarble satisfying correct- ness and indistinguishability security, given below.

Correctness : For all RAM programs Π and inputs 푥,

[︁ ⃒ ]︁ ˜ ⃒˜ 휆 Pr Π(˜푥) = Π(푥)⃒Π, 푥˜ ← WkGarble(Π, 푥, 1 ) ≥ 1 − negl(휆)

Indistinguishability Security Let Π0 and Π1 be RAM programs, and let 푥0 and 휆 휆 푥1 be memory configurations. WkGarble(Π0, 푥0, 1 ) and WkGarble(Π1, 푥1, 1 ) are com- putationally indistinguishable if all of the following hold.

* – The first 푡 addresses 푎1, . . . , 푎푡* accessed by Π0 on 푥0 are the same as the first * 푡 addresses accessd by Π1 on 푥1. Furthermore, there is a small circuit Γ such * that for 푡 < 푡 , 푎푡 = Γ(푡).

– Either:

Π0(⃗푥0) and Π1(⃗푥1) yield identical internal states and external memory con- tents immediately after the 푡*-th step.

* Π0(⃗푥0) and Π1(⃗푥1) both give the same output immediately after the 푡 -th step.

– The transition function of Π0 and the transition function of Π1, restricted to states with a timestamp of at least 푡*, are functionally equivalent.

70 7.2 Construction

WkGarble(Π, ⃗푥) takes a RAM program Π and a memory configuration ⃗푥 as input and outputs Harden(Π′, ⃗푥′), where Π′ is another RAM program (to be defined), and ⃗푥′ is a memory configuration. Π′ is defined as a RAM program with Π hard-coded. Π′ views memory as a complete binary tree (we will say location 푖 stores a node whose children are at 2푖 and 2푖 + 1).

′ Π ’s states take the form (푡, 푡푒푥푝, 푖, 푖exp, 푞Π). 푡 is the timestamp, 푡푒푥푝 is the times- tamp that the currently accessed word must have. 푖 is the address that Π is currently accessing, and 푖exp is the location tag that the currently accessed word must have. 푞Π is the current state of the emulated Π.

′ To execute an access of Π to address 푎푡, Π accesses each node on the path to the 푡ℎ ′ ′ 푎푡 leaf. At each access, Π expects a particular timestamp, and Π will abort if the node it is given does not have that timestamp. Similarly, Π′ knows what location it is accessing, and it will abort if the given node does not have that location tag. Π′ knows what timestamp to expect because in addition to a “self-timestamp”, each non-leaf node contains timestamps for both of its children. The invariant is that a parent’s timestamp for its child should match the child’s self-timestamp. Π′ maintains this invariant in the obvious way. In particular, when Π′ accesses a node at time 푡, it writes that node back with two of its timestamps set to 푡 - the self-timestamp, and the timestamp corresponding to whichever child Π′ will access next.1 Our timestamp convention is that a state with timestamp 푡 writes a word with timestamp 푡, and the first timestamp is 1.

Say that ⃗푥 = (푥1, . . . , 푥푁 ). Without loss of generality suppose that 푁 is a power ′ ′ ′ of two. Then we define ⃗푥 as (푥1, . . . , 푥2푁−1), where

⎧ ⎪(푖, 0, 0, 0, ⊥) if 푖 ≤ 푁 − 1 ′ ⎨ 푥푖 = ⎩⎪(푖, 0, ⊥, ⊥, 푥푖−(푁−1)) otherwise.

1Π′ is said to be “at time 푡” if Π’s emulated state has timestamp 푡. Thus every node accessed in a tree traversal is written with the same self-timestamp.

71 ′ Generally the components of ⃗푥 take the form (푖, 푡, 푡퐿, 푡푅, 푣). We call 푖 the location label, 푡 the self-timestamp, 푡퐿 and 푡푅 the timestamps of the left (respectively right) child, and we call 푣 the stored value. Sometimes we say that a word is at leaf 푗 to

mean that its location label is 푗 + (푛 − 1) (and therefore the word’s value is 푥푗). WkGarble outputs Π˜, ⃗푥˜ ← Harden(Π′, (⊥), ⃗푥′).

7.3 Security Proof

It suffices to prove a simpler lemma: informally, that a RAM program performing 푗 dummy steps is indistinguishable from a RAM program performing 푗 + 1 dummy steps.

Definition 11. Suppose Π is a RAM program on 푁 words, and suppose Γ is a circuit mapping [푇 ] → [푁]. For any 푗 ∈ [푇 ], define 퐷푗,푞*,Γ,Π as a RAM program which executes the following steps:

1. At time 푡 ∈ {1, . . . , 푗 −1}, access but don’t modify address Γ(푡). At these times

the state of 퐷푗,푞*,Γ,Π is (푡, ⊥).

2. At time 푡 = 푗, resume execution as Π, using 푞* as the starting state and accessing whatever location 푞* accesses.

3. At time 푡 > 푗, just act as Π. At these times the state of 퐷푗,푞*,Γ,Π is (푡, 푞푡) for

some 푞푡 which is a state of Π.

Lemma 4. Let Π be a RAM machine which on state 푞푗 modifies memory ⃗푥푗−1

into ⃗푥푗 in a single step by accessing location Γ(푗), resulting in state 푞푗+1. Then

WkGarble(퐷푗,푞푗 ,Γ,Π, ⃗푥푗−1) is indistinguishable from WkGarble(퐷푗+1,푞푗+1,Γ,Π, ⃗푥푗)

Proof. We will let Π0 denote the circuit that WkGarble(퐷푗,푞푗 ,Γ,Π) hardens and Π1

denote the circuit that WkGarble(퐷푗+1,푞푗+1,Γ,Π) hardens. The lemma follows from an application of Corollary 2. Suppose that at location

Γ(푗), ⃗푥푗−1 has value 푣푗−1 while ⃗푥푗 has value 푣푗.

72 ′′ ′′ Definition of 푆푊 If 푊 is the set of words of Π0, define 푆푊 ⊂ 푊 as the set of

푤 = (푖, 푡, 푡퐿, 푡푅, 푣) satisfying the following properties:

1. If 푖 = Γ(푗) and 푡 < 푗, then 푣 = 푣푗.

2. If 푖 is on the path to Γ(푗) and if 푡 ≥ 푗, then 푡퐿 ≥ 푗 or 푡푅 ≥ 푗, whichever corresponds to the next node on the path to Γ(푗).

′′ ′′ Definition of 푆푄 If 푄 is the set of states of Π0, define 푆푄 ⊂ 푄 as the set of

푞 = (푡, 푡푒푥푝, 푖, 푖푒푥푝, 푞Π) satisfying the following properties:

1. 푞Π is of the form (푡, 푞푡) for some 푞푡 which is a state of Π. Also 0 ≤ 푡푒푥푝 < 푡, and

푖푒푥푝 is a node on the path to 푖.

2. If 푡 < 푗 then 푞Π = (푡, ⊥) and 푖 = Γ(푡).

3. If 푡 = 푗 then 푞Π = (푗, 푞푗) and 푖 = Γ(푗).

4. If 푡 ≥ 푗 and if 푖푒푥푝 is a node on the path to Γ(푗) then 푡푒푥푝 ≥ 푗.

′′ Definitions of 휄푊 and 휄푄 Define the injection 휄푊 : 푆푊 ˓→ 푊 as

⎧ ⎨⎪(푖, 푡, 푡퐿, 푡푅, 푣푗+1) if 푖 = Γ(푗) and 푡 < 푗 휄푊 ((푖, 푡, 푡퐿, 푡푅, 푣) = ⎩⎪(푖, 푡, 푡퐿, 푡푅, 푣) otherwise

′′ and 휄푄 : 푆푄 ˓→ 푄 as

⎧ ⎨⎪(푡, 푡푒푥푝, 푖, 푖푒푥푝, (푗, ⊥)) if 푡 = 푗 휄푄((푡, 푡푒푥푝, 푖, 푖푒푥푝, 푞Π) = ⎩⎪(푡, 푡푒푥푝, 푖, 푖푒푥푝, 푞Π) otherwise

It’s not hard to see that 푆푊 , 푆푄 are invariant sets of Π0.

Isomorphism of Π0 and Π1: In order to apply Corollary 2, we must observe that for all 푞 = (푡, 푡푒푥푝, 푖, 푖푒푥푝, 푞Π) ∈ 푆푄 and all 푤 = (푖푊 , 푡푊 , 푡퐿, 푡푅, 푣) ∈ 푆푊 ,

((휄푄 × 휄푊 × id × id) ∘ Π0)(푞, 푤) = (Π1 ∘ (휄푄 × 휄푊 ))(푞, 푤) (7.1)

73 This follows from casework: Without loss of generality 푡푒푥푝 = 푡푊 , 푖푒푥푝 = 푖푊 , be- cause otherwise the Verifiable Reads transformation ensures that both Π0(푞, 푤) and ′ ′ Π1(휄푄(푞), 휄푊 (푤)) output ⊥. Let 푡 denote the timestamp of the output state 푞 of ′ Π0(푞, 푤), and let 푤 denote the written word.

′ 1. If 푡 ≤ 푗 − 1 and 푡 ≤ 푗 − 1, then Π0(푞, ·) and Π1(푞, ·) are functionally equivalent ′ ′ and 휄푄(푞) = 푞, 휄푄(푞 ) = 푞 . Furthermore, given that 푡푊 < 푗 and 푖푊 = 푖푒푥푝, 휄푊

is “orthogonal” to both Π0(푞, ·) and Π1(푞, ·) in its action on memory words: 휄푊

acts only on the underlying value and location tag, while Π0 and Π1 ignore these

attributes. So indeed Π1(휄푄(푞), 휄푊 (푤)) is equal to ((휄푄 ×휄푊 ×id×id)∘Π0)(푞, 푤).

′ 2. If 푡 = 푗 − 1 and 푡 = 푗, then Π0(푞, ·) and Π1(푞, ·) are still functionally equiva- ′ lent and 휄푄(푞) = 푞. 푆푄 is defined enough so that we know 푞 is of the form

(푗, 푗 − 1, Γ(푗), Root, 푞푗), while Π1 produces a new state of the form (푗, 푗 − ′ 1, Γ(푗), Root, (푗, ⊥)) which is exactly 휄푄(푞 ).

′ Again since both 푡푊 and 푡푊 are less than 푗, an orthogonality argument shows ′ that Π1(푞, 휄푊 (푤)) outputs a word which is 휄푊 (푤 ), so 푃 푖1 also outputs a word ′ which is 휄푊 (푤 ).

′ 3. If 푡 = 푗 and 푡 = 푗, then Π0(푞, ·) and Π1(휄푄(푞), ·) are not accessing a leaf node, so ′ ′ they are functionally equivalent and 휄푊 (푤) = 푤 and 휄푊 (푤 ) = 푤 . Since 푞 and

휄푄(푞) aren’t accessing a leaf node, Π0’s and Π1’s action on them is orthogonal to

the action of 휄푄, so Π1(휄푄(푞), 휄푊 (푤)) is equal to ((휄푄 × 휄푊 × id × id) ∘ Π0)(푞, 푤).

′ 4. If 푡 = 푗 and 푡 = 푗 + 1, then by the constraints of 푆푄 and 푆푊 , 푞 is of the

form (푗, 푡푒푥푝, Γ(푗), Γ(푗), (푗, 푞푗)), and 푤 is of the form (Γ(푗), 푡푒푥푝, ⊥, ⊥, 푣푗) where

푡푒푥푝 < 푗.

So we can compute

휄푊 (푤) = (Γ(푗), 푡푒푥푝, ⊥, ⊥, 푣푗+1)

and

휄푄(푞) = (푗, 푡푒푥푝, Γ(푗), Γ(푗), (푗, ⊥))

74 and verify that Π1(휄푄(푞), 휄푊 (푤)) is equal to ((휄푄 × 휄푊 × id × id) ∘ Π0)(푞, 푤).

5. If 푡 > 푗, then Property 4 of 푆푄 ensures that 휄푊 (푤) = 푤 (otherwise 푖푒푥푝 = ′ ′ 푖푊 = Γ(푗) and 푡푊 < 푗, but 푡푒푥푝 ≥ 푗). The timestamps of 푞, 푞 , and 푤 ′ ′ are all at least 푗 + 1, so it is also the case that 휄푄(푞) = 푞, 휄푄(푞 ) = 푞 and ′ ′ 휄푊 (푤 ) = 푤 . So in Equation 7.1, the 휄푄’s and 휄푊 ’s vanish, and it is sufficient

to show Π0(푞, 푤) = Π1(푞, 푤).

But Π0(푞, ·) and Π1(푞, ·) are functionally equivalent, so this is true.

The full security property follows from Lemma 4 by a hybrid argument sketched in Figure 7-1. Lemma 4 states that paths differing by a diamond (or the left-most trian- gle) are indistinguishable, and it is easy to see that the top path can be transformed into the bottom path by a sequence of diamonds.

푞1 푞2 ··· 푞푡*−1

* (1, ⊥) (2, ⊥) ··· (푡 − 1, ⊥) 푞푡*

′ ′ ′ 푞1 푞2 ··· 푞푡*−1

Figure 7-1: Each path of length 푡* is a hybrid corresponding to some number of dummies followed by either Π0 or Π1. The initial memory configuration for the hybrid corresponding to a path is not shown, but depends on the first non-⊥ state.

75 76 Chapter 8

Full RAM Garbling

In this chapter, we construct a garbling scheme for RAM programs by combining the primitive of weak garbling from Chapter 7 and the strong oblivious RAM described in Appendix A. In contrast to weak garbling, here we hide the locations accessed by a RAM program, even if they are not locally computable. A RAM program’s input is given as an initial memory configuration ⃗푥 ∈ 푊 푁 .

8.1 Oblivious RAM (ORAM)

An ORAM is a way of transforming a RAM program to have an oblivious access pattern – one in which the addresses accessed reveal nothing about the underlying program. This is often thought of as an atomic transformation of a program Π and memory configuration ⃗푥 into an oblivious program Π′ and memory configuration ⃗푥′ given by AddORAM(Π, ⃗푥), but we will think of it as an online transformation.

푡ℎ That is, at the beginning of the 푡 underlying access, the ORAM has some state 푞푡.

Given an underlying address 푎푡, the ORAM emulates an access to 푎푡 by adaptively ′ ′ making 휂 accesses to addresses 푎푡,1,..., 푎푡,휂, and then returning a value 푥푡 and a

new state 푞푡+1. We implicitly assume the ORAM has a small worst-case overhead 휂;

in particular, 휂 is poly(log 푁). An ORAM also provides an Encode푂푅퐴푀 procedure which encodes the initial memory ⃗푥 and produces an initial ORAM state 푞0. Correctness requires that for any initial memory ⃗푥, and for any sequence of under-

77 lying accesses 푎1, . . . , 푎푡, the values 푥1, . . . , 푥푡 returned by the ORAM are with high

probability the same as if accesses 푎1, . . . , 푎푡 were executed non-obliviously on the unencoded ⃗푥. In addition to a standard information-theoretic ORAM security property, we will require that the conditional distribution on the ORAM’s internal state and external memory after 푡 underlying steps can be efficiently sampled given the following values:

– The addresses that the ORAM accessed up to time 푡.

– The underlying memory contents at time 푡.

– The most recent time that each underlying memory address was accessed.

In Appendix A, we show that the ORAM construction of Chung and Pass satisfies our desired properties.

8.2 Construction of Garble:

On input (Π, ⃗푥, 1휆), Garble outputs WkGarble(AddORAM(Π, ⃗푥, 1휆), 1휆). WkGarble and AddORAM are both functionality-preserving and separable transformations, so Garble is also functionality-preserving and separable.

8.3 Security Proof

We now show that our garbling scheme reveals nothing more than Π(⃗푥), as well as the running time 푇 , the memory size |⃗푥|, and the program size |Π|. More precisely:

Theorem 4. Assuming the existence of an injective one-way function and an i풪- obfuscator for circuits, there is a PPT algorithm Sim such that for all RAM programs Π, all initial memory configurations ⃗푥, if Π’s running time1 is 푇 , then for all PPT

1For now we speak only of worst-case running times, but achieving input-specific running times is also possible.

78 풜,

⎡ ⃒ ⎤ ⃒ 푏 ← {0, 1}, Π˜ , ⃗푥˜ ← Garble(Π, ⃗푥, 1휆), ˜ ˜ 휆 ⃒ 0 0 1 Pr ⎣풜(Π푏, ⃗푥푏, 1 ) = 푏⃒ ⎦ < + negl(휆). ⃒ ˜ ˜ 휆 2 ⃒ Π1, ⃗푥1 ← Sim(Π(⃗푥), 푇, |⃗푥|, |Π|, 1 )

′ ′ Proof Overview We give 2(푇 + 1) hybrid distributions 퐻0, 퐻1, 퐻1, . . . , 퐻푇 , 퐻푇 , followed by a qualitatively different hybrid 퐻푇 +1. 퐻0 will be exactly the distribution 휆 Garble(Π, ⃗푥, 1 ) and 퐻푇 +1 will be sampleable given only Π(⃗푥), 푇 , |⃗푥|, and |Π|, and so we will define Sim as the algorithm which samples 퐻푇 +1.

Proof. Our hybrids are as follows.

′ ′ ′ ′ Hybrid 퐻푖 (0 ≤ 푖 ≤ 푇 ). 퐻푖 is WkGarble(Π , ⃗푥푖), where Π and ⃗푥푖 are sampled as follows:

휆 1. Sample a puncturable PRF 퐹 ← GenPRF(1 ).

2. For 푗 = 1, . . . , 푖, define 퐼푗 = OSample(푗; 퐹 (푗)).

′ ⃗ 3. Sample 푞푂푅퐴푀,푖, ⃗푥푖 ← Sim푂푅퐴푀 (푡푖, ⃗푥푖, 퐼1, . . . , 퐼푖). Here after 푖 steps of executing

Π on ⃗푥, ⃗푥푖 is the external memory contents and ⃗푡푖 is the vector of last-written times for each external memory locations.

4. Define Π′ as a RAM program which accesses but does not modify locations

푡ℎ ′ 퐼1, . . . , 퐼푖 and then resumes emulation of Π as usual from the 푖 + 1 step. Π

has 푞푂푅퐴푀,푖 and 퐹 hard-coded. If Π on ⃗푥 terminates after 푖 steps and produces an output Π(⃗푥), then Π′ has Π(⃗푥) hard-coded. Otherwise, if Π’s internal state

′ after 푖 execution steps is given by 푞Π,푖, then Π has 푞Π,푖 and 푎푖 hard-coded, where

푎푖 is the address accessed by 푞Π,푖.

′ ′ ′ ′ ′ ′ Hybrid 퐻푖 (0 ≤ 푖 ≤ 푇 ) 퐻푖 is WkGarble(Π , ⃗푥푖+1), where Π and ⃗푥푖+1 are sampled as follows:

휆 1. Sample a puncturable PRF 퐹 ← GenPRF(1 ).

79 2. For 푗 = 1, . . . , 푖, define 퐼푗 = OSample(푗; 퐹 (푗)).

′ ⃗ 3. Sample 푞푂푅퐴푀,푖, ⃗푥푖 ← Sim푂푅퐴푀 (푡푖, ⃗푥푖, 퐼1, . . . , 퐼푖). Here after 푖 steps of executing

Π on ⃗푥, ⃗푥푖 is the external memory contents and ⃗푡푖 is the vector of last-written times for each external memory locations.

4. Let 퐼푖+1 denote the (physical) memory addresses accessed by an ORAM on state

푞푂푅퐴푀,푖 for underlying access 푎푖 using random bits 퐹 (푖+1). Here 푎푖 denotes the 푡ℎ 푖+1 address accessed by the underlying Π when executed on ⃗푥. Let 푞푂푅퐴푀,푖+1 ′ and ⃗푥푖+1 denote the resulting ORAM state and external memory configuration.

5. Define Π′ as a RAM program which performs dummy accesses to locations

푡ℎ 퐼1, . . . , 퐼푖+1 and then resumes emulation of Π as usual from the 푖 + 2 step. ′ Π has 푞푂푅퐴푀,푖+1 and 퐹 hard-coded. If Π on ⃗푥 terminates after 푖 + 1 steps and produces an output Π(⃗푥), then Π′ has Π(⃗푥) hard-coded. Otherwise, if Π’s

′ internal state after 푖 + 1 execution steps is given by 푞Π,푖+1, then Π has 푞Π,푖+1

and 푎푖+1 hard-coded, where 푎푖+1 is the address accessed by 푞Π,푖+1.

′ ′ ′ ′ Hybrid 퐻푇 +1. 퐻푇 +1 is WkGarble(Π푇 +1, ⃗푥푇 +1), where Π푇 +1 and ⃗푥푇 +1 are sampled as follows:

휆 1. Sample a PPRF 퐹 ← GenPRF(1 )

′ 2. Define Π푇 +1 to make dummy accesses to 퐼1, . . . , 퐼푇 , where 퐼푗 = OSample(푗; 퐹 (푗)), ′ and then output Π(⃗푥). Π푇 +1 has 퐹 , 푇 , and Π(⃗푥) hard-coded.

′ ′ ′ 3. Define ⃗푥푇 +1 as the length-푁 vector (⊥,..., ⊥), where 푁 is the size of an ORAM-encoded length-푁 memory.

′ Claim 4. 퐻푖 ≈ 퐻푖

′ ′ ′ ′ Proof. Π푖 executed on ⃗푥푖 and Π푖,0 executed on ⃗푥푖+1 have the same state, memory configuration, and functionality after the 푖 + 1푡ℎ underlying step, and they access the same memory locations (succinctly described by OSample and the PRF key 퐾. So

′ the security of WkGarble implies that 퐻푖 ≈ 퐻푖.

80 ′ Claim 5. 퐻푖 ≈ 퐻푖+1.

′ ′ Proof. 퐻푖 and 퐻푖+1 differ only in how 푞푂푅퐴푀,푖+1, 퐼푖+1, and ⃗푥푖+1 are generated: In

퐻푖+1 they are the result of one honest step executed on a simulated 푞푂푅퐴푀,푖, ⃗푥푖, ′ while in 퐻푖 they are just simulated. But because Sim푂푅퐴푀 samples the correct ′ conditional distribution on 푞푂푅퐴푀,푖+1, ⃗푥푖+1 given 퐼1, . . . , 퐼푖+1, these two distributions are the same. This is proved formally in Lemma 5 in Appendix A, which gives us the desired indistinguishability.2

Claim 6. 퐻푇 ≈ 퐻푇 +1

Proof. This is applying the security of WkGarble again, since 퐻푇 and 퐻푇 +1 access the same succinctly described set of locations. Specifically, at time 푖, they access the 푖

푖 푖 (mod 휂)’th address of OSample(⌊ 휂 ⌋; 퐹 (⌊ 휂 ⌋)). 퐻푇 and 퐻푇 +1 also both give the same output (Π(⃗푥)) after 휂푇 execution steps, and for higher timestamps their transition functions are functionally equivalent (they always output ⊥).3

Hybrid 퐻푇 +1 can be sampled given Π(⃗푥), 푇 , |⃗푥|, and |Π|, which allows us to define

Sim as the algorithm which samples 퐻푇 +1. This concludes the proof of Theorem 4.

2 ′ 퐻푖 actually hard-codes 퐼푖+1 while 퐻푖+1 computes 퐼푖+1 as OSample(푖 + 1; 퐹 (푖 + 1)), but this difference is indistinguishable by a standard technique using the puncturability of 퐹 . 3 Here we are simplifying the proof by assuming the execution time is given at garble-time. We * can also achieve an input-specific running time 푇 if we assume a prior polynomial bound 푇푚푎푥 on the worst-case running time. We go through an intermediate hybrid, where we use Theorem 2 to * indistinguishably change the transition function to be ⊥ on all timestamps between 푇 and 푇푚푎푥.

81 82 Bibliography

[ABG+13a] Prabhanjan Ananth, Dan Boneh, Sanjam Garg, Amit Sahai, and Mark Zhandry. Differing-inputs obfuscation and applications. IACR Cryptol- ogy ePrint Archive, 2013:689, 2013.

[ABG+13b] Prabhanjan Ananth, Dan Boneh, Sanjam Garg, Amit Sahai, and Mark Zhandry. Differing-inputs obfuscation and applications. IACR Cryptol- ogy ePrint Archive, 2013:689, 2013.

[AGVW13] Shweta Agrawal, Sergey Gorbunov, Vinod Vaikuntanathan, and Hoeteck Wee. Functional encryption: New perspectives and lower bounds. In Ran Canetti and JuanA. Garay, editors, Advances in Cryptology âĂŞ CRYPTO 2013, volume 8043 of Lecture Notes in Computer Science, pages 500–518. Springer Berlin Heidelberg, 2013.

[AL11] Gilad Asharov and Yehuda Lindell. A full proof of the bgw protocol for perfectly-secure multiparty computation. In Electronic Colloquium on Computational Complexity (ECCC), volume 18, page 36, 2011.

[BCP14] Elette Boyle, Kai-Min Chung, and Rafael Pass. On extractability ob- fuscation. In Theory of Cryptography - 11th Theory of Cryptography Conference, TCC 2014, San Diego, CA, USA, February 24-26, 2014. Proceedings, pages 52–73, 2014.

[BGI+01] Boaz Barak, Oded Goldreich, Russell Impagliazzo, Steven Rudich, Amit Sahai, Salil P. Vadhan, and Ke Yang. On the (im)possibility of obfus- cating programs. In CRYPTO, pages 1–18, 2001.

[BGI14] Elette Boyle, Shafi Goldwasser, and Ioana Ivan. Functional signatures and pseudorandom functions. In PKC, pages 501–519, 2014.

[BGT13] Elette Boyle, Shafi Goldwasser, and Stefano Tessaro. Communication locality in secure multi-party computation. In Amit Sahai, editor, Theory of Cryptography, volume 7785 of Lecture Notes in Computer Science, pages 356–376. Springer Berlin Heidelberg, 2013.

[BGT14] Nir Bitansky, Sanjam Garg, and Sidharth Telang. Succinct randomized encodings and their applications. Cryptology ePrint Archive, Report 2014/771, 2014. http://eprint.iacr.org/.

83 [BGV12] Zvika Brakerski, Craig Gentry, and Vinod Vaikuntanathan. (leveled) fully homomorphic encryption without bootstrapping. In Proceedings of the 3rd Innovations in Theoretical Computer Science Conference, ITCS ’12, pages 309–325, New York, NY, USA, 2012. ACM.

[BOGW88] Michael Ben-Or, Shafi Goldwasser, and Avi Wigderson. Completeness theorems for non-cryptographic fault-tolerant distributed computation. In Proceedings of the twentieth annual ACM symposium on Theory of computing, pages 1–10. ACM, 1988.

[BPR14] Nir Bitansky, Omer Paneth, and Alon Rosen. On the cryptographic hard- ness of finding a nash equilibrium. Cryptology ePrint Archive, Report 2014/1029, 2014. http://eprint.iacr.org/.

[BV11] Zvika Brakerski and Vinod Vaikuntanathan. Efficient fully homomorphic encryption from (standard) lwe. In Proceedings of the 2011 IEEE 52Nd Annual Symposium on Foundations of Computer Science, FOCS ’11, pages 97–106, Washington, DC, USA, 2011. IEEE Computer Society.

[BW13] Dan Boneh and . Constrained pseudorandom functions and their applications. In ASIACRYPT, pages 280–300, 2013.

[CGP14] Ran Canetti, Shafi Goldwasser, and Oxana Poburinnaya. Adaptively se- cure two-party computation from indistinguishability obfuscation. Cryp- tology ePrint Archive, Report 2014/845, 2014. http://eprint.iacr. org/.

[CHJV14] Ran Canetti, Justin Holmgren, Abhishek Jain, and Vinod Vaikun- tanathan. Indistinguishability obfuscation of iterated circuits and ram programs. Cryptology ePrint Archive, Report 2014/769, 2014. http: //eprint.iacr.org/.

[CP13] Kai-Min Chung and Rafael Pass. A simple ORAM. IACR Cryptology ePrint Archive, 2013:243, 2013.

[Gen09] Craig Gentry. A fully homomorphic encryption scheme. PhD thesis, Stanford University, 2009.

[GGG+14] Shafi Goldwasser, S.Dov Gordon, Vipul Goyal, Abhishek Jain, Jonathan Katz, Feng-Hao Liu, Amit Sahai, Elaine Shi, and Hong-Sheng Zhou. Multi-input functional encryption. In PhongQ. Nguyen and Elisabeth Oswald, editors, Advances in Cryptology âĂŞ EUROCRYPT 2014, vol- ume 8441 of Lecture Notes in Computer Science, pages 578–602. Springer Berlin Heidelberg, 2014.

[GGH+13a] Sanjam Garg, Craig Gentry, Shai Halevi, Mariana Raykova, Amit Sa- hai, and Brent Waters. Candidate indistinguishability and functional encryption for all circuits. In FOCS, pages 40–49, 2013.

84 [GGH+13b] Sanjam Garg, Craig Gentry, Shai Halevi, Amit Sahai, and Brent Wa- ters. Attribute-based encryption for circuits from multilinear maps. In Advances in Cryptology - CRYPTO 2013, volume 8043 of Lecture Notes in Computer Science, pages 479–499. Springer Berlin Heidelberg, 2013. [GGM86] Oded Goldreich, Shafi Goldwasser, and Silvio Micali. How to construct random functions. J. ACM, 33(4):792–807, 1986. [GHL+14] Craig Gentry, Shai Halevi, Steve Lu, Rafail Ostrovsky, Mariana Raykova, and Daniel Wichs. Garbled RAM revisited. In EUROCRYPT, pages 405–422, 2014. [GHRW14] Craig Gentry, Shai Halevi, Mariana Raykova, and Daniel Wichs. Out- sourcing private ram computation. In FOCS, 2014. [GL89] Oded Goldreich and Leonid A Levin. A hard-core predicate for all one- way functions. In Proceedings of the twenty-first annual ACM symposium on Theory of computing, pages 25–32. ACM, 1989. [GLOS14] Sanjam Garg, Steve Lu, Rafail Ostrovsky, and Alessandra Scafuro. Gar- bled ram from one-way functions. Cryptology ePrint Archive, Report 2014/941, 2014. http://eprint.iacr.org/. [GMW87] Oded Goldreich, Silvio Micali, and Avi Wigderson. How to play any mental game. In Proceedings of the nineteenth annual ACM symposium on Theory of computing, pages 218–229. ACM, 1987. [GPSW06] Vipul Goyal, Omkant Pandey, Amit Sahai, and Brent Waters. Attribute- based encryption for fine-grained access control of encrypted data. In Proceedings of the 13th ACM Conference on Computer and Communica- tions Security, CCS ’06, pages 89–98, New York, NY, USA, 2006. ACM. [GVW13] Sergey Gorbunov, Vinod Vaikuntanathan, and Hoeteck Wee. Attribute- based encryption for circuits. In Proceedings of the Forty-fifth Annual ACM Symposium on Theory of Computing, STOC ’13, pages 545–554, New York, NY, USA, 2013. ACM. [KLW14] Venkata Koppula, Allison Bishop Lewko, and Brent Waters. Indistin- guishability obfuscation for turing machines with unbounded memory. Cryptology ePrint Archive, Report 2014/925, 2014. http://eprint. iacr.org/. [KPTZ13] Aggelos Kiayias, Stavros Papadopoulos, Nikos Triandopoulos, and Thomas Zacharias. Delegatable pseudorandom functions and applica- tions. In ACM CCS, pages 669–684, 2013. [LP14] Huijia Lin and Rafael Pass. Succinct garbling schemes and applications. Cryptology ePrint Archive, Report 2014/766, 2014. http://eprint. iacr.org/.

85 [SCSL11] Elaine Shi, T.-H. Hubert Chan, Emil Stefanov, and Mingfei Li. Oblivious RAM with o((logn)3) worst-case cost. In ASIACRYPT, pages 197–214, 2011.

[SS10] Amit Sahai and Hakan Seyalioglu. Worry-free encryption: Functional encryption with public keys. In Proceedings of the 17th ACM Conference on Computer and Communications Security, CCS ’10, pages 463–472, New York, NY, USA, 2010. ACM.

[SW05] Amit Sahai and Brent Waters. Fuzzy identity-based encryption. In Ronald Cramer, editor, Advances in Cryptology âĂŞ EUROCRYPT 2005, volume 3494 of Lecture Notes in Computer Science, pages 457– 473. Springer Berlin Heidelberg, 2005.

[SW14] Amit Sahai and Brent Waters. How to use indistinguishability obfusca- tion: deniable encryption, and more. In STOC, pages 475–484, 2014.

[vDGHV09] Marten van Dijk, Craig Gentry, Shai Halevi, and Vinod Vaikuntanathan. Fully homomorphic encryption over the integers. Cryptology ePrint Archive, Report 2009/616, 2009. http://eprint.iacr.org/.

[Wat12] Brent Waters. Functional encryption for regular languages. Cryptology ePrint Archive, Report 2012/384, 2012. http://eprint.iacr.org/.

[Wat14] Brent Waters. A punctured programming approach to adaptively se- cure functional encryption. Cryptology ePrint Archive, Report 2014/588, 2014. http://eprint.iacr.org/.

[Yao82] Andrew C Yao. Protocols for secure computations. In 2013 IEEE 54th Annual Symposium on Foundations of Computer Science, pages 160–164. IEEE, 1982.

86 Appendix A

Oblivious RAM

We describe the oblivious RAM of Chung and Pass [CP13], which is a simplification of [SCSL11], and we highlight the security property needed for our garbled RAM construction.

A.1 Construction

Starting with a RAM machine Π that uses 푁 memory words, the construction trans- forms it into a machine Π′ that uses 푁 ′ = 푁 · poly(log 푁, 휆) memory words. While the eventual goal is to store 푂(1) words in the local state of Π′, Chung and Pass start with a “basic” construction in which the local state of Π′ consists of a “position map” pos :[푁/훼] → [푁/훼] for some constant 훼 > 1. The 푁 underlying memory locations are divided into 푁/훼 “blocks” each storing 훼 underlying memory words. The external memory is organized as a complete binary tree of 푁/훼 leaves. The semantics of the position map is that the 푖-th block of memory maps to the leaf labeled pos(푖). Let 푑 = log(푁/훼). The CP/SCSL invariant is that:

“Block 푖 is stored in some node on the path from the root to the leaf labeled with pos(푖).”

Each internal node of the tree stores a few memory blocks. In particular, each internal node, labeled by a string 훾 ∈ {0, 1}≤푑 is associated with a “bucket” of 훽

87 blocks for some 훽 = polylog(푁). The reads and writes to a location 푟 ∈ [푁] in the CP/SCSL ORAM proceed as follows:

∙ Fetch: Let 푏 = ⌊푟/훼⌋ be the block containing the memory location 푟, and let 푖 = 푟 mod 훼 be the component within block 푏 containing the location 푟. We first look up the leaf corresponding to block 푏 using the (locally stored) position map. Let 푝 = Pos(푏).

Next, we traverse the tree from the roof to the leaf 푝, reading and writing the bucket associated to each internal node exactly once. In particular, we read the content once, and then we either write it back, or we erase a block once it is found, and write back the rest of the blocks.

∙ Update Position Map: Pick a uniformly random leaf 푝′ ← [푁/훼] and set (in the local memory) Pos(푏) = 푝′.

∙ Write Back: In the case of a READ, add the tuple (푏, 푝′, 푣) to the root of the tree. In the case of a WRITE, add the tuple (푏, 푝′, 푣′) where 푣′ is the new value to be written. If there is not enough space in the bucket associated with the root, output overflow and abort. (We note that [CP13, SCSL11] show that, setting the parameters appropriately, the probability that the overflow event happens is negligible).

∙ Flush the Block: Pick a uniformly random leaf 푝* ← [푁/훼] and traverse the tree from the roof to the leaf 푝* making exactly one read and one write operation for every memory cell associated with the nodes along the path so as to implement the following task: “push down” each tuple (˜푏, 푝,˜ 푣˜) read in the nodes traversed as far as possible along the path to 푝* while ensuring that the tuple is still on the path to its associated leaf 푝˜ (i.e., maintaining the CP/SCSL invariant). In other words, the tuple ends up in the node 훾 = the longest common prefix of

* 푝 and 푝̃︀. If at any point some bucket is about to overflow, abort outputting overflow.

88 The following observation is central to the correctness and security of the CP/SCSL ORAM:

Observation 1. Each oblivious READ and WRITE operation traverses the the tree along two randomly chosen paths, independent of the history of operations so far.

This key observation follows from the facts that (1) Each position in the position map is used exactly once in a traversal (and before this traversal, this position is not used in determining what nodes to traverse), and (2) the flushing, by definition, traverses a random path, independent of the history.

A.2 Security Property

Suppose an underlying access pattern is given; we will consider the randomized pro- cedure of executing this sequence of accesses via this ORAM. We want a randomized “dummy” access algorithm OSample which on input 푗 outputs a list of locations. This list should be distributed according to the real distribution of accesses corresponding to the 푗푡ℎ underlying access. We can now describe our desired security property. Fix some underlying access pattern 푎1, . . . , 푎푡, including both the addresses and values written, and fix an initial memory configurtaion ⃗푥. Let 푄푠 be a random variable for the entire ORAM state (both private registers and memory configuration) after the 푠푡ℎ underlying access,

푡ℎ and let 퐼푗 be a random variable for the addresses accessed by the ORAM on the 푗 underlying access.

Lemma 5. There exists a PPT algorithms Sim such that for any 푠, and any possible

(non-zero probability) values 푖1, . . . , 푖푠−1 of 퐼1, . . . , 퐼푠−1, for all PPT adversaries 풜,

⎡ ⃒ ⎤ ⃒ 0 0 0 푏 푏 ⃒ 푞푠−1 ← Sim(푖1, . . . , 푖푠−1), 푞푠 , 푖푠 ← OAccess(푎푠; 푞푠−1) 1 Pr ⎣풜(푞푠, 푖푠) = 푏⃒ ⎦ ≤ +negl(휆) ⃒ 1 1 2 ⃒ 푖푠 ← OSample(푠), 푞푠 ← Sim(푖1, . . . , 푖푠)

This is a consequence of the following two claims.

Claim 7. 퐼푠 is independent of 퐼1, . . . , 퐼푠−1 and 푎1, . . . , 푎푠, and is efficiently sampleable.

89 Proof. This follows immediately from Observation 1.

This lets us define OSample(푠) as the efficient algorithm which samples 퐼푠. Specif- ically, in the CP/SCSL ORAM, OSample samples and outputs two uniformly random paths in each tree.

Claim 8. The conditional distribution 푄푠|퐼1, . . . , 퐼푠 is efficiently sampleable for all values of 퐼1, . . . , 퐼푠 (that jointly occur with non-zero probability).

˜ Proof. Recall that 푄푠 has two parts: a position map Pos and memory contents 퐷푠, which are structured as a tree. We first give the sampling procedure for the basic construction, and then extend it to the recursive case. It is easy to verify that this procedure produces the correct distribution.

To sample 푄푠 given a sequence of memory accesses (푖1, . . . , 푖푠), do the following.

For every memory block 푏 ∈ [푁/훼], let 휏푏 ≤ 푠 be the last time when block 푏 was read flsh accessed. Let 퐼푗 = (퐼푗 , 퐼푗 ) be the pair of paths that comprise each 퐼푗.

∙ For each block 푏, pick a uniformly random leaf 푝푏 ← ⌊푁/훼⌋. Compute the

unique internal node 훾푏 such that 훾푏 is the largest common prefix between 푝푏 and any of 퐼flsh, . . . , 퐼flsh. 휏푏 푠

∙ Construct Pos by letting Pos(푏) = 푝푏.

˜ ∙ Construct 퐷푠 by writing each memory block 푏 together with its value at time 푠

to the internal node 훾푏.

To sample 푄푠 for the recursive construction, we note that this basic sampler doesn’t need to ⃗푥 and the entire access pattern; it only needs to know each 휏푏 described ′ ′ above, as well as the memory contents at time 푠. This information ({휏푏′ }, ⃗푥푠) for ′ the next smaller recursive case is readily computable. ⃗푥푠 for the next level ORAM ′ is just Pos, which we have already computed. 휏푏′ is the maximum of 휏푏 over all 푏 corresponding to 푏′. So we can run the basic sampler repeatedly until we have sampled 푄푠 for the whole recursive construction.

90 This allows us to define Sim as the above procedure for efficiently sampling 푄푠 conditioned on 퐼1 = 푖1, . . . , 퐼푠 = 푖푠. We can now prove a stronger (statistical) version of Lemma 5, knowing that Sim and OSample output the correct conditional distributions.

0 0 1 1 Claim 9. Pr[푞푠 , 푖푠 = 푞푠, 푖푠] ≈ Pr[푞푠 , 푖푠 = 푞푠, 푖푠].

Proof.

0 0 Pr[푞푠 , 푖푠 = 푞푠, 푖푠] ≈ IE푞푠−1 [Pr[푞푠, 푖푠|푞푠−1, 푖1, . . . , 푖푠−1]|푖1, . . . , 푖푠−1]

= Pr[푞푠, 푖푠|푖1, . . . , 푖푠−1]

= Pr[푞푠|푖1, . . . , 푖푠] Pr[푖푠|푖1, . . . , 푖푠−1]

= Pr[푞푠|푖1, . . . , 푖푠] Pr[푖푠]

1 1 ≈ Pr[푞푠 , 푖푠 = 푞푠, 푖푠].

1. The first approximate equality follows from Sim approximately sampling 푞푠−1

given 푖1, . . . , 푖푠−1 and from OAccess (exactly) sampling 푞푠, 푖푠 given 푞푠−1.

2. The second equality is just marginalization over 푞푠−1.

3. The third equality is the chain rule for probabilities.

4. The fourth equality is Claim 7 - namely that the locations accessed at time 푠 are independent of previously accessed locations.

5. The fifth approximate equality follows from OSample approximately sampling

푖푠.

91