poly

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package poly provides polynomial-arithmetic primitives over R_q = Z_q[X] / (X^N + 1) used by every Lux lattice protocol.

LP-107 §"Polynomial and RNS operations" — the canonical motivation. Add, sub, scalar-mul, NTT-domain mul; converted to /from NTT domain via package ntt.

Phase 2 (this file): pure-Go reference implementation. Body uses luxfi/math/modarith for the field arithmetic and luxfi/math/ntt for the transform; no re-implementation, just composition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(dst, a, b []uint64, q uint64) error

Add returns dst = a + b (mod q). All inputs must have length N.

func Mul

func Mul(dst, a, b []uint64, svc *ntt.Service) error

Mul computes the negacyclic polynomial product dst = a * b (mod q, mod X^N + 1) via NTT round-trip: NTT(a), NTT(b), pointwise mul, inverse NTT. dst, a, b must each have length p.N. Inputs are in coefficient domain; output is in coefficient domain.

dst MAY alias a or b.

func PointwiseMul

func PointwiseMul(dst, a, b []uint64, q uint64) error

PointwiseMul returns dst = a * b (pointwise, NTT domain) (mod q). Inputs must already be in NTT domain; output is also in NTT domain. Use ntt.Service.Inverse to bring back to coefficient domain.

func ScalarMul

func ScalarMul(dst, a []uint64, scalar, q uint64) error

ScalarMul returns dst = a * scalar (mod q).

func Sub

func Sub(dst, a, b []uint64, q uint64) error

Sub returns dst = a - b (mod q).

Types

This section is empty.

Jump to

Keyboard shortcuts

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