18 Commits
Author SHA1 Message Date
Hanzo AI 15135d3b63 deps: bump luxfi/vm v1.2.0, sampler v1.1.0, staking v1.5.0 (relicense)
Picks up the 2026-06-06 relicensing:
- luxfi/vm v1.2.0 → Lux Ecosystem License v1.2 (was Lux Research v1.0).
  License-only retag of the extracted runtime; patent reservation
  preserved for runtime optimization surfaces, royalty-free for
  Descending Chains.
- luxfi/sampler v1.1.0 → BSD-3-Clause (was Lux Research v1.0).
  License restored to match the luxfi/node provenance (originally
  extracted from node/utils/sampler).
- luxfi/staking v1.5.0 → BSD-3-Clause (was Lux Research v1.0).
  License restored to match the luxfi/node provenance.

No code changes in this commit — go.mod/go.sum only.
2026-06-06 19:01:30 -07:00
Hanzo AI 7893edc47e chore(deps): go get -u ./...
Updated dependencies to latest minor versions via go get -u + go mod tidy.
2026-06-02 11:12:35 -07:00
Hanzo AI 0b5e44ea3a deps: luxfi/crypto v1.19.0 2026-05-13 11:59:42 -07:00
Hanzo AI 8e81daacc6 LP-107 Phase 3: NTT canonical body migration to luxfi/math/ntt
Migrates the canonical Lattigo-derived Montgomery NTT body from
luxfi/lattice/v7/ring into luxfi/math/ntt/canonical. This is the
ownership inversion LP-107 Phase 3 calls for: the math substrate
now OWNS the canonical body, and luxfi/lattice/ring becomes a thin
shim over it.

ntt/canonical/ — new public package with the canonical body:
* subring.go         — SubRing struct + constructors (269 LoC)
* ntt.go             — NTT/INTT body, loop-unrolled-by-16 (1320 LoC)
* ntt_simd.go        — SIMD AVX2 dispatcher (405 LoC, build-tagged)
* ntt_simd_stub.go   — purego dispatcher stub for non-SIMD builds
* modular_reduction.go — Barrett + Montgomery scalars
* factorization.go   — prime factorization helpers
* utils.go           — primitive root finders, parameter helpers
* vec_ops.go         — vectorized polynomial helpers
* weierstrass.go     — companion algebraic helpers

ntt/purego.go — REWORK: the pureGoBackend now holds *canonical.SubRing
instead of *lattice/v7/ring.SubRing; the lattice/v7/ring import is
GONE. Cycle-free: GOWORK=off go list -deps github.com/luxfi/math/ntt
shows zero github.com/luxfi/lattice imports.

Total: ~3.7K LoC of canonical body migrated. Public API unchanged
for downstream callers — luxfi/lattice/ring re-exports the same
SubRing.NTT/INTT surface from the new owner location.

Tests: GOWORK=off go test ./... in luxfi/math/.claude/worktrees/lp-107-phase3
  ok  github.com/luxfi/math/ntt              (cached)
  ok  github.com/luxfi/math/ntt/canonical    0.276s
  + every other package green.
2026-05-04 10:26:46 -07:00
Hanzo AI e018a9c3d1 LP-107 Phase 2: math substrate — params, backend, codec, modarith,
ntt, poly, rns, sample

Eight pure-Go reference packages that own the canonical semantics of
every cryptographic-math primitive Lux protocols share. Backends
(AVX2 / NEON / cgo+C++ / CUDA / Metal / WGSL) plug in behind the
substrate; KATs gate byte-equality across them.

Packages added:

* params/    — ModulusID, NTTParamID, FHEParamID, PulsarParamID,
               HashSuiteID, BackendID; KATHeader required-fields
               schema. Stable string IDs; renaming is a breaking
               change.

* backend/   — Policy enum (PureGo / NativeCPU / GPUPreferred /
               GPURequired); Resolve(policy, registered) returns the
               BackendID per LP-107's fallback chain. GPURequired
               returns ErrUnavailable when no GPU backend is
               registered.

* codec/     — Bounded readers (closes lattice issues #2 + #4 DoS
               class permanently). Limits + LimitError + Reader.
               ReadUint{16,32,64}Slice all reject the 70T-element
               attack input before allocating; depth + frame-bytes
               caps; iterative (no recursion). Regression test
               TestReadUint64Slice_RejectsHugeLength encodes the
               original lattice issue #4 input.

* modarith/  — Modulus type with QInv, R2, Barrett constants
               (computed via math/big once per modulus). AddMod /
               SubMod / MulMod (Div64 reference path). MontMulMod /
               ToMontgomery / FromMontgomery cross-checked against
               MulMod across 100 random Pulsar-Q pairs.
               ReductionMode enum byte-equal to lattice/types.

* ntt/       — Service + Backend interface; pure-Go backend
               delegates to lattice/v7/ring.SubRing.NTT/INTT (the
               canonical Lattigo-derived Montgomery NTT body — no
               re-implementation, just dispatch). Round-trip +
               batch + determinism tests on Pulsar N=256.

* poly/      — Add / Sub / ScalarMul / PointwiseMul (NTT-domain) /
               negacyclic Mul (NTT round-trip). Composes modarith +
               ntt; no lower-level reach.

* rns/       — Basis(Moduli, Name) for FHE RNS chains. Single +
               two-prime construction validated; rejects even moduli.
               Phase 3 will add basis-extension and modulus-switching.

* sample/    — Uniform (rejection sampling, mask-and-retry); Ternary
               (density + sign byte); CenteredBinomial (popcount
               difference); DiscreteGaussianRejection (6-sigma cutoff).
               All take an io.Reader so callers can KAT-replay.

Architecture invariants enforced in package docs:

  - Go is the canonical semantic reference.
  - Backend selection MUST NOT alter transcript bytes (consensus
    paths default to PolicyPureGo / PolicyNativeCPU).
  - No unbounded codec readers anywhere near wire formats.
  - No re-implementation: where lattice/v7/ring already owns the
    canonical body, we delegate, not fork.
  - One ID space; renaming is a breaking change.

Test posture: 8/8 packages green via `GOWORK=off go test ./...`.

Phases 3-7 (queued):
  3. lattice consumes math
  4. pulsar consumes lattice + math
  5. fhe consumes math
  6. luxcpp/crypto/math native backend mirror
  7. cross-runtime KAT release gate

See SUBSTRATE.md for the full posture and migration plan; full LP at
~/work/lux/lps/LP-107-lux-math-substrate.md.
2026-05-04 09:28:23 -07:00
Hanzo AI 8d638e5218 deps: update go.mod/go.sum 2026-04-19 17:04:50 -07:00
Hanzo AI f11d8d0eab chore: update dependencies 2026-04-01 14:03:38 -07:00
Hanzo Dev c7436768c8 chore: sync local changes 2026-03-26 22:47:13 -07:00
Zach Kelling f80474aedf chore: sync dependencies and format code 2026-02-04 15:43:42 -08:00
Zach Kelling 21b7243e9f refactor: remove local replace, use published big v0.1.0 2026-01-05 01:38:02 -08:00
Zach Kelling 356605c2c1 chore: update go.mod/sum 2026-01-04 19:29:50 -08:00
Zach Kelling 8e13df0a8b chore: update go.mod 2025-12-31 22:21:37 -08:00
Zach Kelling 107c43637e feat: add heap, linked, sorting, zero - remove utils dependency
- Add Zero[T any]() generic function for zero values
- Add IsSortedBytes for byte slice sorting checks
- Add heap/queue.go with priority Queue[T] implementation
- Add heap/map.go with indexed Map[K,V] for heap operations
- Add linked/list.go with doubly-linked List[T]
- Add linked/hashmap.go with ordered HashMap[K,V]
- Update sampleable_set.go to use local luxmath.Zero[T]()
- Update averager_heap.go to use github.com/luxfi/math/heap
- Update safe_math.go to use luxmath.Zero[T]()
- Remove github.com/luxfi/utils dependency entirely
2025-12-24 15:06:41 -08:00
Zach Kelling 086468c3ca refactor: remove node dependency, use extracted packages
- Replace github.com/luxfi/node/utils with github.com/luxfi/utils
- Replace github.com/luxfi/node/utils/sampler with github.com/luxfi/sampler
- Replace github.com/luxfi/node/utils/wrappers with github.com/luxfi/utils/wrappers
- Replace github.com/luxfi/node/utils/json with github.com/luxfi/utils/json
2025-12-24 14:12:00 -08:00
Zach Kelling 5675cd73a6 deps: upgrade crypto to v1.17.25 2025-12-21 11:11:46 -08:00
Zach Kelling 8015ec9f82 Update dependencies to latest versions 2025-12-13 10:42:20 +00:00
Zach Kelling 9cf2d96eec Remove local replace, update to latest luxfi versions
- Remove local replace directive for luxfi/utils
- Use published github.com/luxfi/utils v1.0.0
- Update github.com/luxfi/geth: v1.16.34 -> v1.16.43
- Update github.com/luxfi/ids: v1.0.2 -> v1.1.4
- Update github.com/luxfi/crypto: v1.2.9 -> v1.17.15
- Update Go version to 1.25.5
- All tests pass
2025-12-11 05:44:25 +00:00
Hanzo Dev f271a0362b Initial commit: Lux math library 2025-08-18 13:18:19 -05:00