Ring-­‐Learning	
  With	
  Errors	
  &	
  HElib
Wenjie	
  Lu(陸 文杰)	
  
University	
  of	
  Tsukuba	
  
riku@mdl.cs.tsukuba.ac.jp	
  
1
Outline
1.  Homomorphic	
  EncrypFon	
  &	
  Fully	
  Homomorphic	
  EncrypFon	
  (FHE)	
  
2.  Learning	
  With	
  Errors	
  (LWE)	
  &	
  Ring-­‐LWE	
  	
  
3.  Ring-­‐LWE	
  based	
  FHE	
  operaFons:	
  KeyGen	
  etc.	
  
4.  HElib	
  
1.  BGV’s	
  leveled	
  FHE	
  scheme	
  
2.  OpFmizaFons	
  e.g.	
  modulo-­‐switch	
  in	
  HElib	
  
3.  Example	
  codes	
  
5.  Two	
  kind	
  of	
  packing	
  methods	
  &	
  example	
  codes	
  
6.  Some	
  other	
  rouFnes	
  in	
  HElib	
  	
  &	
  example	
  codes	
  
7.  An	
  applicaFon	
  on	
  epidemiology	
  study	
  	
  
8.  Misc.	
  includes	
  noise-­‐esFmaFon	
  &	
  parameters	
  decision	
  in	
  HElib	
  
2
Privacy	
  Preserving	
  CompuFng
3
Secure	
  MulF-­‐parFes	
  CompuFng
Secure	
  Outsourcing Homomorphic	
  Encryp-on
Homomorphic	
  EncrypFon
•  AddiFve	
  Hom.	
  EncrypFon,	
  e.g.	
  Paillier	
  	
  
•  MulFplicaFve	
  Hom.	
  EncrypFon,	
  e.g.	
  ElGamal	
  
•  Fully	
  Homomorphic	
  EncrypFon	
  
	
  	
  	
  	
  	
  	
  	
  	
  SaFsfies	
  both	
  addiFve	
  and	
  mulFplicaFve
4
Fully	
  homomorphic	
  encrypFon
•  Breakthrough	
  by	
  Gentry	
  in	
  2009	
  
•  Main	
  idea:	
  
1.  First	
  build	
  a	
  somewhat	
  homomorphic	
  encrypFon	
  
2.  Then	
  apply	
  bootstrapping	
  to	
  achieve	
  FHE	
  
•  Common	
  facts	
  of	
  the	
  current	
  FHE	
  schemes	
  
1.  Noise	
  grows	
  with	
  operaFons	
  
2.  MulFplicaFon	
  yields	
  the	
  most	
  noise	
  
3.  DecrypFon	
  will	
  fail	
  with	
  too	
  large	
  noise
5
[A	
  fully	
  homomorphic	
  encrypFon	
  scheme	
  Gentry	
  2009]
Ring-­‐learning	
  With	
  Errors	
  based	
  FHE
•  RLWE	
  schemes:	
  	
  The	
  most	
  efficient	
  schemes	
  	
  
	
  	
  	
  	
  for	
  now.	
  
•  Different	
  kinds	
  of	
  RLWE	
  based	
  FHE	
  
1.  BGV’s	
  	
  leveled	
  scheme	
  (implemented	
  by	
  HElib)	
  
2.  Brakerski,	
  Scale-­‐invariant	
  scheme	
  
3.  ……
6
[(Leveled)	
  fully	
  homomorphic	
  encrypFon	
  without	
  bootstrapping]	
  
Brakerski,	
  Gentry,	
  Vaikuntanathan	
  2012
[Fully	
  Homomorphic	
  Encryp-on	
  without	
  Modulus	
  Switching	
  from	
  
Classical	
  GapSVP]	
  Brakerski,2012
Nota-ons
7
•  	
  	
  	
  	
  	
  	
  :	
  Integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  :	
  Vectors	
  consists	
  of	
  n	
  integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  uniformly	
  sample	
  	
  	
  	
  	
  	
  from	
  
• 	
   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  	
  set	
  of	
  polynomials	
  
•  F(x)	
  a	
  polynomial,	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  a	
  quoFent	
  set	
  
	
  	
  	
  	
  	
  	
  
•  Cyclotomic	
  polynomial:	
  
Nota-ons
8
•  	
  	
  	
  	
  	
  	
  :	
  Integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  :	
  Vectors	
  consists	
  of	
  n	
  integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  uniformly	
  sample	
  	
  	
  	
  	
  	
  from	
  
• 	
   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  	
  set	
  of	
  polynomials	
  
•  F(x)	
  a	
  polynomial,	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  a	
  quoFent	
  set	
  
	
  	
  	
  	
  	
  	
  
•  Cyclotomic	
  polynomial:	
  
x 1 ⌘ 6x + 6 mod 7
Nota-ons
9
•  	
  	
  	
  	
  	
  	
  :	
  Integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  :	
  Vectors	
  consists	
  of	
  n	
  integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  uniformly	
  sample	
  	
  	
  	
  	
  	
  from	
  
• 	
   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  	
  set	
  of	
  polynomials	
  
•  F(x)	
  a	
  polynomial,	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  a	
  quoFent	
  set	
  
	
  	
  	
  	
  	
  	
  
•  Cyclotomic	
  polynomial:	
  
Nota-ons
10
•  	
  	
  	
  	
  	
  	
  :	
  Integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  :	
  Vectors	
  consists	
  of	
  n	
  integer	
  modulo	
  q	
  
•  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  uniformly	
  sample	
  	
  	
  	
  	
  	
  from	
  
• 	
   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  	
  set	
  of	
  polynomials	
  
•  F(x)	
  a	
  polynomial,	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :	
  a	
  quoFent	
  set	
  
	
  	
  	
  	
  	
  	
  
•  Cyclotomic	
  polynomial:	
  
Cyclotomic	
  polynomial:	
  Some	
  “prime”	
  polynomial
Learning	
  With	
  Errors
•  LWE-­‐AssumpFon	
  
•  Ring-­‐LWE:	
  use	
  a	
  polynomial	
  ring	
  instead	
  
11
[On	
  lajces,	
  learning	
  with	
  errors,	
  random.	
  Regev	
  2005	
  ]
