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

discrete ziggurat a time memory trade off for sampling
SMART_READER_LITE
LIVE PREVIEW

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,


slide-1
SLIDE 1

Discrete Ziggurat: A Time-Memory Trade-off for Sampling from a Gaussian Distribution over the Integers

Johannes Buchmann, Daniel Cabarcas, Florian G¨

  • pfert,

Andreas H¨ ulsing, Patrick Weiden

Technische Universit¨ at Darmstadt Darmstadt, Germany

Selected Areas in Cryptography Aug 16, 2013

1 / 18

slide-2
SLIDE 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

slide-3
SLIDE 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

  • ffering a flexible trade-off between speed and memory

3 / 18

slide-4
SLIDE 4

Discrete Gaussians and Samplers

◮ Discrete Gaussian distribution Dσ for parameter σ assigns

x ∈ Z probability proportional to ρσ(x) = exp(− 1

2x2/σ2) ◮ Sufficient for cryptographic applications: bounded support

B := Z ∩ [−tσ, tσ] with tailcut t > 0 large enough [GPV08]

  • ❛✉ss✿

❞✐s❝r❡t❡ −tσ tσ B = Z Z ∩ [−tσ, tσ] ❝♦♥t✐♥✉♦✉s

4 / 18

slide-5
SLIDE 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

slide-6
SLIDE 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

slide-7
SLIDE 7

The Ziggurat Algorithm

◮ Sampling x ∈ [0, tσ]: Intuition

◮ Given: partition of area into rectangles of equal size ◮ Choose rectangle Ri = Rl

i ∪ Rr i randomly

◮ Sampling in rectangle Ri: ◮ Sample x ∈ [0, xi] randomly ◮ If x ∈ Rl i : accept x ◮ Else sample in Rr i using rejection sampling (restart)

R1 R2 R3 R4 R5 R6 R7 x0 x1 x2 x3 x4 x5 x6 x7 ✳ ✳ ✳ A Rl

3

Rr

3

y0 y1 y2 y7

7 / 18

slide-8
SLIDE 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: (xi, yi) for Ri where i = 1, . . . ,#rectangles ◮ Expensive part: sampling in Rr i ◮ Trade-off:

◮ Controlled by #rectangles ◮ More rectangles: Rl

i comparatively bigger than Rr i

→ acceptance of x without computing ρσ(x) with higher probability → less rejections of x → less ‘restarts’

◮ But: more memory needed 8 / 18

slide-9
SLIDE 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 Rr i : straight line approach

Rr

i

yi xi−1 xi yi−1 s ρσ Rr

i

yi xi−1 xi yi−1 s ρσ

The concave-down case The concave-up case

9 / 18

slide-10
SLIDE 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 ∆(Dσ, Dσ) < te(1−t2)/2 + |B+

0 |

ρσ(B+) + 1

2

(2−ω+1 + 2−n). Proof idea: Hybrid argument using intermediary distributions

10 / 18

slide-11
SLIDE 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.

te(1−t2)/2

  • l

+ |B+

0 |

ρσ(B+) + 1

2

(2−ω+1 + 2−n)

  • r

< 2−100 → 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

slide-12
SLIDE 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 · 105 according to [GD12]

◮ Algorithms: Ziggurat, ZigguratO, invCDF∗, rejSam∗, KY

(∗ = lookup-table)

◮ Each algorithm queried to output 106 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

slide-13
SLIDE 13

Experiments and Results

Ziggurat ZigguratO invCDF rejSam KY

200000 400000 600000 800000 1000000 1200000 1400000 64 512 4096 32768 262144 209715216777216 134217728 Speed [samples/s] Memory [B]

Different samplers for σ = 1.6 · 105

13 / 18

slide-14
SLIDE 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 · 105:

◮ 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

slide-15
SLIDE 15

Experiments and Results

Improvement rate of ZigguratO to Ziggurat

  • 5

5 10 15 20 25 30 35 64 256 1024 4096 16384 65536 262144 Improvement [%] Memory [B]

15 / 18

slide-16
SLIDE 16

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

16 / 18

slide-17
SLIDE 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

slide-18
SLIDE 18

Thanks!

18 / 18