fast homomorphic evaluation of deep discretized neural ... · fast homomorphic evaluation of deep...

83
Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal Paillier ENS, CNRS, PSL Research University, INRIA (Work done while visiting CryptoExperts) CRYPTO 2018 – UCSB, Santa Barbara

Upload: others

Post on 03-Jun-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Fast Homomorphic Evaluation ofDeep Discretized Neural Networks

Florian Bourse Michele Minelli Matthias Minihold Pascal Paillier

ENS, CNRS, PSL Research University, INRIA(Work done while visiting CryptoExperts)

CRYPTO 2018 – UCSB, Santa Barbara

Page 2: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 3: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 4: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 5: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 6: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 7: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 8: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 9: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 10: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Machine Learning as a Service (MLaaS)

x

M (x)

Alice’sprivacy!

Enc (x)

Enc (M (x))

Possible solution: FHE.

3 Privacy data is encrypted (both input and output)7 Efficiency main issue with FHE-based solutions

Goal of this work: homomorphic evaluation of trained networks.

Michele Minelli2 / 16

Page 11: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

(Very quick) refresher on neural networks

...

Outputlayer

...

Inputlayer

...

Hiddenlayers

d

. . . ...

Michele Minelli3 / 16

Page 12: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

(Very quick) refresher on neural networks

Computation for every neuron:

x1

x2

......

w1

w2y

Σxi ,wi , y ∈ R

y = f(∑

iwi xi

),

where f is an activation function.

Michele Minelli3 / 16

Page 13: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

(Very quick) refresher on neural networks

Computation for every neuron:

x1

x2

......

w1

w2y

Σxi ,wi , y ∈ R

y = f(∑

iwi xi

),

where f is an activation function.

Michele Minelli3 / 16

Page 14: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A specific use case

We consider the problem of digit recognition.

7

Dataset: MNIST (60 000 training img + 10 000 test img).

Michele Minelli4 / 16

Page 15: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A specific use case

We consider the problem of digit recognition.

7

Dataset: MNIST (60 000 training img + 10 000 test img).

Michele Minelli4 / 16

Page 16: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A specific use case

We consider the problem of digit recognition.

7

Dataset: MNIST (60 000 training img + 10 000 test img).

Michele Minelli4 / 16

Page 17: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A specific use case

We consider the problem of digit recognition.

7

Dataset: MNIST (60 000 training img + 10 000 test img).

Michele Minelli4 / 16

Page 18: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]

3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 19: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 20: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 21: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 22: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 23: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 24: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

State of the art

Cryptonets [DGBL+16]3 Achieves blind, non-interactive classification

3 Near state-of-the-art accuracy (98.95%)

7 Replaces sigmoidal activ. functions with low-degree f (x) = x2

7 Uses SHE =⇒ parameters have to be chosen at setup time

Main limitationThe computation at neuron level depends on the total multiplicative depth of the network=⇒ bad for deep networks!

Goal: make the computation scale-invariant =⇒ bootstrapping.

Michele Minelli5 / 16

Page 25: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A restriction on the model

We want to homomorphically compute the multisum∑i

wixi

Given w1, . . . ,wp and Enc (x1) , . . . ,Enc (xp), do∑i

wi · Enc (xi)

Proceed with cautionIn order to maintain correctness, we need wi ∈ Z

=⇒ trade-off efficiency vs. accuracy!

Michele Minelli6 / 16

Page 26: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A restriction on the model

We want to homomorphically compute the multisum∑i

wixi

Given w1, . . . ,wp and Enc (x1) , . . . ,Enc (xp), do∑i

wi · Enc (xi)

Proceed with cautionIn order to maintain correctness, we need wi ∈ Z

=⇒ trade-off efficiency vs. accuracy!

Michele Minelli6 / 16

Page 27: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A restriction on the model

We want to homomorphically compute the multisum∑i

wixi

Given w1, . . . ,wp and Enc (x1) , . . . ,Enc (xp), do∑i

wi · Enc (xi)