Learning	
  With	
  Errors
•  LWE-­‐AssumpFon	
  
•  Ring-­‐LWE:	
  use	
  a	
  polynomial	
  ring	
  instead	
  
12
[On	
  lajces,	
  learning	
  with	
  errors,	
  random.	
  Regev	
  2005	
  ]
Learning	
  With	
  Errors
•  LWE-­‐AssumpFon	
  
•  Ring-­‐LWE:	
  use	
  a	
  polynomial	
  ring	
  instead	
  
13
[On	
  lajces,	
  learning	
  with	
  errors,	
  random.	
  Regev	
  2005	
  ]
Add.	
  &	
  Mul.	
  On	
  
14
(i.e.	
  n	
  is	
  power	
  of	
  2)
Paremeters	
  in	
  RLWE-­‐based	
  scheme
15
(default	
  3.2)
Security	
  
parameter
The	
  stand	
  deviaFon	
  of	
  the	
  discrete	
  
	
  Gaussian	
  distribuFon
Message	
  Space	
  &	
  Ciphertext	
  Space
•  Message	
  Space:	
  polynomial	
  quoFent	
  ring	
  
•  Ciphertex	
  Space	
  	
  
16
Coefficients	
  
modulo	
  p
Polynomial	
  modulo	
  
Coefficients	
  
modulo	
  q
Polynomial	
  modulo	
  
Basic	
  EncrypFon	
  Scheme	
  OperaFons
•  KeyGeneraFon	
  
17
[Can	
  Homomorphic	
  Encryp-on	
  be	
  Prac-cal?	
  K.	
  Lauter	
  et	
  al.	
  2011]
Basic	
  EncrypFon	
  Scheme	
  OperaFons
•  EncrypFon	
  
•  DecrypFon	
  	
  
18
addi-ons,	
  mul-plica-ons	
  over	
  
polynomial	
  ring.
Homomorphic	
  OperaFons
•  AddiFon	
  
•  MulFplicaFon	
  	
  
The	
  size	
  of	
  ciphertext	
  increases!	
  
19
HElib
•  Purely	
  wrimen	
  in	
  C++	
  
•  Implements	
  the	
  BGV-­‐type	
  encrypFon	
  scheme	
  
•  Supports	
  opFmazaFons	
  such	
  as:	
  reLinearazaFon,	
  
bootstapping,	
  packing	
  
•  Supports	
  mulFthread	
  from	
  this	
  March	
  
