Commit Graph
124 Commits
Author SHA1 Message Date
zeekay 2e94deef62 Merge kms-nonce-bind-2026-04-28
# Conflicts:
#	CHANGELOG.md
2026-04-28 00:58:33 -07:00
zeekay 41c32bd4a8 cc/attest: canonical TEE attestation verifier (#222 stage 1)
Adds the canonical TEE attestation verifier package at cc/attest. This
is the home for chain validation + trust anchor management; the
luxcpp/crypto/attestation parser primitives feed bytes here BEFORE
their measurement output is trusted.

Stage 1 — SEV-SNP — PRODUCTION:
  - cc/attest/sev.go: SEVSNP{} verifier built on
    github.com/google/go-sev-guest v0.14.1. Live VCEK fetch from AMD
    KDS, ARK→ASK→VCEK chain validation, signature verify against the
    leaf, MEASUREMENT/REPORT_DATA/HOST_DATA/CHIP_ID extraction,
    caller-supplied policy gates (WithExpectedReportData,
    WithExpectedMeasurement). 197 LOC.
  - testdata/: real-vendor Milan attestation report + VCEK leaf
    committed verbatim from the upstream go-sev-guest test corpus.
    Tests replay the AMD KDS responses via SimpleGetter so CI never
    hits the network.
  - 9 SEV-SNP tests passing (happy path, dispatch, length reject,
    tampered signature, wrong report_data, wrong measurement,
    deterministic composite hash, unknown kind, stub-panic guard).

Stage 2 — TDX — STUB (#222 stage 2):
  - cc/attest/tdx.go: TDX{}.Verify panics with ErrNotImplemented so
    any caller routing TDX evidence during stage 1 fails LOUD. Plan
    documented inline: go-tdx-guest + Intel PCS + QE/TDX module
    identity pinning.

Stage 3 — NRAS — STUB (#222 stage 3):
  - cc/attest/nras.go: NRAS{}.Verify panics with ErrNotImplemented.
    Plan: lift the existing pkg/attestation/nvidia NRAS client into
    the cc/attest contract with a JWKS cache.

Wire-in:
  - pkg/attestation/composite.go gains VerifyEvidence(ctx, opts...)
    which dispatches each Evidence blob to cc/attest by Issuer.
    Callers (kms release gate, scheduler) MUST invoke this before
    accepting parser output.

Doc:
  - cc/attest/doc.go states the production/stub matrix and the
    layering contract between the C-ABI parser and this package.
2026-04-28 00:47:37 -07:00
zeekay 867663b38a deps: bump luxfi/hsm v1.1.1 → v1.1.2
v1.1.2 renames EnvProvider default env var from
LUX_MPC_PASSWORD to MPC_PASSWORD. The binary now reads the
canonical name used by the K8s operator injection.
2026-04-22 03:53:56 -07:00
zeekay 8c569f04cd fix(mpc): R2-1/R2-2 — webauthn verification + CAS under Postgres
R2-1: biometric enrollment is a forged-enrollment oracle fixed.
- pkg/webauthn/verify.go: full WebAuthn verification — compare against the
  random challenge bytes we issued (not the DB row ID), origin allowlist,
  rpIDHash equality, UP+UV authenticator-flag enforcement, ceremony type.
- pkg/webauthn/liveness.go: SecureGate-signed liveness attestation. Ed25519
  envelope over {providerId, userId, score, timestamp, nonce}. MPC verifies
  against MPC_SECUREGATE_PUBKEY_ED25519 and enforces userId match, score
  floor, max age. Body-supplied livenessScore is never trusted again.
- If SecureGate pubkey is unconfigured, handleBiometricEnroll returns 503.
- 14 new tests cover each rejection path.

R2-2: CAS-under-Postgres. The previous in-Go check-then-write +
unconditional UPSERT works on SQLite (writeMu) but loses updates under
Postgres READ COMMITTED. Switched to SELECT ... FOR UPDATE inside READ
COMMITTED tx via orm.RunInTransactionWith + orm.GetForUpdate[T]. Requires
hanzoai/[email protected] (tagged today).
- Session consume: operationLimit strictly respected under concurrency;
  valueAccum computed under the lock.
- Operation approve: ApprovedBy append under the row lock, quorum
  finalization transitions at most once even under racing approvers.
- pkg/db.New now supports postgres:// DSNs.
- New Postgres-backed regression tests in cas_postgres_test.go —
  auto-skipped when no TEST_PG_DSN reachable; 10 concurrent consumers
  against operationLimit=5 yields exactly 5 successes and 5 denials.

Bumps github.com/hanzoai/orm v0.3.2 → v0.4.0.

Test plan:
  go test -tags sqlite_json1 -count=10 \
    -run 'CASUnderRace|CASUnderRace_Postgres|RequireRoleOrAPIPermission' \
    ./pkg/api/ ./pkg/webauthn/
2026-04-18 17:02:33 -07:00
zeekay cb80ef4dd6 chore: exclude missing luxfi/genesis v1.5.21/22, sync edwards25519 replace 2026-04-18 15:18:16 -07:00
zeekay a8961d25c0 fix: lattice v7.0.2 — fresh tag, no stale proxy cache 2026-04-18 09:10:44 -07:00
zeekay ab7ff02e10 fix: edwards25519 v0.1.0 (published go.mod), lattice direct-download hash
- luxfi/edwards25519 now has go.mod (v0.1.0 tag)
- Replace agl/ed25519 → luxfi/edwards25519 v0.1.0
- go.sum lattice hash matches GOPRIVATE direct download (not proxy)
2026-04-18 09:06:00 -07:00
zeekay 8c7eb08cd2 fix: remove local replace directives — use published tagged versions only 2026-04-16 14:26:41 -07:00
zeekay c649ce7600 fix: remove postgres/valkey/legacy mode — consensus+ZapDB only
- Removed --mode, --api-db, --api-kv, --db flags
- Removed legacy NATS/Consul transport (runNode, ~200 lines)
- Removed standalone API server (runAPIOnly, ~200 lines)
- Removed Consul helpers, NATS connection, interactive prompts
- Dashboard now uses ZapDB (SQLite) instead of postgres
- pkg/db: removed postgres backend, removed valkey client
- Consensus mode is the only mode. Zero external deps.
2026-04-13 04:14:40 -07:00
zeekay 3e7078e533 deps: luxfi/zapdb v4 → v1.0.0 (module path reset) 2026-04-11 00:05:19 -07:00
zeekay b76314d404 Merge hanzo/mpc additions: ConsensusKV, HSM providers, policy engine, rename CLI to mpc-cli
- pkg/infra: Add abstract KV interface, ConsensusKV (dual-cert BFT with
  Ed25519 + ML-DSA-65), NatsKV, ConsulKVAdapter, HybridKV, SQLiteMeta
  with full test coverage
- pkg/hsm: Add Provider interface and implementations for AWS KMS,
  GCP Cloud KMS, Azure Key Vault, Zymbit HSM, Hanzo KMS, and file-based
  providers with registry and tests. Rename existing FileProvider to
  FilePasswordProvider to avoid collision with new Provider interface
- pkg/policy: Add transaction governance engine with signers, roles,
  spending limits, whitelist/blacklist, time windows, rate limiting,
  approval workflow, audit log, and FHE private policy evaluation
- contracts: Add ThresholdPolicy.sol for on-chain policy enforcement
- cmd: Rename lux-mpc-cli to mpc-cli
- Makefile: Update build targets for mpc-cli
2026-04-08 13:16:06 -07:00
zeekay 56042a466a fix: remove local replace directive for hanzoai/base
Bump hanzoai/base from v0.28.0 (broken module path) to v0.39.1
(correct module path). Removes the local development replace
directive so the module resolves from the Go module proxy.
2026-04-07 13:29:46 -07:00
zeekay 13bf95ee0d feat: Base framework + consensus default + minimal ops
- Mount chi handlers on Hanzo Base (lifecycle, health, auth framework)
- Default mode: consensus (ZAP p2p) — NATS/Consul deprecated
- compose.yml: 2 services (api + dashboard), SQLite, no external DB
- config.yaml: consensus mode, SQLite-first
- Makefile: simplified build targets, docker compose format
- K8s: kustomization.yaml for idempotent deploys
- Removed listenAddr from NewServer (Base handles listening)
- Legacy NATS/Consul preserved but not default
2026-04-07 01:18:53 -07:00
zeekay 17b3a2869a feat: SQLite default — zero external deps to start
db.New() auto-detects backend from DSN:
- "" or "sqlite://path" or "file.db" → SQLite (default)
- "postgres://..." → PostgreSQL (production upgrade)

KV (Valkey/Redis) is optional — pass "" to skip.
No postgres, no redis required to run mpcd out of the box.
Removed pgxpool direct dependency from db package.
2026-04-07 01:05:03 -07:00
zeekay 1a368e0da8 chore: update all dependencies
Go: 98 deps updated including crypto v1.17.45, threshold v1.6.0,
otel v1.42.0, cbor v2.9.1, samber/lo v1.53.0, urfave/cli v3.8.0.
Excluded luxfi/log v1.3.0 (broken module path declaration).
Makefile: add -tags json1 + CGO_ENABLED=1 for SQLite JSON support.

Dashboard: next 15.3.3, react 19.2.4, zustand 5.0.12,
tanstack/react-query 5.96.1, typescript 6.0.2, playwright 1.59.0.
Pinned eslint to v9 (v10 has peer dep conflicts with next eslint plugins).
Pinned tailwindcss to v3 (v4 requires postcss migration).

19/19 packages pass, dashboard builds clean.
2026-04-01 09:11:20 -07:00
zeekay 3b50768156 fix: bump luxfi/fhe v1.7.6 → v1.7.7 (checksum mismatch) 2026-03-20 10:50:10 -07:00
zeekay 3343f2b01d deps: update golang.org/x/crypto, x/net, x/sys to latest 2026-03-18 14:15:21 -07:00
zeekay 8b66b6ffd9 feat: sr25519 threshold signing for Polkadot/Substrate
MPC daemon now supports sr25519 (Schnorrkel) key generation and
threshold signing using FROST over the ristretto255 group.

New files:
- pkg/mpc/sr25519_keygen_session.go — threshold keygen
- pkg/mpc/sr25519_signing_session.go — threshold signing
- pkg/mpc/sr25519_config_marshal.go — CBOR serialization
- pkg/mpc/ristretto255.go — local curve implementation
- pkg/eventconsumer/signing_handler_sr25519.go — event routing

Wiring:
- KeyTypeSR25519 constant + session type
- Event consumer routes sr25519 keygen/signing events
- API accepts "sr25519" as valid protocol
- DOT/KSM network codes mapped to sr25519 key type
- Signing context configurable (default "substrate")

14 tests passing.
2026-03-18 14:09:08 -07:00
zeekay bdd4d05ab0 Wire HSM threshold attestation into MPC daemon
- Add --hsm-attest / MPC_HSM_ATTEST flag for share attestation
- Add --hsm-signer / --hsm-signer-key-id flags for co-signing
- KeyShareVault initialized when attestation enabled
- Bump github.com/luxfi/hsm v1.0.0 → v1.1.0
2026-03-02 23:52:08 -08:00
zeekay 9d2ab79482 chore: bump Go 1.26.0 → 1.26.1
Fixes 5 stdlib CVEs (html/template, os, net/url, crypto/x509 x2).
2026-02-28 01:09:24 -08:00
zeekay b4f933425a chore: upgrade zapdb v4.9.2 → v4.9.3
Picks up upstream badger merge, Go 1.26 vet fixes, and grpc build
tag for protobuf.
2026-02-27 23:09:04 -08:00
zeekay 668401f23d chore: go 1.26, add go.work, tidy modules
- Bump e2e module to go 1.26.0
- Add go.work workspace file (replaces need for local replaces)
- Remove dgraph-io/badger from e2e direct deps (unused directly)
- Tidy both modules
- Document agl/ed25519 redirect requirement (broken upstream)
2026-03-01 19:25:22 -08:00
zeekay 88b0c94297 refactor(kvstore): rename Badger→Zap types, clean up package API
- badger.go → zapdb.go, badger_backup.go → zap_backup.go
- BadgerKVStore → Store, BadgerConfig → Config, NewBadgerKVStore → New
- BadgerBackupExecutor → Backup, NewBadgerBackupExecutor → NewBackup
- BadgerBackupMeta → BackupMeta, BadgerBackupVersionInfo → BackupVersion
- Config.DBPath → Path, EncryptionKey → Key, BackupEncryptionKey → BackupKey
- Store.BackupExecutor → Store.Exec
- fix(wallet): expand participants list using ExpectedPeers
- chore: update go.mod deps (luxfi/database v1.17.43, luxfi/metric v1.5.0)
2026-03-01 18:34:47 -08:00
zeekay 2e92b3ffa3 refactor: use luxfi/database abstraction for KV storage, rename BadgerDB→ZapDB
- Replace direct github.com/luxfi/zapdb/v4 imports with github.com/luxfi/database
  abstraction in pkg/kvstore/ (zapdb.New + encdb.New for encryption)
- BadgerKVStore now uses database.Database interface internally — backend is
  pluggable (zapdb/leveldb/memdb) without changing MPC code
- Remove custom badger_logger.go (database module handles its own logging)
- Update BadgerBackupExecutor to use database.Database instead of *badger.DB;
  RestoreAllBackupsEncrypted loads into raw zapdb (values are already
  individually encrypted by encdb)
- Rewrite backup_test.go to use KVStore interface instead of raw badger API
- Update migration script to use KVStore Put/Get/Delete/Keys instead of txn API
- Rename all user-visible "BadgerDB"/"Badger" strings to "ZapDB" in logs,
  prompts, and comments across cmd/mpcd/main.go, pkg/kvstore/, pkg/transport/
- Fix backup_test.go type reference: badgerBackupExecutor→BadgerBackupExecutor
  (resolves CI test and lint failures)
2026-03-01 16:00:07 -08:00
zeekay df84005b46 feat: replace BadgerDB with ZapDB, remove local replace directives, vendor mode CI/CD
- Replace github.com/dgraph-io/badger/v4 with github.com/luxfi/zapdb/v4 v4.9.2
  throughout pkg/kvstore/, pkg/transport/, cmd/mpcd/, e2e/, scripts/
- Rename BadgerPath/BadgerPassword → ZapDBPath/ZapDBPassword in FactoryConfig
- Remove local replace directives from go.mod:
  - hanzoai/orm: now uses published v0.3.2 (tagged on GitHub)
  - hanzoai/kv-go/v9: now uses published v9.17.2-hanzo.1
  - Only remaining replace: agl/ed25519 → luxfi/edwards25519
- Add vendor/ directory (GOWORK=off go mod vendor) for reproducible builds
- Update Dockerfile to golang:1.26-alpine + -mod=vendor build flag
- Update CI/CD to use self-hosted linux/amd64 runners (no cross-compilation)
- Add k8s/valkey.yaml for session KV store
- Update k8s manifests: api-kv support, ZapDB password env, fresh secrets
- Dashboard API and MPC nodes all tested running on cluster (3/3 nodes healthy)
2026-03-01 15:27:32 -08:00
zeekay abe92a082c feat: implement MFA TOTP, real KMS encryption, smart wallet DB ops, fix dashboard stubs
Backend:
- MFA TOTP via pquerna/otp: generate secret, verify code, enforce at login
- KMS client: real AES-256-GCM encryption with Argon2id key derivation
- Smart wallet handlers: propose/execute Safe tx, submit UserOp via DB
- 9 new KMS tests, all 27 API tests passing

Frontend:
- Dashboard home fetches real vault/wallet counts, transactions, cluster status
- User menu shows actual logged-in email instead of hardcoded placeholder
- Reshare page connected to real API
- Smart wallet detail connected to real API (propose, execute, user-op)
- Loading/error states throughout
2026-02-28 15:11:20 -08:00
zeekay 1273c14334 fix: go.mod deps, white-label branding, cleanup stale workflows
- Fix go.mod: move chi, cors, jwt, pgx from indirect to direct deps
- Add jackc/puddle/v2 and golang.org/x/sync as indirect deps
- Add Dockerfile ARG TARGETARCH for multi-arch builds
- Add white-label hostname branding (mpc.lux.network vs cloud.lux.network)
- Add imagePullSecrets to K8s deployments
- Remove stale docker-publish.yml and docker.yml workflows
- Remove Dockerfile.go123 placeholder
- Fix release.yml Go version to 1.25.5
2026-02-28 13:35:08 -08:00
zeekay f110e06800 feat: MPC wallet dashboard - full-stack implementation
Complete MPC wallet management platform rivaling Fireblocks/Utila/Fordefi:

Backend (Go):
- REST API with 60+ endpoints on chi router (pkg/api/)
- PostgreSQL schema with 13 tables (pkg/db/)
- JWT + MFA auth, bcrypt passwords, API key management
- Policy engine (deny/approve/require_approval)
- Transaction signing flow with approval workflow
- Subscription scheduler for recurring payments
- Payment requests with public pay pages
- Safe + ERC-4337 smart wallet integration (pkg/smart/)
- Rate limiting, webhook delivery (HMAC-SHA256), audit logging
- 27 passing tests (auth, policy engine, middleware)

Frontend (Next.js 14):
- 27 routes with monochrome dark theme (Tailwind + Geist fonts)
- Full API client with JWT auto-refresh
- React Query hooks for all resources
- Pages: dashboard, vaults, wallets, transactions, policies,
  whitelist, team, settings, API keys, webhooks, audit,
  subscriptions, payments, smart wallets

Infrastructure:
- Dockerfiles for API (Go) and dashboard (Next.js standalone)
- compose.yml for local development (PostgreSQL + API + dashboard)
- K8s manifests for mpc.lux.network + cloud.lux.network
- GitHub Actions deploy workflow (build → push GHCR → kubectl apply)
- TLS via cert-manager, Traefik IngressRoute for both domains
2026-02-28 13:27:34 -08:00
zeekay 113615960a feat: add /keygen HTTP endpoint, PubSub self-delivery, increase keygen timeout
- Add POST /keygen endpoint for triggering MPC keygen via HTTP API
- Fix PubSub self-delivery: Publish now delivers to local subscribers
  before broadcasting to peers (required for consensus mode keygen)
- Increase KeyGenTimeOut from 30s to 120s (Paillier prime generation
  takes 6-15s per node, multi-round protocol needs more time)
- Add pubKeyToEthAddress helper for deriving ETH addresses from ECDSA keys
- Bump version to 0.3.3
2026-02-27 22:25:09 -08:00
zeekay db4c7ea771 feat: add S3 backup integration, keepalive pings, and connection stability
- Add S3 backup manager (pkg/backup/s3.go) for periodic encrypted BadgerDB
  backups with upload to S3-compatible storage (MinIO)
- Add 30s keepalive pings in transport layer to prevent idle read timeouts
- Increase read timeout from 30s to 5 minutes
- Add connection tie-breaking for simultaneous peer connections (lower node
  ID keeps outbound) to prevent connection storms
- Add pointer-specific peer removal (removePeerConn) to prevent orphaned
  goroutines from removing replacement connections
- Export BadgerBackupExecutor type for use by backup package
- Add /backup HTTP endpoint for on-demand backup triggers
- Bump version to 0.3.2
2026-02-27 21:59:49 -08:00
zeekay f8f75c732b chore: sync dependencies and format code 2026-02-04 15:47:51 -08:00
zeekay 32dba799bf chore: upgrade log to v1.4.1 and threshold to v1.5.5
- Upgrade github.com/luxfi/log to v1.4.1 for correct Level types
- Upgrade github.com/luxfi/threshold to v1.5.5 for log compatibility
- Upgrade github.com/luxfi/fhe to v1.7.6
2026-01-25 10:13:53 -08:00
zeekay f1754176c1 Add TFHE (Threshold Fully Homomorphic Encryption) support
- Add tfhe_session.go with TFHESession interface and implementations
- Add tfheKeygenSession for threshold FHE key generation
- Add tfheComputeSession for encrypted computation operations
- Add CreateTFHEKeyGenSession and CreateTFHEComputeSession to Node
- Add luxfi/fhe v1.7.5 dependency

TFHE enables:
- Encryption/decryption with threshold t-of-n
- Homomorphic computation on encrypted data
- Threshold RNG via T-Chain integration
- Privacy-preserving computation alongside MPC signing
2026-01-25 10:03:48 -08:00
zeekay efa0853421 Sync improvements from hanzoai/mpc
Features:
- Add FROST keygen and signing sessions for EdDSA/Taproot
- Add LSS keygen and signing sessions with dynamic resharing
- Add CBOR serialization for FROST and LSS configs (fix JSON corruption)
- Add recovery byte calculation for Ethereum compatibility
- Add FROST signing handler for EdDSA signatures
- Upgrade threshold library to v1.5.2

Security:
- Fix config serialization using CBOR instead of JSON
- Add security audit findings to LLM.md
- Document blockchain support matrix

Files added:
- frost_config_marshal.go, frost_keygen_session.go
- lss_config_marshal.go, keygen_session_lss.go
- signing_session_frost.go, signing_session_lss.go
- recovery.go, signing_handler_frost.go
2026-01-25 03:37:47 -08:00
zeekay 254da086d7 chore: update logger imports and dependencies 2026-01-25 03:34:15 -08:00
zeekay 8f3f43c612 chore: update LICENSE and go.mod 2025-12-31 22:21:37 -08:00
zeekay 770173969d merge: mpc-bump-hsm-airgap-2026-04-28 2025-12-28 20:10:00 -08:00
zeekay 42bdf6130a deps: bump luxfi/hsm v1.1.2 → v1.1.3 (airgap factory cases published)
luxfi/hsm v1.1.3 publishes the missing surface (AirgapTransport/Format,
plus coldcard/foundation/keystone/ngrave/gridplus/ledger/trezor signers
and pkcs11/yubihsm/nitrokey) that cmd/mpcd airgap_command.go was gated
on. The file-mediated ceremony orchestration stays as-is — Coldcard
microSD and BBQr/UR QR flows are the canonical product UX, not stubs.

What changes:
  cmd/mpcd/airgap_command.go      drop the v1.1.2 'gated downstream'
                                  caveat from package doc; the surface
                                  is published.
  cmd/mpcd/airgap_command_test.go new round-trip test that asserts every
                                  airgapProviders() name is constructible
                                  via hsm.NewSigner (catches rename drift
                                  or missing factory cases at `go test`,
                                  not at first ceremony).
2025-12-28 18:00:00 -08:00
zeekay c3d5a91dc1 chore: upgrade threshold to v1.1.11 (LSS livelock fix) 2025-12-28 17:14:28 -08:00
zeekay b4cd2d6109 feat(policy): re-point fhe_threshold_decryptor at canonical tfhe home
The phantom luxfi/fhe/threshold and luxfi/fhe/pkg/threshold APIs the
RealThresholdDecryptor referenced (FHECiphertext, FHEThresholdShare,
KeyShare, ShareAggregator, PartialDecrypter, ...) were never built.
The canonical home for threshold-FHE primitives is
luxfi/threshold/protocols/tfhe — one and only one place.

Repoint the import; add the local replace directive until
luxfi/threshold cuts a release tag containing the new committee
surface; pkg/policy now compiles and 7/7 RealThresholdDecryptor tests
pass.
2025-12-28 17:00:24 -08:00
zeekay 5403f97d6d feat(registry,attestation): trust + capability registry foundation
Build the GPU-runtime trust registry that gates every dispatch decision
against typed capability records and a deterministic attestation root.

Reference: LP-137-TRUST-REGISTRY.md.

pkg/registry:
  - types.go: WorkerCapability, NodeCapability, GPUArch, GPUBackend,
    PeerInterconnect with Validate() that enforces TEE-arch + attestation
    invariants at the API edge.
  - policy.go: LanePolicy (operator-controlled), WorkloadPolicy
    (per-request), and a single canonical Eligible(lane, workload, worker)
    check that runs twelve gates in fixed order. Privacy-class consistency
    is re-checked on the hot path so a stale worker record cannot bypass
    the API edge.

pkg/attestation:
  - composite.go: CompositeAttestation envelope over CPU TEE + GPU TEE +
    platform evidence. Root() is RFC 8949 §4.2 deterministic CBOR via
    fxamacker/cbor (already a direct dep) followed by SHA-256. The same
    encoder is used by Marshal so Root and the wire form agree byte-for-
    byte. Validate() rejects malformed envelopes including
    composite-trust-without-GPU-evidence.

Tests (103 pass): truth-table eligibility coverage, gate-ordering
regression, sensitivity-to-every-field digest, deterministic-bytes
round-trip, garbage-decode rejection.

go.mod: promote luxfi/lattice/v7 from indirect to direct require, add
local replace pointing at ../lattice (mirrors the existing fhe pattern).
Drop the replace once luxfi/lattice publishes a tag containing
types/trust.go.
2025-12-28 16:47:09 -08:00
zeekay 8f09d162a6 feat(policy): RealThresholdDecryptor wires committee to FHEVerifier
Implements the ThresholdDecryptor interface against the t-of-n
threshold-FHE service layer in luxfi/fhe/threshold.

RealThresholdDecryptor fans PartialDecrypt requests across configured
PartyClient peers, collects shares, and aggregates >=threshold valid
ones via the local ShareAggregator. The plaintext is rounded to a
boolean for the FHE policy verdict path.

Failure modes (insufficient quorum, peer errors, status non-OK) all
propagate as errors — the verifier wraps them as ErrFHEThresholdDec
and fails the policy gate closed.

go.mod adds a local replace for luxfi/fhe pending a release tag that
includes the threshold/ package.

Tests: 7/7 pass (2-of-3, 3-of-5, insufficient peers, two-peers-err
quorum-fail, one-peer-err quorum-pass, zero-threshold, roundToBool).
Full pkg/policy regression: 37/37 pass.
2025-12-28 16:40:32 -08:00
zeekay cda17a33dc deps: bump luxfi/hsm v1.1.1 → v1.1.2
v1.1.2 renames EnvProvider default env var from
LUX_MPC_PASSWORD to MPC_PASSWORD. The binary now reads the
canonical name used by the K8s operator injection.
2025-12-28 13:48:21 -08:00
zeekay cc52b14802 fix(mpc): R2-1/R2-2 — webauthn verification + CAS under Postgres
R2-1: biometric enrollment is a forged-enrollment oracle fixed.
- pkg/webauthn/verify.go: full WebAuthn verification — compare against the
  random challenge bytes we issued (not the DB row ID), origin allowlist,
  rpIDHash equality, UP+UV authenticator-flag enforcement, ceremony type.
- pkg/webauthn/liveness.go: SecureGate-signed liveness attestation. Ed25519
  envelope over {providerId, userId, score, timestamp, nonce}. MPC verifies
  against MPC_SECUREGATE_PUBKEY_ED25519 and enforces userId match, score
  floor, max age. Body-supplied livenessScore is never trusted again.
- If SecureGate pubkey is unconfigured, handleBiometricEnroll returns 503.
- 14 new tests cover each rejection path.

R2-2: CAS-under-Postgres. The previous in-Go check-then-write +
unconditional UPSERT works on SQLite (writeMu) but loses updates under
Postgres READ COMMITTED. Switched to SELECT ... FOR UPDATE inside READ
COMMITTED tx via orm.RunInTransactionWith + orm.GetForUpdate[T]. Requires
hanzoai/[email protected] (tagged today).
- Session consume: operationLimit strictly respected under concurrency;
  valueAccum computed under the lock.
- Operation approve: ApprovedBy append under the row lock, quorum
  finalization transitions at most once even under racing approvers.
- pkg/db.New now supports postgres:// DSNs.
- New Postgres-backed regression tests in cas_postgres_test.go —
  auto-skipped when no TEST_PG_DSN reachable; 10 concurrent consumers
  against operationLimit=5 yields exactly 5 successes and 5 denials.

Bumps github.com/hanzoai/orm v0.3.2 → v0.4.0.

Test plan:
  go test -tags sqlite_json1 -count=10 \
    -run 'CASUnderRace|CASUnderRace_Postgres|RequireRoleOrAPIPermission' \
    ./pkg/api/ ./pkg/webauthn/
2025-12-28 10:49:33 -08:00
zeekay 32b1f7f89c chore: exclude missing luxfi/genesis v1.5.21/22, sync edwards25519 replace 2025-12-28 10:03:12 -08:00
zeekay 0108d9a835 fix: lattice v7.0.2 — fresh tag, no stale proxy cache 2025-12-28 09:43:20 -08:00
zeekay 523e1adcfb fix: edwards25519 v0.1.0 (published go.mod), lattice direct-download hash
- luxfi/edwards25519 now has go.mod (v0.1.0 tag)
- Replace agl/ed25519 → luxfi/edwards25519 v0.1.0
- go.sum lattice hash matches GOPRIVATE direct download (not proxy)
2025-12-28 09:30:06 -08:00
zeekay 08ebe172ea fix: remove local replace directives — use published tagged versions only 2025-12-28 06:51:10 -08:00
zeekay 847ddebc2e fix: remove postgres/valkey/legacy mode — consensus+ZapDB only
- Removed --mode, --api-db, --api-kv, --db flags
- Removed legacy NATS/Consul transport (runNode, ~200 lines)
- Removed standalone API server (runAPIOnly, ~200 lines)
- Removed Consul helpers, NATS connection, interactive prompts
- Dashboard now uses ZapDB (SQLite) instead of postgres
- pkg/db: removed postgres backend, removed valkey client
- Consensus mode is the only mode. Zero external deps.
2025-12-28 06:18:03 -08:00
zeekay e6f3444f48 deps: luxfi/zapdb v4 → v1.0.0 (module path reset) 2025-12-28 05:25:05 -08:00