Proceed with cautionIn order to maintain correctness, we need wi ∈ Z

=⇒ trade-off efficiency vs. accuracy!

Michele Minelli6 / 16

Page 28: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

A restriction on the model

We want to homomorphically compute the multisum∑i

wixi

Given w1, . . . ,wp and Enc (x1) , . . . ,Enc (xp), do∑i

wi · Enc (xi)

Proceed with cautionIn order to maintain correctness, we need wi ∈ Z =⇒ trade-off efficiency vs. accuracy!

Michele Minelli6 / 16

Page 29: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Discretized neural networks (DiNNs)

Goal: FHE-friendly model of neural network.

DefinitionA DiNN is a neural network whose inputs are integer values in {−I, . . . , I }, and whose weightsare integer values in {−W , . . . ,W }, for some I,W ∈ N.For every activated neuron of the network, the activation function maps the multisum tointeger values in {−I, . . . , I }.

Not as restrictive as it seems: e.g., binarized NNs;

Trade-off between size and performance;

(A basic) conversion is extremely easy.

Michele Minelli7 / 16

Page 30: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Discretized neural networks (DiNNs)

Goal: FHE-friendly model of neural network.

DefinitionA DiNN is a neural network whose inputs are integer values in {−I, . . . , I }, and whose weightsare integer values in {−W , . . . ,W }, for some I,W ∈ N.For every activated neuron of the network, the activation function maps the multisum tointeger values in {−I, . . . , I }.

Not as restrictive as it seems: e.g., binarized NNs;

Trade-off between size and performance;

(A basic) conversion is extremely easy.

Michele Minelli7 / 16

Page 31: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Discretized neural networks (DiNNs)

Goal: FHE-friendly model of neural network.

DefinitionA DiNN is a neural network whose inputs are integer values in {−I, . . . , I }, and whose weightsare integer values in {−W , . . . ,W }, for some I,W ∈ N.For every activated neuron of the network, the activation function maps the multisum tointeger values in {−I, . . . , I }.

Not as restrictive as it seems: e.g., binarized NNs;

Trade-off between size and performance;

(A basic) conversion is extremely easy.

Michele Minelli7 / 16

Page 32: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Discretized neural networks (DiNNs)

Goal: FHE-friendly model of neural network.

DefinitionA DiNN is a neural network whose inputs are integer values in {−I, . . . , I }, and whose weightsare integer values in {−W , . . . ,W }, for some I,W ∈ N.For every activated neuron of the network, the activation function maps the multisum tointeger values in {−I, . . . , I }.

Not as restrictive as it seems: e.g., binarized NNs;

Trade-off between size and performance;

(A basic) conversion is extremely easy.

Michele Minelli7 / 16

Page 33: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Discretized neural networks (DiNNs)

Goal: FHE-friendly model of neural network.

DefinitionA DiNN is a neural network whose inputs are integer values in {−I, . . . , I }, and whose weightsare integer values in {−W , . . . ,W }, for some I,W ∈ N.For every activated neuron of the network, the activation function maps the multisum tointeger values in {−I, . . . , I }.

Not as restrictive as it seems: e.g., binarized NNs;

Trade-off between size and performance;

(A basic) conversion is extremely easy.

Michele Minelli7 / 16

Page 34: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

∑i

wi · Enc (xi) = Enc(∑

iwixi

)

Issues:

Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 35: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

Enc(

f(∑

iwixi

))

Issues:

Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 36: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

Enc∗(

f(∑

iwixi

))

Issues:

Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 37: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

Enc∗(

f(∑

iwixi

))

Issues:

Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 38: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

Issues:Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 39: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

Issues:Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 40: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Homomorphic evaluation of a DiNN1 Evaluate the multisum: easy – just need a linearly hom. scheme

2 Apply the activation function: depends on the function

3 Bootstrap: can be costly

4 Repeat for all the layers

Issues:Choose the message space: guess, statistics, or worst-case

The noise grows: need to start from a very small noise

How do we apply the activation function homomorphically?

Michele Minelli8 / 16