20
[hmps://github.com/shaih/Helib]
Architecture	
  of	
  HElib
PAlgebra
Structure of Zm*, §2.4
PAlgebraMod
plaintext-slot algebra, §2.5
NumbTh
miscellaneous
utilities, §2.2
CModulus
polynomials mod p, §2.3
Math
DoubleCRT
polynomial arithmetic, §2.8
FHE
KeyGen/Enc/Dec, §3.2
Ctxt
Ciphertext operations, §3.1
Crypto
EncryptedArray
Routing plaintext slots, §4.1
IndexSet/IndexMap
Indexing utilities, §2.6
FHEcontext
parameters,§2.7
bluestein
FFT/IFFT, §2.3
timing
§2.1
KeySwitching
Matrices for key-switching, §3.3
21*	
  Reference	
  from	
  the	
  HElib	
  design	
  document
Leveled	
  homomorphic	
  encrypFon
The	
  BGV-­‐type	
  scheme	
  is	
  a	
  leveled	
  homomorphic	
  encrypFon	
  
scheme	
  
•  What	
  is	
  levels?	
  
–  The	
  ciphertext	
  space	
  is	
  not	
  fixed.	
  
•  Why	
  need	
  levels	
  ?	
  	
  
–  Bootstrapping	
  is	
  too	
  too	
  heavy	
  	
  
–  To	
  somehow	
  reduce	
  the	
  noise	
  inside	
  ciphertexts	
  	
  
•  When	
  to	
  change	
  the	
  level?	
  
– Majorly	
  arer	
  ciphertexts	
  mulFplicaFon	
  
22
L1
L2
L3
L4
[(Leveled)	
  fully	
  homomorphic	
  encrypFon	
  without	
  bootstrapping]	
  
Brakerski,	
  Gentry,	
  Vaikuntanathan	
  2012
Parameters	
  of	
  the	
  
	
  Leveled	
  homomorphic	
  encrypFon
1. An	
  posi9ve	
  integer	
  L,	
  called	
  levels	
  
2. A	
  prime	
  sequence	
  
•  The	
  ciphertext-­‐space	
  changes	
  level	
  by	
  level	
  
•  The	
  noise	
  inside	
  ciphertexts	
  can	
  reduce	
  by	
  
•  This	
  opera9on	
  called	
  Modulo-­‐switch	
  	
  
23
[(Leveled)	
  fully	
  homomorphic	
  encrypFon	
  without	
  bootstrapping]	
  
Brakerski,	
  Gentry,	
  Vaikuntanathan	
  2012
One	
  mulFplicaFon
How	
  to	
  decide	
  the	
  levels?
•  Majorly	
  depends	
  on	
  the	
  evaluaFon	
  funcFon	
  
24
Need	
  at	
  least	
  2-­‐levels
1-­‐level	
  may	
  also	
  works
1-­‐level	
  may	
  not	
  works
reLinearizaFon	
  (Key	
  switching)
•  What	
  is	
  relinearizaFon?
25
[Efficient	
  fully	
  homomorphic	
  encrypFon	
  from	
  LWE	
  Brakerski,	
  Vaikuntanathan,	
  2011]
The	
  dimension	
  of	
  ciphertext	
  increases!	
  
reLinearizaFon	
  (Key	
  switching)
•  Why	
  want	
  to	
  reLinearize	
  ?	
  
– To	
  reduce	
  the	
  overhead	
  in	
  ciphertext	
  mulFplicaFon	
  
•  Need	
  to	
  add	
  extra	
  informaFon	
  into	
  the	
  public	
  key	
  
•  Should	
  always	
  reLinearize	
  ?	
  
– Depends	
  on	
  the	
  mulFplicaFon	
  depth	
  
26
[Efficient	
  fully	
  homomorphic	
  encrypFon	
  from	
  LWE	
  Brakerski,	
  Vaikuntanathan,	
  2011]
Sample	
  codes:	
  Setup
levels
To	
  add	
  extra	
  informaFon	
  for	
  reLinearizaFon	
  
27
Line	
  6:	
  The	
  FHESecKey	
  class	
  was	
  designed	
  to	
  inherit	
  
from	
  the	
  FHEPubKey	
  class
Sample	
  codes:	
  Enc/Dec/Mult
Line	
  2:	
  Plaintext	
  need	
  to	
  be	
  a	
  polynomial.	
  
Line	
  7	
  &	
  9:	
  To	
  use	
  or	
  not	
  use	
  reLineraza-on	
  during	
  homomorphic	
  mul-plica-on	
  
28
sk.Decrypt(plain,	
  ctxt);
Packing
What	
  is	
  packing	
  ?	
  
•  To	
  pack	
  several	
  messages	
  into	
  one	
  ciphertext	
  
Why	
  use	
  packing	
  ?	
  
1.  To	
  reduce	
  the	
  numbers	
  of	
  ciphertext	
  	
  
2.  To	
  amorFze	
  the	
  computaFon	
  Fme	
  
Different	
  kinds	
  of	
  packing	
  
•  Pack	
  into	
  coefficients	
  
•  Pack	
  into	
  subfields	
  (so-­‐called	
  CRT-­‐based	
  packing)	
  
29
I.	
  Pack	
  into	
  coefficients
•  Example	
  Message	
  Space	
  
•  image	
  that	
  8	
  boxes	
  and	
  each	
  can	
  put	
  in	
  a	
  less	
  than	
  
13^2	
  posiFve	
  integer.	
  	
  
1 2 3 4
30
I.	
  Pack	
  into	
  coefficients
•  We	
  need	
  to	
  design	
  how	
  to	
  encode	
  our	
  data	
  into	
  a	
  
useful	
  polynomial	
  form	
  
Enc(	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  )	
   Enc(	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  )	
  
Enc(	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  )	
  
Just	
  the	
  mul-plica-on	
  between	
  polynomials!	
  	
  
mod	
  (13^2,	
  x^8	
  +	
  1)
31
Example:	
  Encoding	
  for	
  scalar	
  product
•  Given	
  
•  If	
  we	
  make	
  two	
  polynomials	
  such	
  as	
  
•  But	
  
	
  
•  Change	
  a	
  limle	
  bit	
  
	
   	
   	
  	
  	
  
32
Sample	
  codes:	
  	
  
Pack	
  into	
  
Coefficients
3rd	
  coeff. 33
II.	
  Pack	
  into	
  subfields
•  Not	
  put	
  into	
  each	
  coefficients	
  directly	
  
•  UFlize	
  the	
  Chinese	
  Reminder	
  Theorem	
  	
A	
  number	
  p	
  can	
  
be	
  factorized	
  into	
  	
  
prime	
  factors	
  
Consider	
  the	
  CRT	
  in	
  the	
  integer	
  field
We	
  have	
  the	
  isomorphism	
  from	
  CRT
34
II.	
  Pack	
  into	
  subfields
•  Not	
  put	
  into	
  each	
  coefficients	
  directly	
  
•  UFlize	
  the	
  Chinese	
  Reminder	
  Theorem	
  	
A	
  number	
  p	
  can	
  
be	
  factorized	
  into	
  	
  
prime	
  factors	
  
Consider	
  the	
  CRT	
  in	
  the	
  integer	
  field
We	
  have	
  the	
  isomorphism	
  from	
  CRT
35
II.	
  Pack	
  into	
  subfields
•  Polynomial-­‐CRT	
  
The	
  cyclotomic	
  polynomial	
  
can	
  be	
  factorized	
  into	
  disFnct	
  
l	
  	
  irreducible	
  polynomials
For	
  each	
  irreducible	
  polynomial
called	
  slots
36
Euler	
  funcFon
(Some	
  “prime”	
  polynomial)
Example:	
  Component-­‐wise	
  OperaFons
•  m	
  =	
  8,	
  p	
  =	
  17	
  
•  So	
  each	
  slot	
  hold	
  degree	
  0	
  polynomial	
  modulo	
  17.	
  
37
	
  
	
  
	
  
	
  
	
  
Example:	
  Component-­‐wise	
  OperaFons
38
+ =
+ = mod	
  17
x
x = mod	
  17
=
Example:	
  “RotaFon”	
  OperaFon
39
On	
  field:
An	
  automorphism	
  
Replace
2	
  ler-­‐rotated	
  !!
OperaFons	
  supported	
  by	
  HElib
•  Component-­‐wise	
  (entry-­‐wise)	
  addiFon/mult.	
  
•  RotaFon	
  	
  
-  Shir;	
  padding	
  with	
  0s	
  
-  Running	
  sums	
  
-  total	
  sums
40
Sample	
  codes
Codes	
  for	
  	
  
CRT-­‐packing
41
Sample	
  codes	
  for	
  other	
  HElib	
  rou-nes	
  
42
Noise	
  EsFmaFon
•  Ok	
  to	
  decrypt:	
  
•  Fresh	
  ciphertext:	
  
•  Modulus-­‐switch:	
  
•  reLineara9on:	
  
•  Ctxt-­‐plain	
  add.:	
  
•  Ctxt-­‐plain	
  mult.:	
  
43
*	
  Reference	
  from	
  the	
  HElib	
  design	
  document
Noise	
  EsFmaFon
•  Ctxt-­‐ctxt	
  add.:	
  	
  
•  Ctxt-­‐ctxt	
  mult.:	
  
•  Rota9on:	
  	
  	
  	
  1	
  ctxt-­‐plain	
  mult.,	
  1	
  ctxt-­‐plain	
  add.	
  
•  ShiP:	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  2	
  ctxt-­‐plain	
  mult.
44
*	
  Reference	
  from	
  the	
  HElib	
  design	
  document
45
on	
  epidemiology	
  	
  
a A a	
  (expected) A(expected) Count
Case o1 o2 e1=n3n1/n e2=n4n1/n n1
Control o3 o4 e3=n3n2/n e4=n4n2/n n2
Count n3 n4 n
Applica-on
observed	
  
46
on	
  epidemiology	
  	
  
a A Count
Case o1 o2 n1
Control o3 o4 n2
Count n3 n4 n
Applica-on
Data:	
  
[AA,	
  Aa,	
  aa,	
  Aa,	
  …..]
x=[	
  	
  	
  2	
  ,	
  	
  	
  1,	
  	
  	
  0,	
  	
  	
  1,	
  	
  …..]
Encoding
[case,	
  control,	
  case,	
  control,	
  ….]
Encoding
y=[	
  	
  	
  1	
  ,	
  	
  	
  	
  	
  	
  	
  	
  0,	
  	
  	
  	
  	
  	
  	
  1,	
  	
  	
  	
  	
  0,	
  	
  	
  …..]
47
on	
  epidemiology	
  	
  
a A Count
Case o1 o2 n1
Control o3 o4 n2
Count n3 n4 n
Applica-on
Data:	
  
[AA,	
  Aa,	
  aa,	
  Aa,	
  …..]
x=[	
  	
  	
  2	
  ,	
  	
  	
  1,	
  	
  	
  0,	
  	
  	
  1,	
  	
  …..]
Encoding
[case,	
  control,	
  case,	
  control,	
  ….]
Encoding
y=[	
  	
  	
  1	
  ,	
  	
  	
  	
  	
  	
  	
  	
  0,	
  	
  	
  	
  	
  	
  	
  1,	
  	
  	
  	
  	
  0,	
  	
  	
  …..]How	
  to	
  efficiently	
  
compute	
  scalar	
  
product??	
  
Packing!
Misc:	
  Example	
  to	
  choose	
  parameters
•  Problem:	
  To	
  	
  calculate	
  chi-­‐square	
  test	
  
•  Main	
  computaFon:	
  scalar	
  product	
  of	
  integer	
  vectors	
  
•  Integer	
  vectors:	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ;	
  Data	
  set	
  size	
  
1.  Plaintext	
  space	
  parameters:	
  	
  p,	
  r	
  
2.  Polynomial	
  parameter:	
  m	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  >	
  2000	
  to	
  pack	
  N	
  integers	
  	
  
3.  Levels	
  parameter:	
  L	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  Pack	
  into	
  coefficient:	
  Only	
  need	
  1	
  mulF.	
  =>	
  L	
  =	
  1	
  
	
  	
  	
  	
  	
  	
  	
  Pack	
  into	
  subfields:	
  Need	
  1	
  mulF.	
  &	
  1	
  running	
  sums	
  =>	
  L	
  =	
  2	
  is	
  bemer	
  
4.	
  	
  	
  Check	
  m	
  again	
  by	
  calling	
  FindM
48
Misc:	
  FindM()	
  &	
  the	
  number	
  of	
  slots
•  HElib	
  providers	
  a	
  such	
  funcFon:	
  
	
   	
   	
   	
  FindM(k,	
  L,	
  p,	
  m);	
  
	
  	
  	
  It	
  print	
  out	
  :	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ***	
  Bound	
  N=XXX,	
  choosing	
  m=YYY,	
  phi(m)=ZZZ	
  
	
  	
  	
  	
  k-­‐bits	
  security	
  if	
  phi(m)	
  >=	
  N	
  
•  The	
  number	
  of	
  slots	
  is	
  defined	
  as:	
  
49
Misc:	
  Example	
  to	
  choose	
  parameters
•  Problem:	
  To	
  compute	
  the	
  product	
  of	
  matrix	
  and	
  vector	
  
1.  Plaintext	
  parameter:	
  p^r	
  >	
  8	
  
2.  #slot	
  >=	
  2	
  (pack	
  each	
  rows(columns))	
  
3.  Levels:	
  L	
  =	
  3	
  maybe	
  good	
  
4.  	
  m	
  is	
  decided	
  by	
  FindM()	
  according	
  to	
  L,	
  p,	
  #slots	
  
	
  	
  	
  	
  	
  	
  	
  	
   50
2
1
1
0
2
2
6
6
2
2
1
0
0
1
6
2
Misc.:	
  Rules	
  of	
  thumb	
  
•  By	
  default,	
  only	
  use	
  half	
  of	
  the	
  machine	
  bits	
  for	
  levels	
  
1.  32-­‐bits	
  pla}orm,	
  open	
  –DNOT_HALF_PRIME	
  flag	
  
