Commit Graph
29 Commits
Author SHA1 Message Date
zeekay 82bd565201 mpc: deployment-mode flag + audit dispatcher for fund-private clusters
Adds the topology contract that lets a fund run mpcd as its own private
cluster — no Lux primary network registration, no shared M-Chain audit
ledger — using the same code path and the same operator surface.

Mode flag at cmd/mpcd/main.go:
  --network=primary|private              # registration target
  --audit-store=mchain|local-worm|...    # audit log destination
  --registrar-url, --registrar-auth      # primary-mode announcement
  --audit-worm-path, --audit-mchain-url  # backend selectors

pkg/audit:
  - Append-only Merkle hash chain. Tampering with any historical event
    invalidates every subsequent hash. Canonical bytes use fixed-order
    concatenation (json.Marshal map ordering is non-deterministic).
  - WORMDispatcher: NDJSON append, replay-on-start, fsync per Append.
  - MChainDispatcher: batched POST of (batchHash, fromSeq, toSeq) to a
    configurable anchor RPC.
  - compositeDispatcher: fan-out to multiple legs with per-leg sealing.
  - S3 Glacier Vault / Azure Immutable / GCS Object Lock dispatchers
    fail closed — wired into the flag surface but gated behind the
    cloud-audit build tag, no silent fallback.

pkg/identity/bootstrap.go: identity creation + (primary-mode only)
registrar announcement. Same on-disk format as the previous
loadOrGenerateIdentity (which is now removed); private mode is silent.

deployments/k8s-private: fund-only Kustomize overlay. Standalone
namespace, NetworkPolicy that blocks egress to anything outside the
fund's VPC, hardware-WORM PVC for the audit log, KMS-driven secret
template.

deployments/k8s-primary: env-var patch overlay on the existing lux-mpc
base. composite(local-worm,mchain) by default.

deployments/terraform/{aws,gcp,azure}: VPC + audit storage modules.
terraform validate passes; EKS/GKE/AKS + HSM modules are stubbed and
not yet plan-tested.

deployments/onprem/README.md: WORM storage + PKCS#11 HSM checklist.

Tests (14 total, all passing):
  pkg/audit:           6/6  (chain, WORM replay, MChain batching, composite,
                             cloud stubs fail loud, double-seal rejected)
  pkg/identity:        4/4  (private no-call, primary call, primary empty
                             URL no-op, primary registrar 503 surfaces)
  internal/privatemode: 4/4 (no registrar traffic, restart, tamper-detect,
                             cloud stubs fail loud)

Companion runbook in lux/papers/lux-private-mpc-deployment/
(LaTeX, 5 pages, tectonic-clean).
2025-12-28 16:20:40 -08:00
zeekay de7c8a76e2 mpc: per-node policy gate for non-bypassable signing
CanonicalIntent + LocalVerifier + SignGate. The MPC node signs only
if it independently verifies the policy bundle. Closes the bypassable
single point of failure where each node trusted the coordinator.

pkg/intent: CBOR-encoded intent, RFC 8949 Sec 4.2 deterministic
encoding. Approvals + node attestations excluded from digest.

pkg/policy/local_verifier: six-check gate (wallet, expiry, policy
hash, approval threshold, allowlist+limits, risk). Fails CLOSED.
Signed NodeAttestation for both approve and reject.

pkg/risk: Provider interface. InternalAllowlist (always available),
Chainalysis HTTP client + httptest coverage, TRM/Elliptic NOTIMPL
with documented endpoint shapes. CompositeProvider AND/OR.

pkg/mpc/sign_orchestrator: SignGate wraps verifier as
protocol-agnostic gate. AuthorizeSign returns ErrSignBlocked wrapping
the cause. AuthorizeAndDigest returns the digest the threshold
scheme must sign over.

e2e/policy_gate_test (tag policygate; pre-existing zapdb break) +
pkg/mpc/sign_orchestrator_e2e_test (runs in normal test suite):
3-node simulation proves non-bypassable.

56 tests, 4 packages, all passing.

