Adds NTTEngine.NTTBatch / INTTBatch that dispatch to luxfi/lattice/v7/gpu
(Metal on darwin, CUDA on linux/NVIDIA) when:
1. CGo is on and a GPU device is reachable (lattice/gpu.GPUAvailable())
2. The engine's (N, Q) has passed a deterministic byte-equality probe
against the CPU subring NTT oracle (cached per (N, Q))
Otherwise falls back to per-polynomial CPU subring NTT. The probe ensures
a GPU context with different convention encoding (Montgomery vs standard,
bit-reversed vs natural) is rejected before it can corrupt ciphertexts.
No `gpu` build tag. CGo is the only compile-time gate.
Tests: ntt_gpu_test.go::TestNTTBatch_ByteEqualToInPlace (probe enforces
byte equality), TestINTTBatch_RoundTrip (INTT(NTT(x)) == x).
Bug 1: PN11QP54 used 0x3FFFFFFFFFC0001 which factors as 67*1447*6571*452444119.
Replaced with 0x3FFFFFFFFED001 (prime, 54-bit, Q ≡ 1 mod 4096).
Bug 2: findPrimitiveRoot only checked g^((Q-1)/2) != 1 but must check
g^((Q-1)/p) != 1 for ALL prime factors p of Q-1. Added primeFactors()
to compute distinct prime factors.
Also fixed: div128 overflow for Q > 32 bits (now uses math/bits.Div64),
mulModBarrett correctness for large Q, and INTTInPlace twiddle indexing.
- Remove old Go FHE code (now in lux/fhe)
- Remove old Zama compatibility layers
- Update CI for TypeScript/JS SDK only
- This repo is now purely the @luxfhe npm package ecosystem
- Remove replace directive for lattice/v7 (now using published v7.0.0)
- Keep gpu replace as it requires local C++ compilation and the git repo
path (luxfi/mlx) doesn't match module path (luxfi/gpu)
- TODO: Rename github.com/luxfi/mlx to github.com/luxfi/gpu to fix module path
Add complete test coverage for FHE package:
- evm_types_test.go: All EVM types (ebool → euint256) with big.Int
- testutil_test.go: Shared test utilities (testContext struct)
- pure_go_test.go: CGO_ENABLED=0 mode verification
- gpu_test.go: CGO_ENABLED=1 mode with serialization tests
- CHANGELOG.md: Track changes in semver format
Test coverage includes:
- Arithmetic: Add, Sub, Mul for all integer widths
- Comparison: Eq, Lt, Le, Gt, Ge
- Bitwise: And, Or, Xor, Not, Shl, Shr
- Operations: Min, Max, Select, Neg
- Memory management and benchmarks
Two serialization tests skipped with TODO(fhe#2) for pre-existing bugs.
BSD-3-Clause-Research License: Pure Go TFHE implementation with
patent-pending innovations including deterministic FHE for blockchain
consensus, transaction-batch amortized bootstrapping, and parallel
bootstrapping with work-stealing scheduler.