mirror of
https://github.com/hanzoai/mpc.git
synced 2026-10-30 19:45:28 +00:00
* ci: add id-token: write to caller permissions
Required for hanzoai/.github/.github/workflows/docker-build.yml@main —
without it the workflow_call dies as startup_failure with no jobs
dispatched. Caller permissions are a CEILING.
* go.mod: bump go directive to 1.26.3 (security advisory)
* deps: luxfi/crypto v1.19.0
* deps: luxfi/crypto v1.19.0; refresh stale checksums
* feat(landing): brand-neutral landing/dashboard with per-Host branding
The MPC binary now resolves its visible brand at request time from the
HTTP Host header, so a single image serves mpc.hanzo.ai as "Hanzo MPC",
mpc.lux.network as "Lux MPC", mpc.zoo.network as "Zoo MPC", and every
other host as a generic brand-free "MPC".
What changed:
- New pkg/landing/ subpackage with:
- brand.go: Brand{} struct + FromHost(host) helper + brandTable map
keyed on registered domain (hanzo.ai/lux.network/zoo.network).
Unknown hosts -> zero Brand -> generic page (no brand prefix, no
"Sign In with X ID" suffix, no IAM redirect).
- templates.go: html/template-backed landing/dashboard/auth-callback
HTML. Every visible brand-specific string flows through
{{.Brand.TitlePrefix}}, {{.Brand.SignInLabel}}, {{.Brand.IAMURL}},
{{.Brand.DocsURL}}, {{.Brand.SiteURL}}, {{.Brand.GitHubURL}}.
- landing.go: http.Handler that intercepts GET /, /dashboard,
/auth/callback and delegates everything else to the next handler.
Templates parsed once via sync.Once; per-request execution is
bytes.Buffer-based.
- brand_test.go: per-Host title/body assertions for hanzo.ai (Hanzo),
lux.network (Lux), zoo.network (Zoo), and an unknown host
(generic). Includes a delegation test that ensures unknown paths
fall through to next.
- cmd/mpcd/main.go: wrap apiServer.Handler() in landing.Handler() so
the marketing/dashboard pages render brand-aware while the canonical
/v1/* API surface (signing, keygen, wallets) is unchanged. Same Base
mount, same SQLite, same MPC backend wire protocol.
- cmd/mpcd/main.go: add the missing HasSigningQuorum(threshold) shim on
ConsensusPeerRegistry so the build keeps up with the recent luxfi/mpc
PeerRegistry interface addition (mirrors the consul registry).
No behavioral change to keygen/signing/reshare. /health, /healthz,
/keys, /backup, /keygen on the internal API port (9800) are untouched.
Verified locally:
$ go test ./pkg/landing/... -v
=== RUN TestFromHost --- PASS
=== RUN TestBrandHelpers --- PASS
=== RUN TestHandlerPerHostBranding --- PASS
=== RUN TestHandlerDelegatesUnknownPaths --- PASS
ok github.com/hanzoai/mpc/pkg/landing
To onboard a new white-label deployment, add one row to brandTable in
pkg/landing/brand.go and point its DNS at the cluster — no code change
beyond that table.
* docker: self-sufficient build (clone luxfi/mpc inside builder)
Restores compatibility with the canonical reusable workflow
`hanzoai/.github/.github/workflows/docker-build.yml@main`, which does
a single `actions/checkout@v4` at the workspace root with
`context: .`. The previous Dockerfile assumed the historical CI did
two checkouts and built from the parent dir.
The replace `github.com/luxfi/mpc => ../../lux/mpc` directive is now
satisfied inside the build by `git clone --depth=1 --branch=...
https://github.com/luxfi/mpc.git` into `/build/lux/mpc`, parallel to
`/build/hanzo/mpc` (the COPY of the build context).
Pin: `LUXFI_MPC_REF=v1.14.4` (latest released tag at time of write,
known to satisfy the PeerRegistry.HasSigningQuorum interface). Override
via `--build-arg LUXFI_MPC_REF=<tag>` when reproducibility matters.
78 lines
2.7 KiB
Go
78 lines
2.7 KiB
Go
// Package client — canonical client interface for Hanzo MPC.
|
|
//
|
|
// import mpc "github.com/hanzoai/mpc/client"
|
|
// var t mpc.Threshold = hanzomp.NewThreshold(cfg)
|
|
|
|
package client
|
|
|
|
import "context"
|
|
|
|
// Threshold is the compliance-gated threshold-signature surface.
|
|
// Every custody mutation (mint, burn, transfer, settle) signs through
|
|
// Threshold.Sign — there is no direct path to the MPC backend.
|
|
type Threshold interface {
|
|
// Kind reports the backend identifier
|
|
// (ta-cggmp21 | lit-protocol | fireblocks-mpc | coinbase-custody).
|
|
Kind() string
|
|
|
|
// Sign requests a threshold signature. The implementation applies its
|
|
// compliance ruleset before signing; rejections return an error whose
|
|
// kind names the gate (sanctions, velocity, blocklist, ...).
|
|
//
|
|
// IdempotencyKey is required. The implementation must coalesce repeat
|
|
// calls with the same key to one MPC session, and must verify the
|
|
// PayloadHash matches the cached session's payload before reusing it.
|
|
Sign(ctx context.Context, req SignRequest) (*SignResult, error)
|
|
|
|
// GetSession returns the current state of a signature session.
|
|
GetSession(ctx context.Context, sessionID string) (*SignSession, error)
|
|
|
|
// Cancel cancels a pending session. Idempotent on completed sessions.
|
|
Cancel(ctx context.Context, sessionID string) error
|
|
}
|
|
|
|
// SignRequest is the caller-side payload. Backends map to their protocols.
|
|
type SignRequest struct {
|
|
UserID, OrgID string
|
|
// Intent: settle_trade | swap_dex | mint | burn | withdraw |
|
|
// redeem | corporate_action.
|
|
Intent string
|
|
// WalletID is the provider_wallet_id from custody_wallets.
|
|
WalletID string
|
|
// Asset is the token symbol (BTC, USDL, ETH, ...).
|
|
Asset string
|
|
// Amount is the human-readable string. Backends parse to the asset's
|
|
// native decimals.
|
|
Amount string
|
|
// PayloadHash is the 32-byte hex of the tx payload. Signed verbatim.
|
|
PayloadHash string
|
|
// KeyType: secp256k1 | ed25519 | sr25519 | mldsa65.
|
|
KeyType string
|
|
// IdempotencyKey is required.
|
|
IdempotencyKey string
|
|
// TradeID is optional context for settle_trade.
|
|
TradeID string
|
|
}
|
|
|
|
// SignResult is the immediate response. Synchronous backends populate
|
|
// Signature; asynchronous backends return Status=pending + SessionID for
|
|
// later polling via GetSession.
|
|
type SignResult struct {
|
|
SessionID string
|
|
Signature []byte
|
|
Status string // pending | signed | rejected
|
|
ApprovalID string
|
|
}
|
|
|
|
// SignSession is the poll response.
|
|
type SignSession struct {
|
|
SessionID string
|
|
Status string // pending | signed | rejected | cancelled
|
|
Signature []byte
|
|
ApprovalID string
|
|
// Reason populated when Status=rejected. Values:
|
|
// sanctions | velocity | blocklist | manual_review |
|
|
// key_disabled | tenant_disabled.
|
|
Reason string
|
|
}
|