Page 41: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Basic idea: activate during bootstrapping

Combine bootstrapping & activation function:

Enc (x)→ Enc∗ (f (x))

Michele Minelli9 / 16

Page 42: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Basic idea: activate during bootstrapping

Enc (x1)

Enc (x2)

......

w1

w2Enc∗ (y)

Σ

y = f(∑

iwixi

)

Two steps:

1 Compute the multisum∑

i wixi

2 Bootstrap to the activated value

Michele Minelli9 / 16

Page 43: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Basic idea: activate during bootstrapping

Enc (x1)

Enc (x2)

......

w1

w2Enc∗ (y)

Σ

y = f(∑

iwixi

)Two steps:

1 Compute the multisum∑

i wixi

2 Bootstrap to the activated value

Michele Minelli9 / 16

Page 44: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Basic idea: activate during bootstrapping

Enc (x1)

Enc (x2)

......

w1

w2Enc∗ (y)

Σ

y = f(∑

iwixi

)Two steps:

1 Compute the multisum∑

i wixi

2 Bootstrap to the activated valueMichele Minelli

9 / 16

Page 45: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

TFHE: a framework for faster bootstrapping [CGGI16,CGGI17]

T := R/ZBasic assumption: learning with errors (LWE) over the torus

(a, b = ⟨s,a⟩+ e mod 1)c≈ (a, u) , e ← χα, s←$ {0, 1}n, a,u←$Tn.

Scheme Message CiphertextLWE scalar (n + 1) scalars

TLWE polynomial (k + 1) polynomials

Overview of the bootstrapping procedure:

1 Hom. compute Xb−⟨s,a⟩: spin the wheel2 Pick the ciphertext pointed to by the arrow3 Switch back to the original key

Michele Minelli10 / 16

Page 46: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

TFHE: a framework for faster bootstrapping [CGGI16,CGGI17]

T := R/ZBasic assumption: learning with errors (LWE) over the torus

(a, b = ⟨s,a⟩+ e mod 1)c≈ (a, u) , e ← χα, s←$ {0, 1}n, a,u←$Tn.

Scheme Message CiphertextLWE scalar (n + 1) scalars

TLWE polynomial (k + 1) polynomials

Overview of the bootstrapping procedure:

1 Hom. compute Xb−⟨s,a⟩: spin the wheel2 Pick the ciphertext pointed to by the arrow3 Switch back to the original key

Michele Minelli10 / 16

Page 47: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

TFHE: a framework for faster bootstrapping [CGGI16,CGGI17]

T := R/ZBasic assumption: learning with errors (LWE) over the torus

(a, b = ⟨s,a⟩+ e mod 1)c≈ (a, u) , e ← χα, s←$ {0, 1}n, a,u←$Tn.

Scheme Message CiphertextLWE scalar (n + 1) scalars

TLWE polynomial (k + 1) polynomials

Overview of the bootstrapping procedure:

1 Hom. compute Xb−⟨s,a⟩: spin the wheel2 Pick the ciphertext pointed to by the arrow3 Switch back to the original key

Michele Minelli10 / 16

Page 48: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Our activation function

We focus on f (x) = sign (x) .

-2

-1

0

1

2...

. . .

I

−I

+1

−1

Michele Minelli11 / 16

Page 49: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Our activation function

We focus on f (x) = sign (x) .

-2

-1

0

1

2...

. . .

I

−I

+1

−1

Michele Minelli11 / 16

Page 50: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Michele Minelli12 / 16

Page 51: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Standard packing technique: encrypt a polynomial instead of a scalar.

ct = TLWE.Encrypt(∑

ipi X i

)

Same thing for weights (in the clear) in the first hidden layer: wpol :=∑

i wiX−i .

The constant term of ct · wpol is then Enc (∑

i wi xi).

Michele Minelli12 / 16

Page 52: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Standard packing technique: encrypt a polynomial instead of a scalar.

ct = TLWE.Encrypt(∑

ipi X i

)

Same thing for weights (in the clear) in the first hidden layer: wpol :=∑

