homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in...

50
Homomorphic encryption for deep learning: a revolution in the making Pascal Paillier

Upload: others

Post on 12-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Homomorphic encryption for deep learning: a revolution in the makingPascal Paillier

Page 2: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

Page 3: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

A booming industry.

Page 4: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

GPU

GPU

GPU

data

prediction

Trained neural network

Cloud Inc.

Page 5: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

GPU

GPU

GPU

sensitive data

prediction

Cloud Inc.

Page 6: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

GPU

GPU

GPU

sensitive data

sensitive prediction

Cloud Inc.

Page 7: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

GPU

GPU

GPU

sensitive data

sensitive prediction

STDs, HIV

Health data

GenomicsBlood work

Lifestyle trackingCloud Inc.

Page 8: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

GPU

GPU

GPU

sensitive data

sensitive prediction

Fraud prevention

Financial data

Bank activityTransaction

records

InvestmentsCloud Inc.

Page 9: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The problem

GPU

GPU

GPU

sensitive data

sensitive prediction

Crime prevention

Gov dataPolice/Justice case solving

Tax evasion

Cloud Inc.

Page 10: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Homomorphic encryptionfor neural networks

Page 11: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The big motivation for applying FHE

GPU

GPU

GPU

sensitive data

sensitive prediction

Enc(

Enc(

)

)

Input and output data are encrypted

The model is evaluated in the encrypted domain = homomorphic inference

Only the user has the key to encrypt

and decrypt

Cloud Inc.

Page 12: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

First generation FHE

x, y ∈ {0,1}Enc(x), Enc(y) → Enc(x ⊕ y)

Enc(x), Enc(y) → Enc(x ∧ y)

pretty fast

super slow

⊕ + ∧ = all functions

[Gentry09]

Page 13: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

First generation FHE

x, y ∈ {0,1}Enc(x), Enc(y) → Enc(x ⊕ y)

Enc(x), Enc(y) → Enc(x ∧ y)

pretty fast

super slow

⊕ + ∧ = all functions

Enc(x), Enc(y) → Enc(x ⊕ y)

Enc(x), Enc(y) → Enc(x ∧ y)

noise ~the same

noise doubled

But there is a notion of noise in ciphertexts

If the noise exceeds a threshold, the ciphertext looses decryptability

One must resort to bootstrapping, a very slow noise-cleaning operation

[Gentry09]

Page 14: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The importance of multiplicative depth

computation as a

boolean circuit

inputs

outputs

Page 15: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The importance of multiplicative depth

computation as a

boolean circuit

noise growth is

exponential

inputs

outputs

Page 16: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Somewhat HE and scale-invariant HE

FHE SHE

+bootstrap

+bootstrap

++noise

growth

✔ can go on forever

✘ works up to circuit

outputs

FHE = SHE + bootstrapping

Page 17: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Quick refresher on neural networks

Page 18: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Neural network = cognitive model

Page 19: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Artificial neurons

y =n

∑i=1

wixi + b z = f(y)

activation function

Page 20: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Dense layers (fully connected)

layer L layer L+1yL+1 = WL+1xL + bL+1

xL+1 = f (yL+1)

learnableweight matrix

learnablebias

vector

✔ learnable

Page 21: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Convolutional layers

0 1 1 1 1 0 0 1 1 0 0 0

0 1 2 2 1 1 1 2 2 2 1 0

1 0 0 3 3 1 1 1 1 0 0 0

1 0 2 3 2 3 3 3 1 2 0 0

1 1 3 7 4 5 5 5 5 2 3 1

0 1 1 8 7 6 7 5 6 3 2 0

0 1 0 5 9 5 6 6 3 4 2 0

0 2 2 7 8 9 9 9 4 4 1 0

0 1 3 4 7 7 8 6 3 0 0 0

1 0 3 2 3 5 4 3 4 2 1 0

1 1 2 1 1 5 3 2 2 3 2 1

0 0 0 0 0 2 0 1 1 0 2 0

0 1 1 1 1 0 0 1 1

0 1 2 2 1 1 1 2 2

1 0 0 3 3 1 1 1 1

1 0 2 3 2 3 3 3 1

1 1 3 7 4 5 5 5 5

0 1 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4 7 7 8 6 3

1 0 3 2 3 5 4 3 4

0 1 1 1 1 0 0 1 1

0 1 2 2 1 1 1 2 2

1 0 0 3 3 1 1 1 1

1 0 2 3 2 3 3 3 1

1 1 3 7 4 5 5 5 5

0 1 1 8 7 6 7 5 6

0 1 0 5 9 5 6 6 3

0 2 2 7 8 9 9 9 4

0 1 3 4 7 7 8 6 3

1 0 3 2 3 5 4 3 4

0 1 1 1 1 0 0 1 1

0 1 2 2 1 1 1 2 2

1 0 0 3 3 1 1 1 1

1 0 2 3 2 3 3 3 1

1 1 3 7 4 5 5 5 5

0 1 1 8 7 6 7 5 6

0 1 0 5 9 5 6 6 3

0 2 2 7 8 9 9 9 4

0 1 3 4 7 7 8 6 3

1 0 3 2 3 5 4 3 4

-3 0 2 8

2 -1 -1 4

5 5 3 -6

learnable multiple kernels

kernel

tensorinput 2D image

✔ learnable

Page 22: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Average and max pooling

0 1 1 1 1 0 0 1 1 0 0 0

0 1 2 2 1 1 1 2 2 2 1 0

1 0 0 3 3 1 1 1 1 0 0 0

1 0 2 3 2 3 3 3 1 2 0 0

1 1 3 7 4 5 5 5 5 2 3 1

0 1 1 8 7 6 7 5 6 3 2 0

0 1 0 5 9 5 6 6 3 4 2 0

0 2 2 7 8 9 9 9 4 4 1 0

0 1 3 4 7 7 8 6 3 0 0 0

1 0 3 2 3 5 4 3 4 2 1 0

1 1 2 1 1 5 3 2 2 3 2 1

0 0 0 0 0 2 0 1 1 0 2 0

3 3 1

0 1 2

1 0 0

1 0 2

4x3 max pool

Flatteninglossless

dimension reduction

✘not learnable

Page 23: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Layer-wide operations

✘not learnable

layer L layer L+1

xL+1i =

exLi

∑j exLj

softmax

xL+1 =xL

∥xL∥

L2 regularization

xL+1 =xL

|xL |L1 regularization

Page 24: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

Page 25: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

linear

Page 26: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

Page 27: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

Page 28: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

Page 29: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

Page 30: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

ℝ → ℤp

Page 31: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

So, how to evaluate a neural network?

Σ f

Σ f

Σ f

Σ fΣ f

ℝ → ℤp?

Page 32: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

CryptoNets

y =n

∑i=1

wixi + b z = f(y)

activation function = square

[DGBL+16]

Page 33: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

noise growth is

linear

noise growth

Just take

L = ♯ 𝗅𝖺𝗒𝖾𝗋𝗌 + 1

CryptoNets: just use some leveled SHE

Page 34: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

The CryptoNets approach - pros/consPros

Simple, can reuse libraries for leveled HE

Small accuracy loss compared to state-of-the-art nets

If the leveled HE scheme allows batch plaintexts then one can parallelize homomorphic inference

Cons

Super slow dude! (demo MNIST ~5mn)

Parameters increase too fast to cope with truly deep networks

Does not support state-of-the-art neural nets

How do you perform softmax or regularizations?

34

Page 35: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

4-th generation FHE: Torus FHE (TFHE)

Torus FHE is a simplification and generalisation of 1st, 2nd and 3rd generation FHE based on [R]LWE

In its basic form:

Symmetric FHE

Plaintexts are bits

Supports all binary gates + negation + Mux

Every binary operation is bootstrapped

Bootstrapping is fast - a few tens of milliseconds

Security arises from the hardness of lattice reduction

Supports any security strength, e.g. 80, 128, 192, 256 bits

μ

0 = 112

gaussian noise

E ⃗s(μ) = ( ⃗a , ⃗a ⋅ ⃗s + μ + ϵ)

≈c ( ⃗a , u)

[CGGI16], [CGGI17]

