Commit Graph
113 Commits
Author SHA1 Message Date
Hanzo AI e5f37e2cfd deps: database v1.18.3 (drops zapdb/v4 transitive); ntt_simd updates; bench/ 2026-05-05 17:11:33 -07:00
Hanzo AI a7cafe5f25 LP-107 Phase 5: fhe consumes luxfi/math/codec
wire/wire.go — fhe's wire-format hardening boundary. FHE wire formats
nest deeper than pulsar's (CKKS ciphertext = Vec<Poly> over RNS chain
of Vec<u64>) so MaxDepth = 5 + larger MaxFrameBytes (32 MiB) reflect
the deeper polynomial structure.

Tests:
* TestValidateCiphertextFrame_RejectsHugeLength — regression for
  lattice issue #4 attack input class. Same substrate, same
  rejection.
* TestValidateCiphertextFrame_OverCap — MaxFHESliceLen+1 rejected.

go.mod adds luxfi/math v1.3.0 dependency.

This completes Phase 5 of LP-107: every Lux Go protocol repo
(pulsar, lens, fhe, lattice) now consumes the math substrate for
bounded wire decoding. The same lattice issue #4 attack input is
rejected identically across all four consumers.
2026-05-04 09:50:34 -07:00
Hanzo AI 02fd28b349 fhe: KAT oracle + regen-kats.sh for cross-runtime byte-equality (LP-167)
Lands the Lux FHE-KAT corpus generators consumed by the C++ production
runtime at github.com/luxfi/luxcpp/crypto/fhe (LP-167). Mirrors the
pulsar/lens/warp regen script shape; emits a sha256 manifest and
supports --verify mode for determinism diffing.

Delivered:
  cmd/kat_oracle/main.go               KAT oracle. --emit --out <dir>
                                       writes one JSON entry per
                                       (param_set, seed) tuple. Each
                                       entry pins parameter-set ID,
                                       seed, operation tag, and a
                                       CRC32 fingerprint of the SHA-256
                                       digest of the canonical SecretKey
                                       MarshalBinary output.
  scripts/regen-kats.sh                Driver: runs kat_oracle, runs the
                                       in-tree determinism tests
                                       (TestNewKeyGeneratorFromSeed_Deterministic
                                       + TestNewKeyGeneratorFromSeed_DifferentSeeds),
                                       emits manifest. --verify mode
                                       diffs against existing manifest;
                                       fails on mismatch.
  scripts/regen-kats.manifest.sha256   Initial 4-entry manifest:
                                       PN10QP27 / PN11QP54 × seed-zero /
                                       seed-lp167-stable.

Verification:
  $ LUXCPP_DIR=$HOME/work/luxcpp scripts/regen-kats.sh --verify
  OK: Lux FHE KAT regeneration is byte-equal across runs (4 files)

  $ cd \$HOME/work/luxcpp/crypto/fhe
  $ ctest --test-dir build -R fhe_kat_replay
  OK lux-fhe-cpp KAT replay (4 entries)

LP-167 §"Cross-runtime KAT contract" requires both directions of
byte-equality. The Go→C++ direction is exercised by this commit and
the C++ replay test. The reverse direction (C++ generates, Go
verifies) is queued behind v0.1.0-rc2-fhe-gpu in lockstep with the
production CUDA NTT + key-switch + bootstrap kernels.

go test -count=1 -timeout=300s ./...  ->  3/3 ok
  ok  github.com/luxfi/fhe                 48.345s
  ok  github.com/luxfi/fhe/pkg/encrypted   98.833s
  ok  github.com/luxfi/fhe/pkg/threshold    0.778s
2026-03-03 12:00:00 -08:00
Hanzo AI 0094dd077d test(fhed): standalone integration smoke + cmd/fhed/README
Document fhed's two operating modes (standalone + threshold) explicitly
in cmd/fhed/README.md. fhed never reaches across the network for crypto
state — both modes are self-contained.

Add cmd/fhed/standalone_test.go behind the integration build tag. It
builds fhed, starts it on a free port with a fresh data dir, waits for
/v1/fhe/health, and round-trips an encrypted bit through the HTTP API.

Run: go test -tags=integration ./cmd/fhed/... -count=1 -timeout 180s

Honest scope-limit: the test currently fails on bootstrap-key persistence
("max slice length exceeded" from zapdb). The bug is upstream of this
change — fhed itself cannot complete first-time keygen on any parameter
set against current zapdb. Test is correct against the documented API
and will go green once the zapdb blob-size cap is raised in
github.com/luxfi/database.
2026-04-28 02:56:27 -07:00
Hanzo AI 84c1e8e1d7 feat(keygen): real deterministic NewKeyGeneratorFromSeed (v1.8.0)
Replace the stub implementation with a real HKDF-SHA256 derivation that
seeds blake2b KeyedPRNG streams driving ring.NewSampler over the secret
distribution Xs. Same seed -> byte-identical secret keys, the consensus
invariant validators rely on.

