mirror of
https://github.com/luxfi/mpc.git
synced 2026-09-24 00:26:24 +00:00
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).
113 lines
5.1 KiB
Go
113 lines
5.1 KiB
Go
// Package approval provides ApprovalProvider — a pluggable interface for
|
|
// out-of-band executive approval of CanonicalIntents.
|
|
//
|
|
// Approvals are *separate* from MPC signing. The MPC nodes sign the actual
|
|
// chain transaction; ApprovalProvider attests that an authorized human (or
|
|
// authorized programmatic key) approved the intent before signing began.
|
|
//
|
|
// Why separate? An MPC quorum that both *authorizes* and *signs* is one
|
|
// compromise away from total custody loss. Out-of-band approvers (Ledger
|
|
// Enterprise, hardware-backed WebAuthn, KMS-held keys, Safe multisig) raise
|
|
// the bar to "compromise the MPC quorum AND the executive's distinct device".
|
|
//
|
|
// One way to wire approval:
|
|
//
|
|
// intent := intent.New(...)
|
|
// bundle, err := orchestrator.CollectApprovals(ctx, intent, approvers, threshold)
|
|
// // intent.SetApprovals(bundle); MPC signing only proceeds when
|
|
// // bundle has >= threshold valid signatures from required approvers.
|
|
package approval
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// CanonicalIntent is the contract surface this package needs from
|
|
// pkg/intent.CanonicalIntent. Anything that produces a stable digest and
|
|
// canonical bytes can be approved. We do not import pkg/intent here —
|
|
// that would create a coupling we don't need.
|
|
//
|
|
// pkg/intent.CanonicalIntent's concrete type satisfies this interface via
|
|
// method-set match; callers pass it directly.
|
|
type CanonicalIntent interface {
|
|
// Digest returns the canonical 32-byte hash committed to by approvers.
|
|
Digest() [32]byte
|
|
|
|
// Bytes returns the canonical serialized intent for re-derivation /
|
|
// audit. Approvers MUST verify Digest() == hash(Bytes()) before signing.
|
|
Bytes() []byte
|
|
}
|
|
|
|
// ApprovalProvider is the pluggable interface every approval backend
|
|
// implements. Implementations include cloud KMS, hardware HSMs (Ledger /
|
|
// YubiKey / Zymbit), WebAuthn passkeys, EVM Safes, and post-quantum signers.
|
|
//
|
|
// The provider does *not* manage MPC key shares. It manages an *approval*
|
|
// keypair owned by a specific approver (human executive or programmatic
|
|
// signer). Compromising this keypair compromises authorization decisions
|
|
// only — never the underlying MPC keys.
|
|
type ApprovalProvider interface {
|
|
// Provider returns the canonical name (e.g. "ledger-enterprise",
|
|
// "webauthn", "aws-kms"). Used in audit logs and the Approval registry.
|
|
Provider() string
|
|
|
|
// GetPublicIdentity returns the approver's PublicIdentity — the public
|
|
// material a verifier needs to validate approvals. ApproverID is the
|
|
// stable identifier (email/DID/owner-arn).
|
|
GetPublicIdentity(ctx context.Context, approverID string) (PublicIdentity, error)
|
|
|
|
// ApproveIntent produces an ApprovalSignature for the given intent.
|
|
// For interactive providers (Ledger device, WebAuthn) this BLOCKS until
|
|
// the user taps the device, or the context cancels.
|
|
ApproveIntent(ctx context.Context, approverID string, intent CanonicalIntent) (ApprovalSignature, error)
|
|
|
|
// VerifyApproval checks that sig was produced by approverID via this
|
|
// provider over the given intent. Returns false on signature mismatch,
|
|
// true on cryptographic match. Errors only on unrecoverable failures
|
|
// (network, malformed key) — a wrong signature is (false, nil).
|
|
VerifyApproval(ctx context.Context, intent CanonicalIntent, sig ApprovalSignature) (bool, error)
|
|
}
|
|
|
|
// PublicIdentity is the public-facing approver record stored in the keyset
|
|
// registry. ApproverID is the stable handle ("[email protected]", DID, KMS ARN);
|
|
// PublicKey + Algorithm let any verifier independently validate approvals.
|
|
//
|
|
// Attestation, when present, carries the vendor attestation chain (e.g.
|
|
// Ledger Live attestation, FIDO MDS metadata) — empty by default.
|
|
type PublicIdentity struct {
|
|
ApproverID string `json:"approver_id"`
|
|
Provider string `json:"provider"`
|
|
PublicKey []byte `json:"public_key"`
|
|
Algorithm string `json:"algorithm"`
|
|
Attestation []byte `json:"attestation,omitempty"`
|
|
}
|
|
|
|
// ApprovalSignature is the artifact attached to a CanonicalIntent. It binds
|
|
// (approverID, provider, intent_digest) under the approver's keypair so a
|
|
// later verifier can prove "this exact human approved this exact intent".
|
|
//
|
|
// Algorithm carries the signature scheme used so multi-algorithm bundles
|
|
// (mixed ECDSA / Ed25519 / ML-DSA) can be verified without external lookup.
|
|
type ApprovalSignature struct {
|
|
ApproverID string `json:"approver_id"`
|
|
Provider string `json:"provider"`
|
|
IntentDigest [32]byte `json:"intent_digest"`
|
|
Signature []byte `json:"signature"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Algorithm string `json:"algorithm"`
|
|
}
|
|
|
|
// Algorithm constants for ApprovalSignature.Algorithm and PublicIdentity.Algorithm.
|
|
//
|
|
// Use the named constants — never raw strings — so a typo at the call site
|
|
// becomes a compile error.
|
|
const (
|
|
AlgorithmECDSAP256 = "ECDSA-P256" // generic ECDSA secp256r1, SHA-256
|
|
AlgorithmECDSAsecp256k1 = "ECDSA-secp256k1" // Ethereum / Bitcoin signatures
|
|
AlgorithmEd25519 = "Ed25519"
|
|
AlgorithmMLDSA65 = "ML-DSA-65" // FIPS 204, NIST level 3
|
|
AlgorithmSafeContract = "Safe-execTransaction" // on-chain Safe approval
|
|
AlgorithmWebAuthnES256 = "WebAuthn-ES256" // CTAP2 ES256 (P-256)
|
|
)
|