go.sum: corrects luxfi/edwards25519 v0.1.0 /go.mod hash.
2025-12-28 16:07:25 -08:00
zeekay ff662c2c42 wallet: 9-tier wallet architecture as first-class concept
Add pkg/wallet implementing the 9-tier model (hot, warm, cold, gas,
bridge, contract_admin, validator, quarantine, disaster_recovery) with
canonical TierPolicy, in-memory Registry, domain-separation enforcement,
and per-wallet velocity/daily counters.

Domain separation rejects (cloud_provider, account) collisions and
HSM-provider collisions; cold + DR demand 3+ distinct cloud and HSM
vendors. Hot/warm/bridge/contract_admin demand 2+. Gas tier disables
the check (low value, allowlisted only).

Sign dispatch in pkg/api/handlers_wallet.go routes per tier:
quarantine rejects unconditionally; over-cap rejects with usage view;
airgapped tiers (cold, DR) return airgapped_queued; timelocked tiers
return timelocked with end-time; auto-approval tiers (hot, gas, bridge,
validator) commit counters and return auto_approved when amount is
under the large-amount escalation threshold; remainder return
approval_required with HumanApprovalsMin (or HumanApprovalsLarge above
threshold).

Routes mounted at /v1/wallet (no /api/ prefix per house rule).

Tests:
- pkg/wallet/tier_test.go: 16/16 pass
- e2e/tier_lifecycle_test.go: 9/9 pass
2025-12-28 15:54:10 -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 e6f3444f48 deps: luxfi/zapdb v4 → v1.0.0 (module path reset) 2025-12-28 05:25:05 -08:00
zeekay 4206af599f fix: use badger API directly in e2e test instead of kvstore.Store
CheckKeyInAllNodes was assigning *badger.DB to kvstore.Store.DB which
requires database.Database — badger.DB is missing the Compact method.
The test only needs Get and Close, so use badger.View/txn.Get directly.
2025-12-28 02:06:25 -08:00
zeekay 9c5308750d fix: rename env vars to MPC_PASSWORD, remove LUX_ prefix
- Default env var: MPC_PASSWORD (was LUX_MPC_PASSWORD)
- No fallback to ZAPDB_PASSWORD — single source
- Factory env_var config reads from config map only (not env)
- Cloud HSM providers unchanged (ZAPDB_ENCRYPTED_PASSWORD)
- All tests pass
2025-12-28 00:40:20 -08:00
zeekay 6223351edf chore: sync local changes 2025-12-28 00:33:42 -08:00
zeekay e40f0b6dff fix: goimports formatting with local-prefixes (matches golangci-lint) 2025-12-27 23:14:14 -08:00
zeekay 3954d11f50 fix: goimports formatting + CGO_ENABLED=0 for CI tests
- Run goimports -w on all 17 Go files with formatting issues
- Set CGO_ENABLED=0 on all CI steps (test, lint, build, CodeQL, SBOM)
- Remove -race flag from tests (requires CGO which pulls in blst.h)
- All 17 test packages pass with CGO_ENABLED=0
2025-12-27 23:01:00 -08:00
zeekay 0d7a523c3e security: add orgID multi-tenancy isolation, rename badger to zapdb
Multi-tenancy isolation (addresses Dragonfire review MPC audit):
- Add OrgID field to all event messages (keygen, sign, reshare)
- Scope session dedup keys as orgID-walletID-txID
- Namespace KVStore keys with org prefix (org:<orgID>:<key>)
- Backward-compatible fallback to legacy unscoped keys
- New org_kvstore.go with OrgScopedKey/GetKeyShareWithFallback

