lattice

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package lattice provides GPU-accelerated lattice cryptography operations.

Used for FHE (Fully Homomorphic Encryption), post-quantum signatures, and other lattice-based cryptographic schemes.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInput   = errors.New("lattice: invalid input")
	ErrInvalidDegree  = errors.New("lattice: invalid polynomial degree")
	ErrInvalidModulus = errors.New("lattice: invalid modulus")
)

Functions

func BatchNTTForward

func BatchNTTForward(params NTTParams, polys [][]uint64) ([][]uint64, error)

BatchNTTForward performs forward NTT on multiple polynomials in parallel.

func BatchNTTInverse

func BatchNTTInverse(params NTTParams, polys [][]uint64) ([][]uint64, error)

BatchNTTInverse performs inverse NTT on multiple polynomials in parallel.

func NTTForward

func NTTForward(params NTTParams, coeffs []uint64) ([]uint64, error)

NTTForward performs forward Number Theoretic Transform. Transforms polynomial from coefficient to evaluation form.

func NTTInverse

func NTTInverse(params NTTParams, evals []uint64) ([]uint64, error)

NTTInverse performs inverse Number Theoretic Transform. Transforms polynomial from evaluation to coefficient form.

func PolyAdd

func PolyAdd(modulus uint64, a, b []uint64) ([]uint64, error)

PolyAdd adds two polynomials coefficient-wise.

func PolyMul

func PolyMul(params NTTParams, a, b []uint64) ([]uint64, error)

PolyMul multiplies two polynomials using NTT. Result is (a * b) mod (X^N + 1) mod modulus.

func PolySub

func PolySub(modulus uint64, a, b []uint64) ([]uint64, error)

PolySub subtracts two polynomials coefficient-wise.

func SampleNTT

func SampleNTT(params NTTParams, seed []byte) ([]uint64, error)

SampleNTT samples a polynomial in NTT domain from a seed. Used for generating random polynomials in lattice schemes.

Types

type NTTParams

type NTTParams struct {
	N       uint32 // Polynomial degree (power of 2)
	Modulus uint64 // Prime modulus
	Root    uint64 // Primitive N-th root of unity
}

NTTParams contains parameters for NTT operations.

Jump to

Keyboard shortcuts

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