discrete ziggurat a time memory trade off for sampling
play

Discrete Ziggurat: A Time-Memory Trade-off for Sampling from a - PowerPoint PPT Presentation

Discrete Ziggurat: A Time-Memory Trade-off for Sampling from a Gaussian Distribution over the Integers Johannes Buchmann, Daniel Cabarcas, Florian G opfert, Andreas H ulsing, Patrick Weiden Technische Universit at Darmstadt Darmstadt,


  1. Discrete Ziggurat: A Time-Memory Trade-off for Sampling from a Gaussian Distribution over the Integers Johannes Buchmann, Daniel Cabarcas, Florian G¨ opfert, Andreas H¨ ulsing, Patrick Weiden Technische Universit¨ at Darmstadt Darmstadt, Germany Selected Areas in Cryptography Aug 16, 2013 1 / 18

  2. Outline Motivation and Contribution Discrete Gaussians and Samplers The Ziggurat Algorithm Quality of our Sampler and Parameter Choice Experiments and Results Conclusion 2 / 18

  3. Motivation and Contribution ◮ Discrete Gaussians widely used in lattice-based crypto ◮ E.g. signatures, encryption, (F)HE, multilinear maps ◮ Critical technical challenge: accurate and efficient sampling of discrete Gaussians ◮ E.g. sampling ≈ 50% of signing time [WHCB13] ◮ Existing methods: either large memory or very slow ◮ E.g. Peikert’s sampler about 12MB of storage [GD12] ◮ No flexibility in choice of memory and speed ◮ Memory requirement acceptable on PC, but not on smaller devices ◮ Our contribution: alternative sampler for discrete Gaussians offering a flexible trade-off between speed and memory 3 / 18

  4. Discrete Gaussians and Samplers ◮ Discrete Gaussian distribution D σ for parameter σ assigns x ∈ Z probability proportional to ρ σ ( x ) = exp( − 1 2 x 2 /σ 2 ) ◮ Sufficient for cryptographic applications: bounded support B := Z ∩ [ − t σ, t σ ] with tailcut t > 0 large enough [GPV08] ●❛✉ss✿ ❝♦♥t✐♥✉♦✉s ❞✐s❝r❡t❡ − tσ tσ B = Z Z ∩ [ − tσ, tσ ] 4 / 18

  5. Discrete Gaussians and Samplers ◮ Rejection sampling (rejSam) ◮ Inverse cumulative distribution function (invCDF) ◮ Knuth-Yao (KY) ◮ Hybrid variants: rejection sampling with lookup-table, . . . 5 / 18

  6. The Ziggurat Algorithm ◮ Belongs to class of rejection sampling algorithms ◮ Introduced by Marsaglia and Tsang for sampling from a continuous Gaussian distribution [MT00] ◮ Observation: ◮ Symmetry: sample x ∈ [0 , t σ ] acc. to PDF ◮ Sample sign s ∈ {− 1 , 1 } and return sx ◮ Attention: case x = 0 tσ 6 / 18

  7. The Ziggurat Algorithm ◮ Sampling x ∈ [0 , t σ ]: Intuition ◮ Given: partition of area into rectangles of equal size ◮ Choose rectangle R i = R l i ∪ R r i randomly ◮ Sampling in rectangle R i : ◮ Sample x ∈ [0 , x i ] randomly ◮ If x ∈ R l i : accept x ◮ Else sample in R r i using rejection sampling (restart) A y 0 R 1 y 1 R 2 y 2 R l R 3 3 R r 3 R 4 ✳ ✳ ✳ R 5 R 6 R 7 y 7 x 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 7 / 18

  8. The Ziggurat Algorithm ◮ Ziggurat = efficient “instantiation” of rejection sampling in enclosing area A (instead of in [0 , t σ ] × [0 , 1]) ◮ Rectangles of equal size: ensures equality of probabilities ◮ Storage: ( x i , y i ) for R i where i = 1 , . . . , #rectangles ◮ Expensive part: sampling in R r i ◮ Trade-off: ◮ Controlled by #rectangles ◮ More rectangles: R l i comparatively bigger than R r i → acceptance of x without computing ρ σ ( x ) with higher probability → less rejections of x → less ‘restarts’ ◮ But: more memory needed 8 / 18

  9. The Ziggurat Algorithm: Discretization Procedure: same as continuous Adaptation to discrete case: ◮ Notion of ‘size’ ◮ Pre-computation of rectangles ◮ Implementation issues: ◮ Fix point precision ◮ Discretizing the height ◮ Improvement of sampling in R r i : straight line approach y i − 1 y i − 1 ρ σ s R r R r s i i ρ σ y i y i x i − 1 x i x i − 1 x i The concave-down case The concave-up case 9 / 18

  10. Quality of our Sampler and Parameter Choice Theorem The statistical distance between the discrete Gaussian distribution D σ and the distribution D σ output by our algorithm is bounded by | B + 0 | ∆( D σ , D σ ) < te (1 − t 2 ) / 2 + (2 − ω +1 + 2 − n ) . ρ σ ( B + ) + 1 2 Proof idea: Hybrid argument using intermediary distributions 10 / 18

  11. Quality of our Sampler and Parameter Choice ◮ Parameters: Gaussian parameter σ , tailcut t , fix point precision n , height precision ω ◮ Goal: negligible statistical distance, e.g. | B + 0 | (2 − ω +1 + 2 − n ) te (1 − t 2 ) / 2 < 2 − 100 + ρ σ ( B + ) + 1 � �� � 2 l � �� � r → Find smallest integer t s.t. l < 2 − 101 : t = 13 → Choose ω = n + 1 reduces complexity of r → Find n such that r < 2 − 101 : n = 106 11 / 18

  12. Experiments and Results ◮ C++ implementation using Number Theory Library (NTL, [Sho]) ◮ Parameters: n = 106 ( ω = 107), t = 13, different σ ’s ◮ σ = 32 maintains worst-to-average-case reduction [Reg05], σ = 1 . 6 · 10 5 according to [GD12] ◮ Algorithms: Ziggurat, ZigguratO, invCDF ∗ , rejSam ∗ , KY ( ∗ = lookup-table) ◮ Each algorithm queried to output 10 6 samples ◮ Measured running time using clock gettime with clock CLOCK PROCESS CPUTIME ID (excluded pre-/post-comps.) ◮ Computed memory consumption using #fixed variables in regard to their type 12 / 18

  13. Experiments and Results Ziggurat ZigguratO invCDF rejSam KY 1400000 1200000 1000000 Speed [samples/s] 800000 600000 400000 200000 0 64 512 4096 32768 262144 209715216777216 134217728 Memory [B] Different samplers for σ = 1 . 6 · 10 5 13 / 18

  14. Experiments and Results Some numbers. . . ◮ σ = 32: ◮ rejSam factor 4.2 slower than invCDF, without lookup-table factor 558 slower ◮ Ziggurat factor 1.91 slower than invCDF, 2.19 faster than rejSam ◮ KY factor 3.53 faster than invCDF, but doubled memory ◮ σ = 1 . 6 · 10 5 : ◮ invCDF factor 4 slower than Ziggurat, factor 64 more memory ◮ rejSam about factor 6 slower than Ziggurat ◮ KY only better than Ziggurat by 4%, but 424 times more memory 14 / 18

  15. Experiments and Results Improvement rate of ZigguratO to Ziggurat 35 30 25 Improvement [%] 20 15 10 5 0 64 256 1024 4096 16384 65536 262144 -5 Memory [B] 15 / 18

  16. Conclusion: Take-Home-Message Discrete Ziggurat = Alternative sampler for discrete Gaussians offering a flexible trade-off between speed and memory 16 / 18

  17. Further details. . . Source code on homepage: https://www.cdc.informatik.tu-darmstadt.de/~pschmidt/ implementations/ziggurat/ziggurat-src.zip Version of paper with proofs on eprint: https://eprint.iacr.org/2013/510.pdf 17 / 18

  18. Thanks! 18 / 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend