sampler

package module
v0.0.0-...-fa32371 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 6 Imported by: 0

README

FalconSampler

Gaussian sampler used in FALCON signature scheme, written in Golang

Test vectors obtained from official implementation

cpu: AMD Ryzen 5 5600X 6-Core Processor
=== RUN   BenchmarkSamplerz
BenchmarkSamplerz
BenchmarkSamplerz-12
 2881629               409.8 ns/op             0 B/op          0 allocs/op

Documentation

Index

Constants

View Source
const (
	// Precision of RCDT
	RCDTprec    uint8 = 72
	RCDTprecLen uint8 = (RCDTprec >> 3)

	// ln(2) and 1 / ln(2), with ln the natural logarithm
	LN2  float64 = 0.69314718056
	ILN2 float64 = 1.44269504089
)

Variables

View Source
var C = []*uint256.Int{
	NewBigNumFromInt(0x00000004741183A3),
	NewBigNumFromInt(0x00000036548CFC06),
	NewBigNumFromInt(0x0000024FDCBF140A),
	NewBigNumFromInt(0x0000171D939DE045),
	NewBigNumFromInt(0x0000D00CF58F6F84),
	NewBigNumFromInt(0x000680681CF796E3),
	NewBigNumFromInt(0x002D82D8305B0FEA),
	NewBigNumFromInt(0x011111110E066FD0),
	NewBigNumFromInt(0x0555555555070F00),
	NewBigNumFromInt(0x155555555581FF00),
	NewBigNumFromInt(0x400000000002B400),
	NewBigNumFromInt(0x7FFFFFFFFFFF4800),
	NewBigNumFromInt(0x8000000000000000),
}

C contains the coefficients of a polynomial that approximates exp(-x) More precisely, the value: (2 ** -63) * sum(C[12 - i] * (x ** i) for i in range(i)) Should be very close to exp(-x). This polynomial is lifted from FACCT: https://doi.org/10.1109/TC.2019.2940949

View Source
var RCDT = []*uint256.Int{
	NewBigNumFromHex("0xA3F7F42ED3AC391802"),
	NewBigNumFromHex("0x54D32B181F3F7DDB82"),
	NewBigNumFromHex("0x227DCDD0934829C1FF"),
	NewBigNumFromHex("0xAD1754377C7994AE4"),
	NewBigNumFromHex("0x295846CAEF33F1F6F"),
	NewBigNumFromHex("0x774AC754ED74BD5F"),
	NewBigNumFromHex("0x1024DD542B776AE4"),
	NewBigNumFromHex("0x1A1FFDC65AD63DA"),
	NewBigNumFromHex("0x1F80D88A7B64y28"),
	NewBigNumFromHex("0x1C3FDB2040C69"),
	NewBigNumFromHex("0x12CF24D031FB"),
	NewBigNumFromHex("0x949F8B091F"),
	NewBigNumFromHex("0x3665DA998"),
	NewBigNumFromHex("0xEBF6EBB"),
	NewBigNumFromHex("0x2F5D7E"),
	NewBigNumFromHex("0x7098"),
	NewBigNumFromHex("0xC6"),
	NewBigNumFromHex("0x1"),
}

RCDT is the reverse cumulative distribution table of a distribution that is very close to a half-Gaussian of parameter MAX_SIGMA.

Functions

func Min

func Min(a float64, b float64) float64

func NewBigNumFromHex

func NewBigNumFromHex(s string) *uint256.Int

func NewBigNumFromInt

func NewBigNumFromInt(i uint64) *uint256.Int

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL