11 Commits
Author SHA1 Message Date
Hanzo AI 80dba8cb8b fhe: wire batch NTT/INTT to lattice/v7/gpu with byte-equality safety gate
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).
2026-05-24 14:17:44 -07:00
Hanzo AI 5f82c63695 fix: all routes under /v1/fhe/* — canonical path pattern 2026-04-09 17:46:41 -07:00
Hanzo AI 3c6afe682a fix: replace composite PN11QP54 modulus, fix findPrimitiveRoot to check all prime factors
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.
2026-04-07 16:51:18 -07:00
Zach Kelling 80590865fb Rebrand: ConcreteML → TorusML
- Rename TestConcretMLX/ to TestTorusMLX/
- Update rust/src/lib_python.rs module name
- Update WASM test imports
- Update CI workflow references
- Update Makefile targets
2026-01-26 20:50:15 -08:00
Zach Kelling e7d662e158 Complete Lux FHE rebrand 2026-01-25 13:58:30 -08:00
Zach Kelling a4ab9dd4a9 Clean up: Move Go FHE implementation to lux/fhe
- 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
2026-01-02 10:53:28 -08:00
Zach Kelling dfdcf0fcce ci: simplify Docker workflow, fix go fmt
- Remove Docker Hub dependency (use ghcr.io only)
- Fix gofmt issues in lazy_carry.go, threshold_rng*.go
- Make Docker Hub login optional with continue-on-error
2025-12-31 04:11:56 -08:00
Zach Kelling 06a880f3c5 chore: remove lattice replace directive, keep gpu for CGO
- 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
2025-12-30 16:12:35 -08:00
Zach Kelling b062253bb6 test: add comprehensive FHE test suite with EVM types
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.
2025-12-29 13:57:18 -08:00
Zach Kelling 46e4f1d319 refactor: rename module from tfhe to fhe
- Rename module path github.com/luxfi/tfhe => github.com/luxfi/fhe
- Rename tfhe.go => fhe.go, tfhe_test.go => fhe_test.go
- Update all internal references from tfhe to fhe
- Update SDK bindings and documentation
2025-12-29 10:59:13 -08:00
Zach Kelling c68dea0a9f Initial commit
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.
2025-12-28 18:04:25 -08:00