i wiX−i .

The constant term of ct · wpol is then Enc (∑

i wi xi).

Michele Minelli12 / 16

Page 53: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Standard packing technique: encrypt a polynomial instead of a scalar.

ct = TLWE.Encrypt(∑

ipi X i

)

Same thing for weights (in the clear) in the first hidden layer: wpol :=∑

i wiX−i .

The constant term of ct · wpol is then Enc (∑

i wi xi).

Michele Minelli12 / 16

Page 54: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Fact We can keep the msg space constant (bound on all multisums).Better idea Change the msg space to reduce errors. Intuition: less slices when we do not

need them.How Details in the paper. Quick intuition: change what we put in the wheel.

Bottom lineWe can start with any message space at encryption time, and change it dynamically during thebootstrapping.

Michele Minelli12 / 16

Page 55: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Fact We can keep the msg space constant (bound on all multisums).

Better idea Change the msg space to reduce errors. Intuition: less slices when we do notneed them.

How Details in the paper. Quick intuition: change what we put in the wheel.

Bottom lineWe can start with any message space at encryption time, and change it dynamically during thebootstrapping.

Michele Minelli12 / 16

Page 56: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Fact We can keep the msg space constant (bound on all multisums).Better idea Change the msg space to reduce errors. Intuition: less slices when we do not

need them.

How Details in the paper. Quick intuition: change what we put in the wheel.

Bottom lineWe can start with any message space at encryption time, and change it dynamically during thebootstrapping.

Michele Minelli12 / 16

Page 57: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Fact We can keep the msg space constant (bound on all multisums).Better idea Change the msg space to reduce errors. Intuition: less slices when we do not

need them.How Details in the paper. Quick intuition: change what we put in the wheel.

Bottom lineWe can start with any message space at encryption time, and change it dynamically during thebootstrapping.

Michele Minelli12 / 16

Page 58: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Refining TFHE1 Reducing bandwidth usage2 Dynamically changing the message space

Fact We can keep the msg space constant (bound on all multisums).Better idea Change the msg space to reduce errors. Intuition: less slices when we do not

need them.How Details in the paper. Quick intuition: change what we put in the wheel.

Bottom lineWe can start with any message space at encryption time, and change it dynamically during thebootstrapping.

Michele Minelli12 / 16

Page 59: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 60: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWE

