rns

package
v1.4.1 Latest Latest
Warning

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

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

Documentation

Overview

Package rns provides the Residue Number System primitives that FHE schemes use to operate over a chain of small primes instead of one large modulus.

LP-107 §"Polynomial and RNS operations" — the canonical motivation. FHE PN10QP27 / PN11QP54 ring chains are RNS towers; their basis- extension and modulus-switching primitives live here.

Phase 2 (this file): defines the public surface for RNS Basis, Tower, and basis-extension. Concrete bodies delegate to github.com/luxfi/lattice/v7/ringqp; Phase 3 of LP-107 inverts that.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basis

type Basis struct {
	// Moduli is the tuple of primes. Each entry MUST satisfy
	// gcd(q_i, q_j) = 1 for i != j; we don't re-check this at every
	// op (it's a parameter-set property).
	Moduli []*modarith.Modulus
	// Name is a stable identifier (e.g. "fhe-pn10qp27").
	Name string
}

Basis describes one RNS basis: a list of pairwise coprime primes q_0, q_1, ..., q_{k-1}. Numbers are represented as their CRT projections (x mod q_0, x mod q_1, ..., x mod q_{k-1}).

func NewBasis

func NewBasis(primes []uint64, name string) (*Basis, error)

NewBasis constructs an RNS basis from a list of primes. Returns an error if any modulus fails modarith.NewModulus.

func (*Basis) Levels

func (b *Basis) Levels() int

Levels returns the number of primes in the basis.

Jump to

Keyboard shortcuts

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