internal

package
v0.0.0-...-27b77c7 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RCDTprec uint8 = 72

Precision of RCDT

View Source
const RCDTprecLen uint8 = (RCDTprec >> 3)

Variables

View Source
var (
	ErrEncodingTooLong = errors.New("encoding is too long")
	ErrInvalidEncoding = errors.New("invalid encoding")
)
View Source
var C = [13]uint64{
	0x00000004741183A3,
	0x00000036548CFC06,
	0x0000024FDCBF140A,
	0x0000171D939DE045,
	0x0000D00CF58F6F84,
	0x000680681CF796E3,
	0x002D82D8305B0FEA,
	0x011111110E066FD0,
	0x0555555555070F00,
	0x155555555581FF00,
	0x400000000002B400,
	0x7FFFFFFFFFFF4800,
	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 (
	ErrEquation = errors.New("NTRU equation has no solution")
)
View Source
var ILN2 float64 = 1.44269504089
View Source
var LN2 float64 = 0.69314718056

ln(2) and 1 / ln(2), with ln the natural logarithm

View Source
var RCDT = [18]*big.Int{
	types.NewBigIntFromString("3024686241123004913666"),
	types.NewBigIntFromString("1564742784480091954050"),
	types.NewBigIntFromString("636254429462080897535"),
	types.NewBigIntFromString("199560484645026482916"),
	types.NewBigIntFromString("47667343854657281903"),
	types.NewBigIntFromString("8595902006365044063"),
	types.NewBigIntFromString("1163297957344668388"),
	types.NewBigIntFromString("117656387352093658"),
	types.NewBigIntFromString("8867391802663976"),
	types.NewBigIntFromString("496969357462633"),
	types.NewBigIntFromString("20680885154299"),
	types.NewBigIntFromString("638331848991"),
	types.NewBigIntFromString("14602316184"),
	types.NewBigIntFromString("247426747"),
	types.NewBigIntFromString("3104126"),
	types.NewBigIntFromString("28824"),
	types.NewBigIntFromString("198"),
	types.NewBigIntFromString("1"),
}

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

Functions

func BaseSampler

func BaseSampler(randomBytes [RCDTprecLen]byte) int

func Compress

func Compress(v []int16, slen int) ([]byte, error)

Take as input an array of integers v and a bytelength slen, and return a bytestring of length slen that encode/compress v. If this is not possible, return False.

For each coefficient of v: - the sign is encoded on 1 bit - the 7 lower bits are encoded naively (binary) - the high bits are encoded in unary encoding

func Decompress

func Decompress(x []byte, slen int, n int) ([]int, error)

Take as input an encoding x, a bytelength slen and a length n, and return a list of integers v of length n such that x encode v. If such a list does not exist, the encoding is invalid and we output (nil, ErrInvalidEncoding).

func FfnpFFT

func FfnpFFT(t [][]complex128, T []interface{}) [][]complex128

func GenPoly

func GenPoly(n uint16) []int16

func Gram

func Gram(B [][][]float64) [][][]float64

func GsNorm

func GsNorm(f, g []float64, q float64) float64

func Karatsuba

func Karatsuba(a, b []*big.Int, n int) []*big.Int

Karatsuba multiplication between polynomials. The coefficients may be either integer or real.

func LdlFFT

func LdlFFT(G [][][]complex128) [][][][]complex128

func NtruGen

func NtruGen(n uint16) (f, g, F, G []int16)

func NtruSolve

func NtruSolve(f, g []*big.Int) ([]*big.Int, []*big.Int, error)

Solve the NTRU equation for f and g. Corresponds to NTRUSolve in Falcon's documentation.

func Samplerz

func Samplerz(mu, sigma, sigmin float64) int8

Given floating-point values mu, sigma (and sigmin), output an integer z according to the discrete Gaussian distribution D_{Z, mu, sigma}.

Input: - the center mu - the standard deviation sigma - a scaling factor sigmin The inputs MUST verify 1 < sigmin < sigma < MAX_SIGMA.

Output: - a sample z from the distribution D_{Z, mu, sigma}. https://falcon-sign.info/falcon.pdf#58

Types

type CoeffTree

type CoeffTree struct {
}

type FFTtree

type FFTtree struct {
	Value      []complex128
	Leftchild  []complex128
	Rightchild []complex128
}

func (*FFTtree) AllChild

func (t *FFTtree) AllChild() [][]complex128

func (*FFTtree) FfSamplingFFT

func (T *FFTtree) FfSamplingFFT(t [][]complex128, sigmin float64) [][]complex128

func (*FFTtree) FfldlFFT

func (T *FFTtree) FfldlFFT(G [][][]complex128) FFTtree

Directories

Path Synopsis
transforms
fft
ntt

Jump to

Keyboard shortcuts

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