Pipeline:
  prk    = HKDF-Extract(SHA-256, salt="LUX_FHE_KEYGEN_v1", ikm=seed)
  keyLWE = HKDF-Expand(prk, "LUX_FHE_KEYGEN_v1:LWE", 32)
  keyBR  = HKDF-Expand(prk, "LUX_FHE_KEYGEN_v1:BR",  32)

Tests:
  - Deterministic (same seed -> same SK bytes)
  - DifferentSeeds (distinct seeds -> distinct SKs)
  - GoldenVector (sha256(SKBR) pinned for PN10QP27)
  - EmptySeed (rejected)

Unblocks luxfi/precompile fhe/fhe_ops.go:49 which calls this symbol.
2026-04-28 02:26:15 -07:00
Hanzo AI 5797cae572 fix: rlwe.NewKeyGenerator compat with lattice/v7
lattice/v7 dropped the FromPRNG constructor. Use NewKeyGenerator for
now; deterministic seeding tracked in luxfi/lattice#42.
2026-04-13 02:42:56 -07:00
Hanzo AI 8b8447a0a4 feat(encrypted): FHE CRDT primitives + RFC 3526 safe prime
LWW-Register, ORSet, GCounter merge under TFHE encryption.
EncryptedDocument with structural StateRoot (deterministic across
replicas despite ciphertext non-determinism). AnchorClient interface
for CRDTAnchor.sol checkpoint wiring.

Safe prime swap: 256-bit composite → 2048-bit RFC 3526 Group 14.
Feldman VSS generator now element of order q (was full group).
Reshare uses additive sub-sharing (no secret materialization).

19 encrypted + 10 threshold tests pass. Red-reviewed: 16 findings,
13 fixed, 5 scientist findings addressed.
2026-04-13 01:03:34 -07:00
Hanzo AI e91c21fe2d test: fheCRDT benchmark harness + lattice property checks
Adds bench_crdt_test.go with:
- Lattice property tests (commutativity, associativity, idempotence)
  for LWW-Register, G-Counter, and G-Set over FHE ciphertexts
- Benchmarks for single bootstrap, G-Set merge, G-Counter merge,
  LWW-Register merge throughput
- Ciphertext size measurement
- Simulated 2-node geo-distributed convergence with 50ms RTT
2026-04-12 22:50:17 -07:00
Hanzo AI 4a0944c37f feat: add cli package for lux CLI integration
Exports NewCmd() returning a cobra.Command with keygen, encrypt,
decrypt, and eval subcommands. Wires directly to fhe.KeyGenerator,
fhe.Encryptor, and fhe.Decryptor -- no stubs.
2026-04-12 21:41:49 -07:00
Hanzo AI 4e8b18b5a8 deps: luxfi/zapdb v4 → v1.0.0 (module path reset) 2026-04-11 00:05:17 -07:00
Hanzo AI 5f82c63695 fix: all routes under /v1/fhe/* — canonical path pattern 2026-04-09 17:46:41 -07:00
Hanzo AI 791751c217 chore: final cleanup — all security fixes applied, all tests passing 2026-04-07 22:19:10 -07:00
Hanzo AI 7cf246c498 security: add DEMO WARNING to regulated vault (operator holds full key) 2026-04-07 20:14:48 -07:00
Hanzo AI 6534720976 feat: regulated-vault demo — private data with MPC threshold decrypt for regulators
Operators can't see your data. Nobody can decrypt without t-of-n MPC approval.
Regulators can force-decrypt via legal process (threshold approval flow).

Endpoints:
  POST /v1/vault/store        encrypt + store (operator sees only ciphertext)
  GET  /v1/vault/list         list records (all encrypted, no plaintext)
  POST /v1/vault/request      request decryption (starts approval process)
  POST /v1/vault/approve/{id} MPC key holder approves (t-of-n threshold)
  GET  /v1/vault/reveal/{id}  get plaintext (only after threshold met)
  GET  /v1/vault/audit        full audit trail of all requests + approvals
  POST /v1/vault/compute      homomorphic computation on encrypted data

Architecture: FHE public key encrypts. Secret key Shamir-split across N MPC nodes.
No single party (including operator) can decrypt. Social/legal process required.
2026-04-07 19:07:16 -07:00
Hanzo AI a409594e84 feat: all 7 FHE demos now Base apps — single binary, admin UI, REST API
Each demo is a sovereign app: go run ./cmd/demos/<name> serve

darkpool:     /v1/orders, /v1/match, /v1/reveal — encrypted order matching
compliance:   /v1/portfolio, /v1/check — SEC diversification on encrypted holdings
marketmaker:  /v1/quotes, /v1/best — private market making
auction:      /v1/bids, /v1/determine-winner, /v1/reveal — sealed-bid auction
voting:       /v1/votes, /v1/tally, /v1/result — encrypted shareholder voting
nav:          /v1/holdings, /v1/compute — confidential fund valuation
proof:        /v1/positions, /v1/prove — compliance proofs without revealing data

All use Base embedded SQLite + admin UI at /_/. FHE key material
stored in Base's encrypted collections. Original FHE logic preserved.
2026-04-07 19:00:09 -07:00
Hanzo AI ccec005cde chore: clean working tree — all security fixes applied 2026-04-07 18:47:16 -07:00
Hanzo AI 0a10cdc0c6 security: fix FHE encryptor panic and NTT timing side-channel
F13: Add EncryptSafe(bool) (*Ciphertext, error) that returns errors instead of
panicking. Existing Encrypt(bool) is preserved but deprecated -- it now calls
EncryptSafe internally.

F07: Remove data-dependent branch (if hi == 0) from mulModBarrett. Always
execute the full 128-bit reduction path to eliminate timing side-channel.
2026-04-07 17:40:11 -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
Hanzo AI 4995827ce0 docs: README — architecture, primitives, usage 2026-04-07 09:42:42 -07:00
Hanzo AI 94a4332b52 feat: C FFI + Rust bindings (libluxfhe) 2026-04-04 12:45:53 -07:00
Hanzo AI 03be1b4356 feat: 7 FHE demo programs (dark pool, compliance, MM, auction, voting, NAV, proof) 2026-04-01 17:54:53 -07:00
Hanzo AI 7712c0c314 feat: fhed uses encrypted ZapDB for key material storage
Replace flat-file key storage (secret.key, public.key, bootstrap.key)
with encrypted ZapDB (ChaCha20-Poly1305). All FHE key material is now
stored in a single encrypted database at <dataDir>/zapdb/.

New pkg/store package wraps luxfi/database/encdb for:
- Secret/public/bootstrap key storage (encrypted at rest)
- Ciphertext cache by content hash
- Metadata storage

New --password flag (or FHED_PASSWORD env) for ZapDB encryption.
Both standard and threshold modes use ZapDB.
2026-04-01 16:49:44 -07:00
Hanzo AI 1fe442207d chore: symlink AGENTS.md and CLAUDE.md to LLM.md
Canonical project context lives in LLM.md. Symlinks ensure
agentic coding tools (agent, Cursor, etc.) find context
automatically regardless of which filename they look for.
2026-04-01 14:08:39 -07:00
Hanzo Dev 39344267fc chore: bump Go 1.26.0 → 1.26.1
Fixes 5 stdlib CVEs (html/template, os, net/url, crypto/x509 x2).
2026-03-12 01:08:22 -07:00
Hanzo Dev 67d8386e9a chore: update Go module dependencies 2026-03-03 11:31:01 -08:00
Zach Kelling 6097ab3461 fix: use published mdns v0.1.0 and remove local replace directive 2026-02-20 21:15:54 -08:00
Zach Kelling 93a2cd9e55 chore: standardize LLM.md/CLAUDE.md convention 2026-02-17 19:05:20 -08:00
Zach Kelling 961c42e204 feat: add FHE example apps for all Pars PIPs
- data-seal: Verifiable Data Integrity Seal (PIP-0010/LP-0535)
  FHE-encrypted tamper-proof sealing with Public/ZK/Private modes,
  batch sealing, homomorphic verification

- content-provenance: AI & Media Content Provenance (PIP-0011/LP-7110)
  Model manifests, output attestation via homomorphic comparison,
  media derivation DAGs

- encrypted-crdt: Encrypted CRDT (PIP-0013/LP-6500)
  LWW-Register with FHE values, OR-Set with tag-based add/remove,
  Lamport timestamp conflict resolution, deterministic merge

- shadow-governance: Shadow Government Protocol (PIP-7010)
  Anonymous ministries, encrypted voting with homomorphic tallying,
  nullifier-based anti-fraud, quorum enforcement

Each example includes Solidity contracts, Hardhat tests, CLI tasks,
and README linking to corresponding PIP and LP specifications.
2026-02-13 14:16:46 -08:00
Zach Kelling b6f42849c1 feat: add FHE example applications for sealing, voting, media auth, provenance, CRDTs, and statistics
Six production-ready example applications demonstrating the FHE library:
- cmd/seal: document integrity sealing with encrypted verification
- cmd/vote: encrypted voting system with threshold tallying
- cmd/mediaseal: media content authentication with FHE
- cmd/provenance: AI model provenance tracking with encrypted attestation
- cmd/crdt: encrypted LWW-Register for fheCRDT architectures (LP-6500)
- cmd/stats: secure multiparty statistics over encrypted data

Also pins luxfi/mdns to v0.1.0 and excludes compiled binaries from git.
2026-02-13 12:44:18 -08:00
Zach Kelling 148b20c2c7 refactor: convert to Go bindings only
Remove all submodules and non-Go content.
JS SDKs, plugins, templates, and examples live in their own repos.

Kept:
- Go FHE library (*.go)
- cmd/, pkg/, internal/
- docs/, bin/
2026-01-27 14:41:31 -08:00
Zach Kelling 83c0c3be91 rebrand: final cleanup Zama/Fhenix → Lux/LuxFHE
- Update all submodule references
- Fix ml/extensions LICENSE
- Fix ml/torus-ml CONTRIBUTING and Dockerfiles
- Fix sdk/relayer relayer URL
- Fix proto/decryption-oracle go.mod
- Rename fhevm-suite assets to Lux
- Update fhevm-suite LICENSE
2026-01-27 14:16:17 -08:00
Zach Kelling b10a38e0b7 Update all submodules: Zama/Fhenix → Lux/LuxFHE rebrand
Submodules updated:
- examples/smart-wallet: Fhenix → LuxFHE
- examples/kuhn-poker: Fhenix → LuxFHE
- plugins/remix: Zama → Lux
- templates/vue: Zama → Lux
- templates/nuxt: Fhenix → LuxFHE
- templates/foundry: Fhenix → LuxFHE
- templates/miniapp: Fhenix → LuxFHE
- mocks/foundry: Fhenix → LuxFHE
- js/permit: Fhenix → LuxFHE
2026-01-27 10:51:58 -08:00
Zach Kelling 71df92cb9e Rebrand: Remove Zama/Fhenix references
- plugins/remix: Zama → Lux CSS classes and URLs
- templates/vue: Zama → Lux URLs
- templates/foundry: fhenix → luxfhe remappings
- templates/nuxt,miniapp: fhenix → luxfhe
- js/permit: fhenixjs → luxfhejs
- mocks/foundry: fhenix → luxfhe remappings
- scripts/flatten-repos.sh: fhenixprotocol → luxfhe
- ml/torus-ml: Update spelling dictionary
2026-01-27 10:50:30 -08:00
Zach Kelling 467cf87ac2 Rebrand: Zama → Lux in scripts and docs
- Update GitHub org refs (zama-ai → luxfhe)
- Update PyPI URLs (pypi.zama.ai → pypi.lux.network)
- Update company name in docs
2026-01-27 10:35:11 -08:00
Zach Kelling fe4963bd12 Rebrand: Zama → Lux in TestTorusMLX
- Update copyright headers
- Update bundle identifiers
- Update API URLs
2026-01-27 10:34:48 -08:00
Zach Kelling c5dd14493e Complete Concrete→Torus rebrand
- Update migrate-zama.sh script
- Update ml/torus-ml submodule
- Update ios-demo submodule
2026-01-26 20:58:37 -08:00
Zach Kelling 9f7326f9c4 Complete Concrete→Torus rebrand in all files
- Update all requirements.txt files
- Update all GitHub workflow files
- Update Makefile and federated_learning/Makefile
- Update script files (shell scripts)
- Update deps_licenses files
- Rename raw_cml examples to raw_tml
2026-01-26 20:58:18 -08:00
Zach Kelling 2d521b827f Update ios-demo submodule (docs rebrand) 2026-01-26 20:53:05 -08: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 9b81ae13ef Rename CiphertextFormat.CONCRETE to TORUS 2026-01-26 18:43:04 -08:00
Zach Kelling 61d6b39157 Fix all remaining Concrete references in Python and docs 2026-01-26 18:41:32 -08:00
Zach Kelling dbcce73c7e Fix remaining Concrete → Torus references 2026-01-26 18:40:19 -08:00
Zach Kelling 0d5006ac29 Complete concrete → torus rename across all files 2026-01-26 18:39:19 -08:00
Zach Kelling e04b987975 Complete Torus ML rebrand - update all Python imports, docs, and file names 2026-01-26 18:38:13 -08:00
Zach Kelling ad6624eb92 Update biometrics to use torus-numpy 2026-01-26 18:36:17 -08:00
Zach Kelling 79f3069091 Rename Concrete ML to Torus ML 2026-01-26 18:35:22 -08:00
Zach Kelling c6df5cc9be Update contact email to fhe@lux.network 2026-01-26 18:27:03 -08:00
Zach Kelling 994fb86204 Update pyproject description to Lux FHE 2026-01-26 18:24:31 -08:00
Zach Kelling b304242857 Fix tfhe dependency URL to luxfhe org 2026-01-26 18:20:10 -08:00
Zach Kelling 9f1a8eea55 Update all submodules with Lux FHE rebrand 2026-01-26 18:18:07 -08:00