FPGA Implementation and Comparison of Protections Against SCAs for RLWE Timo Zijlstra 1 Karim Bigou 2 Arnaud Tisserand 1 1 CNRS Lab-STICC UMR 6285, UBS 2 Universit´ e de Bretagne Occidentale - Lab-STICC UMR CNRS 6285 December 17, 2019 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 1 / 26
Overview RLWE-based Cryptography 1 Side channel vulnerabilities 2 Countermeasures against SCA 3 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 2 / 26
RLWE Encryption scheme [LPR10] LWE cryptography introduced by Regev [Reg05] Ring-LWE (RLWE) first appeared in [LPR10] Keys, ciphertexts are polynomials in Z q [ x ] / ( x n + 1) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 3 / 26
RLWE Encryption scheme [LPR10] LWE cryptography introduced by Regev [Reg05] Ring-LWE (RLWE) first appeared in [LPR10] Keys, ciphertexts are polynomials in Z q [ x ] / ( x n + 1) Alice ( KeyGen , Decrypt ) : Bob ( Encrypt ) : $ ← − random polynomial a $ ← − poly w/ small coefficients s , e a , b $ b ← a · s + e − − → e 1 , e 2 , e 3 ← − small c 1 ← a · e 1 + e 2 µ ′ ← D ( c 2 − c 1 · s ) c 1 , c 2 ← − − − c 2 ← b · e 1 + e 3 + E ( µ ) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 3 / 26
Encryption scheme in pictures 1. Encode E : 0 �→ 0 and 1 �→ q 2 . q/4 q/2 0 3q/4 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 4 / 26
Encryption scheme in pictures 2. Encryption : ciphertext coefficient 1. Encode E : 0 �→ 0 and 1 �→ q 2 . distribution is uniformly random over Z q . q/4 q/4 q/2 0 q/2 0 3q/4 3q/4 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 4 / 26
Encryption scheme in pictures 2. Encryption : ciphertext coefficient 1. Encode E : 0 �→ 0 and 1 �→ q 2 . distribution is uniformly random over Z q . q/4 q/4 q/2 0 q/2 0 3q/4 3q/4 3. Decryption : result is close to E ( µ ). q/4 q/2 0 3q/4 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 4 / 26
Encryption scheme in pictures 2. Encryption : ciphertext coefficient 1. Encode E : 0 �→ 0 and 1 �→ q 2 . distribution is uniformly random over Z q . q/4 q/4 q/2 0 q/2 0 3q/4 3q/4 3. Decryption : result is close to E ( µ ). 4. Decode D : left �→ 1, right �→ 0 q/4 q/4 q/2 1 0 q/2 0 0 3q/4 3q/4 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 4 / 26
Decryption function Input: ciphertext c 1 , c 2 Compute d = c 2 − c 1 · s Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 5 / 26
Decryption function Input: ciphertext c 1 , c 2 Compute d = c 2 − c 1 · s → use NTT: d ← c 2 − NTT − 1 ( ˆ c 1 · ˆ s ) Multiplication in NTT domain is point-wise: � � c 1 · ˆ s = c 1 , 1 · ˆ mod q , . . . , ˆ c 1 , n · ˆ mod q ˆ ˆ s 1 s n 1 polynomial multipication takes n multiplications in Z q Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 5 / 26
Side Channel Analysis model Attack each modular multiplication separately during decryption Hypothesis: for each c · s mod q , the power trace allows to guess: HW( c · s mod q ) + N (0 , σ ) HW modular memory mul. Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 6 / 26
Side Channel Analysis model Attack each modular multiplication separately during decryption Hypothesis: for each c · s mod q , the power trace allows to guess: HW( c · s mod q ) + N (0 , σ ) HW modular memory mul. CPA Attack: 1 Generate random ciphertexts 2 Predict power traces 3 Measure power traces during decryption 4 Compute correlation between traces and predictions 5 Maximum correlation is obtained for the correct guess Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 6 / 26
Side Channel Attack simulation Simulate CPA in SageMath: Machine executing one instruction per cycle Correlations from CPA: Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 7 / 26
Countermeasures Randomize computations How to obtain correct results from randomized computations? Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 8 / 26
Countermeasures Randomize computations How to obtain correct results from randomized computations? Masking [RRVV15] 1 [RRVV15] reports FPGA implementation Masked decryption 3 times slower than unmasked We optimize and re-implement it on FPGA Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 8 / 26
Countermeasures Randomize computations How to obtain correct results from randomized computations? Masking [RRVV15] 1 [RRVV15] reports FPGA implementation Masked decryption 3 times slower than unmasked We optimize and re-implement it on FPGA Blinding and Shifting [Saa18] 2 We implement on FPGA Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 8 / 26
Countermeasures Randomize computations How to obtain correct results from randomized computations? Masking [RRVV15] 1 [RRVV15] reports FPGA implementation Masked decryption 3 times slower than unmasked We optimize and re-implement it on FPGA Blinding and Shifting [Saa18] 2 We implement on FPGA Permutation (randomize the order of computations) 3 We propose 2 methods Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 8 / 26
Countermeasures Randomize computations How to obtain correct results from randomized computations? Masking [RRVV15] 1 [RRVV15] reports FPGA implementation Masked decryption 3 times slower than unmasked We optimize and re-implement it on FPGA Blinding and Shifting [Saa18] 2 We implement on FPGA Permutation (randomize the order of computations) 3 We propose 2 methods Redundant secret key representation 4 Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 8 / 26
Countermeasure: Blinding [Saa18] For all integers a , b : a c 1 · b s = ( ab )( c 1 · s ) Reminder Decrypt ( c 1 , c 2 ) = D ( c 2 − c 1 s ) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 9 / 26
Countermeasure: Blinding [Saa18] For all integers a , b : a c 1 · b s = ( ab )( c 1 · s ) 1 Pick some random a , b ∈ Z / q Z and compute ( ab ) − 1 2 Compute a c 1 · b s Reminder 3 Multiply by ( ab ) − 1 and subtract c 2 Decrypt ( c 1 , c 2 ) = D ( c 2 − c 1 s ) to obtain correct d 4 Decode → [Saa18]: use pre-computed roots of unity ω i , ω j , ω n − i − j Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 9 / 26
Countermeasure: Blinding [Saa18] For all integers a , b : a c 1 · b s = ( ab )( c 1 · s ) 1 Pick some random a , b ∈ Z / q Z and compute ( ab ) − 1 2 Compute a c 1 · b s Reminder 3 Multiply by ( ab ) − 1 and subtract c 2 Decrypt ( c 1 , c 2 ) = D ( c 2 − c 1 s ) to obtain correct d 4 Decode → [Saa18]: use pre-computed roots of unity ω i , ω j , ω n − i − j Computation of c 1 · s randomized at each run. d is not randomized = ⇒ decoding algorithm is not protected → use the blinding method in combination with another countermeasure. Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 9 / 26
Countermeasure: Shifting [Saa18] 1 Multiply s and c 1 by x i and x j respectively, for random i , j < n 2 Obtain c 1 s x i + j 3 Multiply by x − ( i + j ) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 10 / 26
Countermeasure: Shifting [Saa18] 1 Multiply s and c 1 by x i and x j respectively, for random i , j < n 2 Obtain c 1 s x i + j 3 Multiply by x − ( i + j ) In Z q [ x ] / ( x n + 1) : multiply by x i ⇐ ⇒ shift i positions to the right → easy to compute NTT domain: pointwise multiplication by NTT ( x i ) = (1 , ω i , ω 2 i , . . . ) → still easy to compute (since ω i is pre-computed for all i < n ) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 10 / 26
Countermeasure: Shifting [Saa18] 1 Multiply s and c 1 by x i and x j respectively, for random i , j < n 2 Obtain c 1 s x i + j 3 Multiply by x − ( i + j ) In Z q [ x ] / ( x n + 1) : multiply by x i ⇐ ⇒ shift i positions to the right → easy to compute NTT domain: pointwise multiplication by NTT ( x i ) = (1 , ω i , ω 2 i , . . . ) → still easy to compute (since ω i is pre-computed for all i < n ) Shifted decryption: 1 Get random indices i , j < n 2 Compute NTT ( x i ) ⊙ s , NTT ( x j ) ⊙ c 1 and NTT ( x i + j ) ⊙ c 2 3 Decrypt and shift i + j positions to the left. Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 10 / 26
Countermeasure: Masked Decryption [RRVV15] Use linearity: a ( b + c ) = ab + ac . Reminder Decrypt ( c 1 , c 2 ) = D ( c 2 − c 1 s ) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 11 / 26
Countermeasure: Masked Decryption [RRVV15] Use linearity: a ( b + c ) = ab + ac . 1 Generate a uniform random s ′ and let s ′′ ← s − s ′ . → then s = s ′ + s ′′ . Reminder Decrypt ( c 1 , c 2 ) = D ( c 2 − c 1 s ) Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 11 / 26
Countermeasure: Masked Decryption [RRVV15] Use linearity: a ( b + c ) = ab + ac . 1 Generate a uniform random s ′ and let s ′′ ← s − s ′ . → then s = s ′ + s ′′ . Reminder 2 Compute (part of) the decryption function for both shares: Decrypt ( c 1 , c 2 ) = D ( c 2 − c 1 s ) d ′ ← c 2 − c 1 s ′ d ′′ ← − c 1 s ′′ Then D ( d ′ + d ′′ ) = µ . Timo Zijlstra (CNRS) Indocrypt 2019 December 17, 2019 11 / 26
Recommend
More recommend