Naming cleanup:
- Rename all badger references to zapdb in code, config, tests
- config.yaml: badger_password → zapdb_password
- AppConfig: BadgerPassword → ZapDBPassword
- Fix MPCiumVersion typo → MPCVersion
2025-12-27 22:41:08 -08:00
zeekay b143c542e4 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.
2025-12-27 21:41:32 -08:00
zeekay 24eca78736 chore: bump Go 1.26.0 → 1.26.1
Fixes 5 stdlib CVEs (html/template, os, net/url, crypto/x509 x2).
2025-12-27 13:05:01 -08:00
zeekay 7cfc8e9874 chore(e2e): use real semver tag v1.0.5, remove local path replace
e2e now references github.com/luxfi/mpc v1.0.5 (semantic tag).
Local resolution handled by go.work workspace, not replace directive.
Only remaining replace is agl/ed25519 → luxfi/edwards25519 (broken upstream).
2025-12-27 17:03:24 -08:00
zeekay ccb91d25e0 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)
2025-12-27 16:56:47 -08:00
zeekay d73d4876e1 refactor(kvstore): rename Badger→ZapDB types, clean up package API
- git mv 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 fields: DBPath→Path, EncryptionKey→Key, BackupEncryptionKey→BackupKey, BackupDir→Dir
- Backup fields: BackupEncryptionKey→Key, BackupDir→Dir
- Store fields: BackupExecutor→Exec, db→DB (exported, fixes e2e compile)
- Updated all callers: transport/factory, transport/state, backup/s3,
  cmd/mpcd/main, cmd/lux-mpc-cli/recovery, scripts/migration/add-key-type,
  e2e/base_test, pkg/kvstore/backup_test
2025-12-27 16:23:40 -08:00
zeekay 7fd512051e 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)
2025-12-27 15:30:42 -08:00
zeekay 33c08f435d chore: sync dependencies and format code 2025-12-27 09:26:29 -08:00
zeekay 6c1e9138ca chore: update logger imports and dependencies 2025-12-27 09:00:00 -08:00
zeekay 8f3f43c612 chore: update LICENSE and go.mod 2025-12-31 22:21:37 -08:00
zeekay c3d5a91dc1 chore: upgrade threshold to v1.1.11 (LSS livelock fix) 2025-12-28 17:14:28 -08:00
zeekay 821bd09da5 chore: remove bridge stub, fix all TODOs with real implementations
- Remove lux-mpc-bridge command (bridge is in T-Chain, not MPC)
- Remove empty pkg/bridge directory
- Fix sign.go: remove stale TODO (ECDSA/EdDSA already supported)
- Fix pubsub.go: remove obsolete subscription TODO
- Fix benchmark_test.go: implement real protocol benchmarks
- Fix xrpl_test.go: implement full XRPL E2E tests
- Update goreleaser: remove bridge build target
- Update docker-compose: remove bridge-compat services

MPC is now a clean standalone threshold signature tool.
2025-12-25 10:44:16 -08:00
zeekay 8952776a9b fix: format imports with goimports
- Fix import formatting in all files
- Ensure consistent import grouping
- Resolve golangci-lint formatting issues
2025-08-17 00:00:28 -05:00
zeekay 98421eb533 fix: update dependencies and fix e2e test issues
- Fixed shell script compatibility for macOS
- Updated e2e module dependencies
- Simplified benchmark tests
- Fixed KMS client build
2025-08-16 13:12:25 -05:00
zeekay e89da4d563 Update examples 2025-08-07 10:55:10 -05:00
zeekay 83969bc35e feat: Complete migration to luxfi/threshold library
Major changes:
- Replaced Binance TSS library with luxfi/threshold (supports CGGMP21 & FROST)
- Added XRPL network support for secp256k1 signatures
- Implemented resharing functionality for both ECDSA and EdDSA
- Fixed protocol adapters for CGGMP21 and FROST
- Updated event consumer to use new node methods
- Fixed all build errors in core packages

Technical improvements:
- Simplified party.ID usage (now string-based)
- Added proper message types and encoding
- Updated session interfaces with required methods
- Fixed test suite to work with new library structure

All core package tests passing. Ready for mainnet deployment.
2025-08-02 20:49:39 -05:00
zeekay 0b8661ced9 Use new threshold lib 2025-08-02 15:49:26 -05:00
zeekay 4ec50522c9 Add benchmarks, tests, updated docs 2025-08-02 15:27:50 -05:00
CodyandGitHub c6e2c3c06f Add integration, unit testing CI pipelines (#48)
* Add comprehensive tests for multiple pkg

* Add db_path to config

* Add e2e testing pipeline

* Add github workflow

* Remove config.test.yaml

* Fix lint issue

* Increase timeout

* Add e2e testing for signing

* Skip signing if node is not in participant list

* Code cleanup

* Add e2e testing for signing and resharing

* Increase timeout

* Add test instructions

* Update github workflow branching

* Add vulnerabilties check in CI

* Fix ci
2025-07-06 14:26:03 +07:00