Documentation
¶
Overview ¶
Package sample provides primitive samplers — uniform mod q, ternary, centered binomial, discrete Gaussian — used as building blocks by every Lux lattice protocol.
LP-107 §"Sampling" — the canonical motivation. Protocol-specific samplers (e.g. Pulsar's transcript-bound discrete Gaussian for the proof of knowledge) remain in their owning protocol package; this package is the source of the primitive distributions those protocols compose.
Determinism contract: every sampler accepts an io.Reader as its entropy source. Same seed → same samples, byte-identically.
Phase 2 (this file): pure-Go reference implementation. Body uses luxfi/math/modarith for modular reduction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CenteredBinomial ¶
CenteredBinomial fills dst with values from a centered binomial distribution with parameter eta (Bin(2*eta, 0.5) - eta). Standard Module-LWE error distribution.
func DiscreteGaussianRejection ¶
DiscreteGaussianRejection samples one value approximately from the discrete Gaussian D_{Z, sigma}, centered at 0, via rejection sampling with a 6-sigma cutoff. Accepts ~64% of draws on average for sigma in the typical lattice range [3, 50]; exact for the uncentered tail.
This is the same reference path used by lattice/gpu.SampleGaussian (which we're consolidating here under LP-107).
func Ternary ¶
Ternary fills dst with values from {-1 mod q, 0, 1} per the given non-zero density (probability of non-zero coefficient). Standard lattice short-secret distribution.
Types ¶
This section is empty.