before	
  building	
  the	
  HElib	
  
2.  64-­‐bits	
  pla}orm:	
  before	
  call	
  buildModChain()	
  
•  Plaintext	
  parameter	
  p^r	
  !=	
  2,	
  bemer	
  to	
  add	
  more	
  levels	
  
	
  	
  	
  	
  	
  	
  	
  	
  
[hmps://github.com/shaih/HElib/issues/52]
51
Misc.:	
  Install	
  HElib
•  Install	
  NTL(Number	
  Theory	
  Library)	
  
	
  hmp://www.shoup.net/ntl/	
  
•  Install	
  GMP,	
  m3	
  library.	
  
•  Install	
  HElib	
  
	
  hmps://github.com/shaih/HElib	
  
•  To	
  use	
  mulFthread,	
  need	
  g++4.9(seems	
  not	
  works	
  
on	
  Mac	
  OS	
  for	
  now)
52
References
•  The	
  design	
  document	
  inside	
  the	
  HElib	
  repo.	
  
•  Fully	
  Homomorphic	
  SIMD	
  opera9ons.	
  N.P.Smart,	
  et.al	
  	
  
•  Can	
  homomorphic	
  be	
  prac9cal?	
  K.	
  Lauter	
  et.	
  al	
  
•  Secure	
  Paern	
  Matching	
  using	
  Somewhat	
  homomorphic	
  encryp9on.	
  
M.	
  Yasusa	
  et.	
  al	
  
•  Fully	
  Homomorphic	
  Encryp9on	
  without	
  Boostrapping.	
  	
  	
  
	
  	
  	
  	
  	
  Z.	
  Brakerski	
  et.	
  al	
  
•  Fully	
  Homomorphic	
  Encryp9on	
  with	
  Polylog	
  Overhead.	
  
	
  	
  	
  	
  	
  C.	
  Gentry	
  et	
  al.
53
Thank	
  you!
54

More Related Content

PDF
暗号文のままで計算しよう - 準同型暗号入門 -
PDF
中3女子でもわかる constexpr
PDF
Marp Tutorial
PPTX
AESについて 輪講資料
PPT
技術勉強会(楕円曲線暗号)資料
PDF
準同型暗号の実装とMontgomery, Karatsuba, FFT の性能
PPTX
自然言語処理 Word2vec
PDF
多数のセンサーによる 時空間センシングデータの 効率的な集約送信技術
暗号文のままで計算しよう - 準同型暗号入門 -
中3女子でもわかる constexpr
Marp Tutorial
AESについて 輪講資料
技術勉強会(楕円曲線暗号)資料
準同型暗号の実装とMontgomery, Karatsuba, FFT の性能
自然言語処理 Word2vec
多数のセンサーによる 時空間センシングデータの 効率的な集約送信技術

What's hot (20)

PPTX
Docker Tokyo
PDF
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
PDF
ARM CPUにおけるSIMDを用いた高速計算入門
PDF
Goの時刻に関するテスト
PDF
RSA暗号運用でやってはいけない n のこと #ssmjp
PDF
PPL 2022 招待講演: 静的型つき函数型組版処理システムSATySFiの紹介
PDF
分散型IDと検証可能なアイデンティティ技術概要
KEY
ラムダ計算入門
PDF
WASM(WebAssembly)入門 ペアリング演算やってみた
PDF
Dockerを支える技術
PDF
Twitterのsnowflakeについて
PDF
RSA鍵生成脆弱性ROCAの紹介
PDF
Domain Modeling Made Functional (DevTernity 2022)
PDF
DNN音響モデルにおける特徴量抽出の諸相
PDF
Singularityで分散深層学習
PDF
ペアリングベースの効率的なレベル2準同型暗号(SCIS2018)
PDF
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
PDF
Wavelet matrix implementation
PPTX
「NIST SP 800-204C サービスメッシュを利用したマイクロサービスベースのアプリケーション向けDevSecOpsの展開」概説
Docker Tokyo
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
ARM CPUにおけるSIMDを用いた高速計算入門
Goの時刻に関するテスト
RSA暗号運用でやってはいけない n のこと #ssmjp
PPL 2022 招待講演: 静的型つき函数型組版処理システムSATySFiの紹介
分散型IDと検証可能なアイデンティティ技術概要
ラムダ計算入門
WASM(WebAssembly)入門 ペアリング演算やってみた
Dockerを支える技術
Twitterのsnowflakeについて
RSA鍵生成脆弱性ROCAの紹介
Domain Modeling Made Functional (DevTernity 2022)
DNN音響モデルにおける特徴量抽出の諸相
Singularityで分散深層学習
ペアリングベースの効率的なレベル2準同型暗号(SCIS2018)
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
Wavelet matrix implementation
「NIST SP 800-204C サービスメッシュを利用したマイクロサービスベースのアプリケーション向けDevSecOpsの展開」概説
Ad

Viewers also liked (15)

PDF
Genopri2015
PPTX
Homomorphic Encryption
PPTX
Digital Fingerprinting
PDF
Inverted Index Based Multi-Keyword Public-key Searchable Encryption with Stro...
PDF
Promcon2016
PDF
The monad fear
PDF
Realizing Fine-Grained and Flexible Access Control to Outsourced Data with At...
PDF
Privacy-Preserving Search for Chemical Compound Databases
PDF
Overview of MONOMI
PDF
Fast, Private and Verifiable: Server-aided Approximate Similarity Computation...
PDF
DBMask: Fine-Grained Access Control on Encrypted Relational Databases
PDF
ENKI: Access Control for Encrypted Query Processing
PDF
Overview of CryptDB
PDF
Fuzzy Keyword Search over Encrypted Data in Cloud Computing
PDF
Privacy-Preserving Multi-Keyword Fuzzy Search over Encrypted Data in the Cloud
Genopri2015
Homomorphic Encryption
Digital Fingerprinting
Inverted Index Based Multi-Keyword Public-key Searchable Encryption with Stro...
Promcon2016
The monad fear
Realizing Fine-Grained and Flexible Access Control to Outsourced Data with At...
Privacy-Preserving Search for Chemical Compound Databases
Overview of MONOMI
Fast, Private and Verifiable: Server-aided Approximate Similarity Computation...
DBMask: Fine-Grained Access Control on Encrypted Relational Databases
ENKI: Access Control for Encrypted Query Processing
Overview of CryptDB
Fuzzy Keyword Search over Encrypted Data in Cloud Computing
Privacy-Preserving Multi-Keyword Fuzzy Search over Encrypted Data in the Cloud
Ad

Similar to Helib (16)

PPTX
Halo2 Verifier in Move from ZERO to ONE.pptx
PDF
Instrumentation & the Pitfalls of Abstraction
PDF
An Introduction to Quantum Programming Languages
PPTX
R meetup lm
PDF
Gnu octave
PPTX
Hybrid multichannel signal separation using supervised nonnegative matrix fac...
KEY
Verification with LoLA: 4 Using LoLA
PDF
Online Divergence Switching for Superresolution-Based Nonnegative Matrix Fa...
PDF
High-dimensional polytopes defined by oracles: algorithms, computations and a...
PPTX
Fuzzy logic
PDF
Introduction to Groovy (Serbian Developer Conference 2013)
PPTX
Theorem proving 2018 2019
PPTX
Polynomial regression
PDF
Backdoors to Satisfiability
PPTX
Ruby basics
PDF
Theorem proving 2018 2019
Halo2 Verifier in Move from ZERO to ONE.pptx
Instrumentation & the Pitfalls of Abstraction
An Introduction to Quantum Programming Languages
R meetup lm
Gnu octave
Hybrid multichannel signal separation using supervised nonnegative matrix fac...
Verification with LoLA: 4 Using LoLA
Online Divergence Switching for Superresolution-Based Nonnegative Matrix Fa...
High-dimensional polytopes defined by oracles: algorithms, computations and a...
Fuzzy logic
Introduction to Groovy (Serbian Developer Conference 2013)
Theorem proving 2018 2019
Polynomial regression
Backdoors to Satisfiability
Ruby basics
Theorem proving 2018 2019

Recently uploaded (20)

PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
Modernising the Digital Integration Hub
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Zenith AI: Advanced Artificial Intelligence
DOCX
search engine optimization ppt fir known well about this
PPT
What is a Computer? Input Devices /output devices
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Flame analysis and combustion estimation using large language and vision assi...
PPTX
2018-HIPAA-Renewal-Training for executives
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PPTX
Build Your First AI Agent with UiPath.pptx
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
Configure Apache Mutual Authentication
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
A contest of sentiment analysis: k-nearest neighbor versus neural network
Modernising the Digital Integration Hub
Taming the Chaos: How to Turn Unstructured Data into Decisions
Microsoft Excel 365/2024 Beginner's training
Zenith AI: Advanced Artificial Intelligence
search engine optimization ppt fir known well about this
What is a Computer? Input Devices /output devices
Getting started with AI Agents and Multi-Agent Systems
Flame analysis and combustion estimation using large language and vision assi...
2018-HIPAA-Renewal-Training for executives
Chapter 5: Probability Theory and Statistics
A proposed approach for plagiarism detection in Myanmar Unicode text
The influence of sentiment analysis in enhancing early warning system model f...
Consumable AI The What, Why & How for Small Teams.pdf
Build Your First AI Agent with UiPath.pptx
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
sbt 2.0: go big (Scala Days 2025 edition)
Configure Apache Mutual Authentication

Helib

  • 1. Ring-­‐Learning  With  Errors  &  HElib Wenjie  Lu(陸 文杰)   University  of  Tsukuba   riku@mdl.cs.tsukuba.ac.jp   1
  • 2. Outline 1.  Homomorphic  EncrypFon  &  Fully  Homomorphic  EncrypFon  (FHE)   2.  Learning  With  Errors  (LWE)  &  Ring-­‐LWE     3.  Ring-­‐LWE  based  FHE  operaFons:  KeyGen  etc.   4.  HElib   1.  BGV’s  leveled  FHE  scheme   2.  OpFmizaFons  e.g.  modulo-­‐switch  in  HElib   3.  Example  codes   5.  Two  kind  of  packing  methods  &  example  codes   6.  Some  other  rouFnes  in  HElib    &  example  codes   7.  An  applicaFon  on  epidemiology  study     8.  Misc.  includes  noise-­‐esFmaFon  &  parameters  decision  in  HElib   2
  • 3. Privacy  Preserving  CompuFng 3 Secure  MulF-­‐parFes  CompuFng Secure  Outsourcing Homomorphic  Encryp-on
  • 4. Homomorphic  EncrypFon •  AddiFve  Hom.  EncrypFon,  e.g.  Paillier     •  MulFplicaFve  Hom.  EncrypFon,  e.g.  ElGamal   •  Fully  Homomorphic  EncrypFon                  SaFsfies  both  addiFve  and  mulFplicaFve 4
  • 5. Fully  homomorphic  encrypFon •  Breakthrough  by  Gentry  in  2009   •  Main  idea:   1.  First  build  a  somewhat  homomorphic  encrypFon   2.  Then  apply  bootstrapping  to  achieve  FHE   •  Common  facts  of  the  current  FHE  schemes   1.  Noise  grows  with  operaFons   2.  MulFplicaFon  yields  the  most  noise   3.  DecrypFon  will  fail  with  too  large  noise 5 [A  fully  homomorphic  encrypFon  scheme  Gentry  2009]
  • 6. Ring-­‐learning  With  Errors  based  FHE •  RLWE  schemes:    The  most  efficient  schemes            for  now.   •  Different  kinds  of  RLWE  based  FHE   1.  BGV’s    leveled  scheme  (implemented  by  HElib)   2.  Brakerski,  Scale-­‐invariant  scheme   3.  …… 6 [(Leveled)  fully  homomorphic  encrypFon  without  bootstrapping]   Brakerski,  Gentry,  Vaikuntanathan  2012 [Fully  Homomorphic  Encryp-on  without  Modulus  Switching  from   Classical  GapSVP]  Brakerski,2012
  • 7. Nota-ons 7 •             :  Integer  modulo  q   •             :  Vectors  consists  of  n  integer  modulo  q   •                           :  uniformly  sample            from   •                                                                                   :    set  of  polynomials   •  F(x)  a  polynomial,                                                    :  a  quoFent  set               •  Cyclotomic  polynomial:  
  • 8. Nota-ons 8 •             :  Integer  modulo  q   •             :  Vectors  consists  of  n  integer  modulo  q   •                           :  uniformly  sample            from   •                                                                                   :    set  of  polynomials   •  F(x)  a  polynomial,                                                    :  a  quoFent  set               •  Cyclotomic  polynomial:   x 1 ⌘ 6x + 6 mod 7
  • 9. Nota-ons 9 •             :  Integer  modulo  q   •             :  Vectors  consists  of  n  integer  modulo  q   •                           :  uniformly  sample            from   •                                                                                   :    set  of  polynomials   •  F(x)  a  polynomial,                                                    :  a  quoFent  set               •  Cyclotomic  polynomial:  
  • 10. Nota-ons 10 •             :  Integer  modulo  q   •             :  Vectors  consists  of  n  integer  modulo  q   •                           :  uniformly  sample            from   •                                                                                   :    set  of  polynomials   •  F(x)  a  polynomial,                                                    :  a  quoFent  set               •  Cyclotomic  polynomial:   Cyclotomic  polynomial:  Some  “prime”  polynomial
  • 11. Learning  With  Errors •  LWE-­‐AssumpFon   •  Ring-­‐LWE:  use  a  polynomial  ring  instead   11 [On  lajces,  learning  with  errors,  random.  Regev  2005  ]
  • 12. Learning  With  Errors •  LWE-­‐AssumpFon   •  Ring-­‐LWE:  use  a  polynomial  ring  instead   12 [On  lajces,  learning  with  errors,  random.  Regev  2005  ]
  • 13. Learning  With  Errors •  LWE-­‐AssumpFon   •  Ring-­‐LWE:  use  a  polynomial  ring  instead   13 [On  lajces,  learning  with  errors,  random.  Regev  2005  ]
  • 14. Add.  &  Mul.  On   14 (i.e.  n  is  power  of  2)
  • 15. Paremeters  in  RLWE-­‐based  scheme 15 (default  3.2) Security   parameter The  stand  deviaFon  of  the  discrete    Gaussian  distribuFon
  • 16. Message  Space  &  Ciphertext  Space •  Message  Space:  polynomial  quoFent  ring   •  Ciphertex  Space     16 Coefficients   modulo  p Polynomial  modulo   Coefficients   modulo  q Polynomial  modulo  
  • 17. Basic  EncrypFon  Scheme  OperaFons •  KeyGeneraFon   17 [Can  Homomorphic  Encryp-on  be  Prac-cal?  K.  Lauter  et  al.  2011]
  • 18. Basic  EncrypFon  Scheme  OperaFons •  EncrypFon   •  DecrypFon     18 addi-ons,  mul-plica-ons  over   polynomial  ring.
  • 19. Homomorphic  OperaFons •  AddiFon   •  MulFplicaFon     The  size  of  ciphertext  increases!   19
  • 20. HElib •  Purely  wrimen  in  C++   •  Implements  the  BGV-­‐type  encrypFon  scheme   •  Supports  opFmazaFons  such  as:  reLinearazaFon,   bootstapping,  packing   •  Supports  mulFthread  from  this  March   20 [hmps://github.com/shaih/Helib]
  • 21. Architecture  of  HElib PAlgebra Structure of Zm*, §2.4 PAlgebraMod plaintext-slot algebra, §2.5 NumbTh miscellaneous utilities, §2.2 CModulus polynomials mod p, §2.3 Math DoubleCRT polynomial arithmetic, §2.8 FHE KeyGen/Enc/Dec, §3.2 Ctxt Ciphertext operations, §3.1 Crypto EncryptedArray Routing plaintext slots, §4.1 IndexSet/IndexMap Indexing utilities, §2.6 FHEcontext parameters,§2.7 bluestein FFT/IFFT, §2.3 timing §2.1 KeySwitching Matrices for key-switching, §3.3 21*  Reference  from  the  HElib  design  document
  • 22. Leveled  homomorphic  encrypFon The  BGV-­‐type  scheme  is  a  leveled  homomorphic  encrypFon   scheme   •  What  is  levels?   –  The  ciphertext  space  is  not  fixed.   •  Why  need  levels  ?     –  Bootstrapping  is  too  too  heavy     –  To  somehow  reduce  the  noise  inside  ciphertexts     •  When  to  change  the  level?   – Majorly  arer  ciphertexts  mulFplicaFon   22 L1 L2 L3 L4 [(Leveled)  fully  homomorphic  encrypFon  without  bootstrapping]   Brakerski,  Gentry,  Vaikuntanathan  2012
  • 23. Parameters  of  the    Leveled  homomorphic  encrypFon 1. An  posi9ve  integer  L,  called  levels   2. A  prime  sequence   •  The  ciphertext-­‐space  changes  level  by  level   •  The  noise  inside  ciphertexts  can  reduce  by   •  This  opera9on  called  Modulo-­‐switch     23 [(Leveled)  fully  homomorphic  encrypFon  without  bootstrapping]   Brakerski,  Gentry,  Vaikuntanathan  2012 One  mulFplicaFon
  • 24. How  to  decide  the  levels? •  Majorly  depends  on  the  evaluaFon  funcFon   24 Need  at  least  2-­‐levels 1-­‐level  may  also  works 1-­‐level  may  not  works
  • 25. reLinearizaFon  (Key  switching) •  What  is  relinearizaFon? 25 [Efficient  fully  homomorphic  encrypFon  from  LWE  Brakerski,  Vaikuntanathan,  2011] The  dimension  of  ciphertext  increases!  
  • 26. reLinearizaFon  (Key  switching) •  Why  want  to  reLinearize  ?   – To  reduce  the  overhead  in  ciphertext  mulFplicaFon   •  Need  to  add  extra  informaFon  into  the  public  key   •  Should  always  reLinearize  ?   – Depends  on  the  mulFplicaFon  depth   26 [Efficient  fully  homomorphic  encrypFon  from  LWE  Brakerski,  Vaikuntanathan,  2011]
  • 27. Sample  codes:  Setup levels To  add  extra  informaFon  for  reLinearizaFon   27 Line  6:  The  FHESecKey  class  was  designed  to  inherit   from  the  FHEPubKey  class
  • 28. Sample  codes:  Enc/Dec/Mult Line  2:  Plaintext  need  to  be  a  polynomial.   Line  7  &  9:  To  use  or  not  use  reLineraza-on  during  homomorphic  mul-plica-on   28 sk.Decrypt(plain,  ctxt);
  • 29. Packing What  is  packing  ?   •  To  pack  several  messages  into  one  ciphertext   Why  use  packing  ?   1.  To  reduce  the  numbers  of  ciphertext     2.  To  amorFze  the  computaFon  Fme   Different  kinds  of  packing   •  Pack  into  coefficients   •  Pack  into  subfields  (so-­‐called  CRT-­‐based  packing)   29
  • 30. I.  Pack  into  coefficients •  Example  Message  Space   •  image  that  8  boxes  and  each  can  put  in  a  less  than   13^2  posiFve  integer.     1 2 3 4 30
  • 31. I.  Pack  into  coefficients •  We  need  to  design  how  to  encode  our  data  into  a   useful  polynomial  form   Enc(                                              )   Enc(                                          )   Enc(                                                                                              )   Just  the  mul-plica-on  between  polynomials!     mod  (13^2,  x^8  +  1) 31
  • 32. Example:  Encoding  for  scalar  product •  Given   •  If  we  make  two  polynomials  such  as   •  But     •  Change  a  limle  bit             32
  • 33. Sample  codes:     Pack  into   Coefficients 3rd  coeff. 33
  • 34. II.  Pack  into  subfields •  Not  put  into  each  coefficients  directly   •  UFlize  the  Chinese  Reminder  Theorem   A  number  p  can   be  factorized  into     prime  factors   Consider  the  CRT  in  the  integer  field We  have  the  isomorphism  from  CRT 34
  • 35. II.  Pack  into  subfields •  Not  put  into  each  coefficients  directly   •  UFlize  the  Chinese  Reminder  Theorem   A  number  p  can   be  factorized  into     prime  factors   Consider  the  CRT  in  the  integer  field We  have  the  isomorphism  from  CRT 35
  • 36. II.  Pack  into  subfields •  Polynomial-­‐CRT   The  cyclotomic  polynomial   can  be  factorized  into  disFnct   l    irreducible  polynomials For  each  irreducible  polynomial called  slots 36 Euler  funcFon (Some  “prime”  polynomial)
  • 37. Example:  Component-­‐wise  OperaFons •  m  =  8,  p  =  17   •  So  each  slot  hold  degree  0  polynomial  modulo  17.   37          
  • 38. Example:  Component-­‐wise  OperaFons 38 + = + = mod  17 x x = mod  17 =
  • 39. Example:  “RotaFon”  OperaFon 39 On  field: An  automorphism   Replace 2  ler-­‐rotated  !!
  • 40. OperaFons  supported  by  HElib •  Component-­‐wise  (entry-­‐wise)  addiFon/mult.   •  RotaFon     -  Shir;  padding  with  0s   -  Running  sums   -  total  sums 40
  • 41. Sample  codes Codes  for     CRT-­‐packing 41
  • 42. Sample  codes  for  other  HElib  rou-nes   42
  • 43. Noise  EsFmaFon •  Ok  to  decrypt:   •  Fresh  ciphertext:   •  Modulus-­‐switch:   •  reLineara9on:   •  Ctxt-­‐plain  add.:   •  Ctxt-­‐plain  mult.:   43 *  Reference  from  the  HElib  design  document
  • 44. Noise  EsFmaFon •  Ctxt-­‐ctxt  add.:     •  Ctxt-­‐ctxt  mult.:   •  Rota9on:        1  ctxt-­‐plain  mult.,  1  ctxt-­‐plain  add.   •  ShiP:                      2  ctxt-­‐plain  mult. 44 *  Reference  from  the  HElib  design  document
  • 45. 45 on  epidemiology     a A a  (expected) A(expected) Count Case o1 o2 e1=n3n1/n e2=n4n1/n n1 Control o3 o4 e3=n3n2/n e4=n4n2/n n2 Count n3 n4 n Applica-on observed  
  • 46. 46 on  epidemiology     a A Count Case o1 o2 n1 Control o3 o4 n2 Count n3 n4 n Applica-on Data:   [AA,  Aa,  aa,  Aa,  …..] x=[      2  ,      1,      0,      1,    …..] Encoding [case,  control,  case,  control,  ….] Encoding y=[      1  ,                0,              1,          0,      …..]
  • 47. 47 on  epidemiology     a A Count Case o1 o2 n1 Control o3 o4 n2 Count n3 n4 n Applica-on Data:   [AA,  Aa,  aa,  Aa,  …..] x=[      2  ,      1,      0,      1,    …..] Encoding [case,  control,  case,  control,  ….] Encoding y=[      1  ,                0,              1,          0,      …..]How  to  efficiently   compute  scalar   product??   Packing!
  • 48. Misc:  Example  to  choose  parameters •  Problem:  To    calculate  chi-­‐square  test   •  Main  computaFon:  scalar  product  of  integer  vectors   •  Integer  vectors:                                          ;  Data  set  size   1.  Plaintext  space  parameters:    p,  r   2.  Polynomial  parameter:  m                                    >  2000  to  pack  N  integers     3.  Levels  parameter:  L                    Pack  into  coefficient:  Only  need  1  mulF.  =>  L  =  1                Pack  into  subfields:  Need  1  mulF.  &  1  running  sums  =>  L  =  2  is  bemer   4.      Check  m  again  by  calling  FindM 48
  • 49. Misc:  FindM()  &  the  number  of  slots •  HElib  providers  a  such  funcFon:          FindM(k,  L,  p,  m);        It  print  out  :                                        ***  Bound  N=XXX,  choosing  m=YYY,  phi(m)=ZZZ          k-­‐bits  security  if  phi(m)  >=  N   •  The  number  of  slots  is  defined  as:   49
  • 50. Misc:  Example  to  choose  parameters •  Problem:  To  compute  the  product  of  matrix  and  vector   1.  Plaintext  parameter:  p^r  >  8   2.  #slot  >=  2  (pack  each  rows(columns))   3.  Levels:  L  =  3  maybe  good   4.   m  is  decided  by  FindM()  according  to  L,  p,  #slots                   50 2 1 1 0 2 2 6 6 2 2 1 0 0 1 6 2
  • 51. Misc.:  Rules  of  thumb   •  By  default,  only  use  half  of  the  machine  bits  for  levels   1.  32-­‐bits  pla}orm,  open  –DNOT_HALF_PRIME  flag   before  building  the  HElib   2.  64-­‐bits  pla}orm:  before  call  buildModChain()   •  Plaintext  parameter  p^r  !=  2,  bemer  to  add  more  levels                   [hmps://github.com/shaih/HElib/issues/52] 51
  • 52. Misc.:  Install  HElib •  Install  NTL(Number  Theory  Library)    hmp://www.shoup.net/ntl/   •  Install  GMP,  m3  library.   •  Install  HElib    hmps://github.com/shaih/HElib   •  To  use  mulFthread,  need  g++4.9(seems  not  works   on  Mac  OS  for  now) 52
  • 53. References •  The  design  document  inside  the  HElib  repo.   •  Fully  Homomorphic  SIMD  opera9ons.  N.P.Smart,  et.al     •  Can  homomorphic  be  prac9cal?  K.  Lauter  et.  al   •  Secure  Paern  Matching  using  Somewhat  homomorphic  encryp9on.   M.  Yasusa  et.  al   •  Fully  Homomorphic  Encryp9on  without  Boostrapping.                Z.  Brakerski  et.  al   •  Fully  Homomorphic  Encryp9on  with  Polylog  Overhead.            C.  Gentry  et  al. 53