Enc(∑

i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 61: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 62: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE

·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 63: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 64: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWE

extract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 65: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 66: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 67: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 68: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWE

weighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 69: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 70: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores

Dec

7argmax

User Server

Michele Minelli13 / 16

Page 71: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec

7argmax

User Server

Michele Minelli13 / 16

Page 72: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec

7

argmax

User Server

Michele Minelli13 / 16

Page 73: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Overview of the processEvaluation of a DiNN with 30 neurons in the hidden layer:

...... ...

1 TLWEEnc

(∑i piX i)

30 TLWE·∑

i wiX−i

30 LWEextract

30 LWE

sign bootstrapping

10 LWEweighted sums

10 scores Dec7argmax

User Server

Michele Minelli13 / 16

Page 74: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Experimental resultsOn inputs in the clear

Original NN (R) DiNN + hard_sigmoid DiNN + sign

30 neurons 94.76% 93.76% (-1%) 93.55% (-1.21%)

100 neurons 96.75% 96.62% (-0.13%) 96.43% (-0.32%)

On encrypted inputsAccur. Disag. Wrong BS Disag. (wrong BS) Time

30 or 93.71% 273 (105–121) 3383/300000 196/273 0.515 s

30 un 93.46% 270 (119–110) 2912/300000 164/270 0.491 s

100 or 96.26% 127 (61–44) 9088/1000000 105/127 1.679 s

100 un 96.35% 150 (66–58) 7452/1000000 99/150 1.64 s

or = original un = unfolded

Michele Minelli14 / 16

Page 75: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Experimental resultsOn inputs in the clear

Original NN (R) DiNN + hard_sigmoid DiNN + sign

30 neurons 94.76% 93.76% (-1%) 93.55% (-1.21%)

100 neurons 96.75% 96.62% (-0.13%) 96.43% (-0.32%)

On encrypted inputsAccur. Disag. Wrong BS Disag. (wrong BS) Time

30 or 93.71% 273 (105–121) 3383/300000 196/273 0.515 s

30 un 93.46% 270 (119–110) 2912/300000 164/270 0.491 s

100 or 96.26% 127 (61–44) 9088/1000000 105/127 1.679 s

100 un 96.35% 150 (66–58) 7452/1000000 99/150 1.64 s

or = original un = unfolded

Michele Minelli14 / 16

Page 76: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Benchmarks

Neurons Size of ct. Accuracy Time enc Time eval Time dec

FHE-DiNN 30 30 8.0 kB 93.71% 0.000168 s 0.49 s 0.0000106 s

FHE-DiNN 100 100 8.0 kB 96.35% 0.000168 s 1.65 s 0.0000106 s

Michele Minelli15 / 16

Page 77: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Benchmarks

Neurons Size of ct. Accuracy Time enc Time eval Time dec

FHE-DiNN 30 30 8.0 kB 93.71% 0.000168 s 0.49 s 0.0000106 s

FHE-DiNN 100 100 8.0 kB 96.35% 0.000168 s 1.65 s 0.0000106 s

independent ofthe network

Michele Minelli15 / 16

Page 78: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Benchmarks

Neurons Size of ct. Accuracy Time enc Time eval Time dec

FHE-DiNN 30 30 8.0 kB 93.71% 0.000168 s 0.49 s 0.0000106 s

FHE-DiNN 100 100 8.0 kB 96.35% 0.000168 s 1.65 s 0.0000106 s

scaleslinearly

Michele Minelli15 / 16

Page 79: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Open problems and future directions

Build better DiNNs: more attention to the conversion (+ retraining)

Implement on GPU to have realistic timingsMore models (e.g., convolutional NNs) and machine learning problems

Research neededWe need a fast way to evaluate other, more complex, functions (e.g., max or ReLUa).

aReLU (x) = max (0, x)

Thank you for your attention!Questions?

Michele Minelli16 / 16

Page 80: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Open problems and future directions

Build better DiNNs: more attention to the conversion (+ retraining)Implement on GPU to have realistic timings

More models (e.g., convolutional NNs) and machine learning problems

Research neededWe need a fast way to evaluate other, more complex, functions (e.g., max or ReLUa).

aReLU (x) = max (0, x)

Thank you for your attention!Questions?

Michele Minelli16 / 16

Page 81: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Open problems and future directions

Build better DiNNs: more attention to the conversion (+ retraining)Implement on GPU to have realistic timingsMore models (e.g., convolutional NNs) and machine learning problems

Research neededWe need a fast way to evaluate other, more complex, functions (e.g., max or ReLUa).

aReLU (x) = max (0, x)

Thank you for your attention!Questions?

Michele Minelli16 / 16

Page 82: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Open problems and future directions

Build better DiNNs: more attention to the conversion (+ retraining)Implement on GPU to have realistic timingsMore models (e.g., convolutional NNs) and machine learning problems

Research neededWe need a fast way to evaluate other, more complex, functions (e.g., max or ReLUa).

aReLU (x) = max (0, x)

Thank you for your attention!Questions?

Michele Minelli16 / 16

Page 83: Fast Homomorphic Evaluation of Deep Discretized Neural ... · Fast Homomorphic Evaluation of Deep Discretized Neural Networks Florian Bourse Michele Minelli Matthias Minihold Pascal

Open problems and future directions

Build better DiNNs: more attention to the conversion (+ retraining)Implement on GPU to have realistic timingsMore models (e.g., convolutional NNs) and machine learning problems

Research neededWe need a fast way to evaluate other, more complex, functions (e.g., max or ReLUa).

aReLU (x) = max (0, x)

Thank you for your attention!Questions?

Michele Minelli16 / 16