Page 36: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Our approach

• Early results published in

Florian Bourse, Michele Minelli, Matthias Minihold and Pascal Paillier ”Fast homomorphic evaluation of deep discretized neural networks”

In CRYPTO 2018

• There have been a number of subsequent improvements following that paper

1. Extension from binary activations to real-valued activations

2. New bootstrapping procedure - also programmable

[BMMP18]

Page 37: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Our approach towards bootstrapping

σ2variance

∥ ⃗w∥2σ2

back to variance

E(μ′�)E (∑i

wiμi mod 1) TFHE bootstrap

Page 38: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Our approach towards bootstrapping

σ2variance

∥ ⃗w∥2σ2

back to variance

E (f(μ′�))E (∑i

wiμi mod 1) our bootstrap

f( ⋅ )

any real-valued univariate function can be programmed

Page 39: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

A neuron-specific FHE

• Our scheme is specifically crafted to encrypt activations in neurons

• Designed to support only 2 operations:

• Multi-sum (scalar product with integer weight vector)

• Fast bootstrapping (a few ms)

• Encrypted activations are real values in intervals, not just bits

• Any activation function can be applied for free when bootstrapping

Page 40: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

How to support all network operations

Generic neuron with parameters

Pick and set

Perform multi-addition with

Program the bootstrapping with the function

Max-pooling becomes super-easy: just reapply Max at will

Max: given

Bootstrap with function

Add

Bootstrap again with identity

w1, …, wn, b, f( ⋅ ) ∈ ℝ

a ∈ ℝ w̄i ≈ ⌈awi⌋w̄1, …, w̄n ∈ ℤ

f ( ⋅a

+ b)

E(μ1), E(μ2)

E(μ1 − μ2) max(0, ⋅)

E(μ2)

Page 41: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Summarized results

• Readily applies to

• Exact activation function: ReLU, Sigmoid, Tanh, etc ✔

• Deep networks, any number of layers ✔

• Convolutional NN, flattening, dropout ✔

• Recurrent NN ✔

• + extensions that support

• Max pooling, average pooling is trivial ✔

• Regularizations (L1, L2, elastic) ✔

• Softmax ✔

All ingredient operations that are performed

in neural networks are being covered

Page 42: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Technological advantages

CryptoNets and the like Our work

Uses levelled SHE (BGV, FV) not FHE True FHE, fully scalable

Each neuron much slower for deeper networks

Speed at neuron level independent of # layers

Polynomial approximation of activation functions Exact activation functions

Models must be trained specifically Can convert pre-trained models

Modular arithmetics Uses floats

Huge latency High throughput

game changers

Page 43: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Benchmark experiments

43

[BMMP18]

Page 44: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Benchmark experiments

44

[BMMP18]

Page 45: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Benchmark experiments

45

[BMMP18]

Page 46: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Introducing a new, game-changing business offer

Page 47: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

GPU

GPU

GPU

sensitive data

sensitive prediction

Enc(

Enc(

)

)

GPU

GPU

GPU

sensitive data

sensitive prediction

to protected inference

Cloud Inc.

Enable Cloud Inc. to switch from unprotected inference

Cloud Inc.

Unsafe MLaaS

Safe MLaaS

Page 48: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Cloud Inc.

Input Output

Pre-trained model in Tensorflow format

(under NDA)

GPU-based inference engine for hard-coded model

GPUGPU GPU

PTXCode

Key generation

Encrypt

Decrypt

+

Automated conversion

Takes user-encrypted inputs

Returns user-encrypted results

User utilities

Cloud Inc.

Page 49: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

ConclusionOur work constitutes a breakthrough in several ways over CryptoNets and the like

Supports all neural network operations

Supports pre-trained neural networks

Blazingly fast

Highly parallelizable

Some challenges remain

Boost performances - switch to GPUs

Avoid going back and forth from and to the FFT domain - can we stay in the FFT domain (almost) all the time?

Perform training over encrypted data

Page 50: Homomorphic encryption for deep learning: a revolution in the … · deep learning: a revolution in the making Pascal Paillier. The problem. A booming industry. The problem GPU GPU

Questions?

[email protected]