mpc

package
v1.23.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultInstanceTypes

func DefaultInstanceTypes() map[CloudProvider]string

DefaultInstanceTypes returns recommended instance types per provider.

func DefaultRegions

func DefaultRegions() map[CloudProvider]string

DefaultRegions returns default regions per provider.

Types

type BackupManager

type BackupManager struct {
	// contains filtered or unexported fields
}

BackupManager handles MPC node backups.

func NewBackupManager

func NewBackupManager(store storage.Storage, basePath, nodeID, nodeName, network string) *BackupManager

NewBackupManager creates a new backup manager.

func (*BackupManager) CreateBackup

func (bm *BackupManager) CreateBackup(ctx context.Context, dbPath string, opts *BackupOptions) (*BackupManifest, error)

CreateBackup creates a backup of the MPC node's BadgerDB.

func (*BackupManager) DeleteBackup

func (bm *BackupManager) DeleteBackup(ctx context.Context, backupName string) error

DeleteBackup removes a backup.

func (*BackupManager) ListBackups

func (bm *BackupManager) ListBackups(ctx context.Context) ([]BackupManifest, error)

ListBackups lists available backups.

func (*BackupManager) RestoreBackup

func (bm *BackupManager) RestoreBackup(ctx context.Context, backupName string, opts *RestoreOptions) error

RestoreBackup restores from a backup.

type BackupManifest

type BackupManifest struct {
	Version       string            `json:"version"`
	NodeID        string            `json:"nodeId"`
	NodeName      string            `json:"nodeName"`
	Network       string            `json:"network"`
	Timestamp     time.Time         `json:"timestamp"`
	Checksums     map[string]string `json:"checksums"`
	DatabaseType  string            `json:"databaseType"` // badgerdb
	Incremental   bool              `json:"incremental"`
	BaseVersion   uint64            `json:"baseVersion,omitempty"`
	LatestVersion uint64            `json:"latestVersion"`
	WalletCount   int               `json:"walletCount"`
	KeyCount      int               `json:"keyCount"`
	Encryption    *EncryptionInfo   `json:"encryption,omitempty"`
	Metadata      map[string]string `json:"metadata,omitempty"`
}

BackupManifest contains metadata about an MPC backup.

type BackupOptions

type BackupOptions struct {
	// Incremental creates a delta backup from the last version
	Incremental bool
	// BaseVersion for incremental backups
	BaseVersion uint64
	// Compression algorithm (zstd, gzip, none)
	Compression string
	// CompressionLevel (1-19 for zstd, 1-9 for gzip)
	CompressionLevel int
	// Encryption settings
	Encryption *EncryptionInfo
	// AgeRecipients for age encryption
	AgeRecipients []string
	// ChunkSize for splitting large backups (default 99MB for GitHub)
	ChunkSize int64
	// ProgressFunc reports backup progress
	ProgressFunc func(stage string, current, total int64)
	// Metadata to include in manifest
	Metadata map[string]string
}

BackupOptions configures backup behavior.

type CloudProvider

type CloudProvider string

CloudProvider represents a cloud provider type.

const (
	CloudProviderLocal        CloudProvider = "local"
	CloudProviderAWS          CloudProvider = "aws"
	CloudProviderGCP          CloudProvider = "gcp"
	CloudProviderAzure        CloudProvider = "azure"
	CloudProviderDigitalOcean CloudProvider = "digitalocean"
)

type DeploymentConfig

type DeploymentConfig struct {
	Provider     CloudProvider `json:"provider"`
	Region       string        `json:"region"`
	InstanceType string        `json:"instanceType"`
	SSHKeyPath   string        `json:"sshKeyPath"`
	SSHKeyName   string        `json:"sshKeyName"`
	SSHUser      string        `json:"sshUser"`

	// AWS specific
	AWSProfile       string `json:"awsProfile,omitempty"`
	AWSSecurityGroup string `json:"awsSecurityGroup,omitempty"`
	AWSVPC           string `json:"awsVpc,omitempty"`
	AWSSubnet        string `json:"awsSubnet,omitempty"`

	// GCP specific
	GCPProject string `json:"gcpProject,omitempty"`
	GCPZone    string `json:"gcpZone,omitempty"`
	GCPNetwork string `json:"gcpNetwork,omitempty"`

	// Azure specific
	AzureSubscription  string `json:"azureSubscription,omitempty"`
	AzureResourceGroup string `json:"azureResourceGroup,omitempty"`

	// DigitalOcean specific
	DOToken   string `json:"doToken,omitempty"`
	DOSSHKeys []int  `json:"doSshKeys,omitempty"`
}

DeploymentConfig holds cloud deployment configuration.

type DeploymentManager

type DeploymentManager struct {
	// contains filtered or unexported fields
}

DeploymentManager manages MPC node deployments to cloud providers.

func NewDeploymentManager

func NewDeploymentManager(baseDir string) *DeploymentManager

NewDeploymentManager creates a new deployment manager.

func (*DeploymentManager) BackupRemoteNode

func (d *DeploymentManager) BackupRemoteNode(ctx context.Context, networkName, nodeName, destination string) error

BackupRemoteNode creates a backup of a remote node and uploads to cloud storage.

func (*DeploymentManager) ConnectToNode

func (d *DeploymentManager) ConnectToNode(ctx context.Context, networkName, nodeName string) (*models.Host, error)

ConnectToNode establishes SSH connection to a remote node.

func (*DeploymentManager) DeployNetwork

func (d *DeploymentManager) DeployNetwork(ctx context.Context, networkName string, cfg *DeploymentConfig) (*RemoteNetworkConfig, error)

DeployNetwork deploys an MPC network to cloud infrastructure.

func (*DeploymentManager) GetRemoteNodeStatus

func (d *DeploymentManager) GetRemoteNodeStatus(ctx context.Context, networkName, nodeName string) (*NodeInfo, error)

GetRemoteNodeStatus gets the status of a remote MPC node.

func (*DeploymentManager) LoadDeploymentConfig

func (d *DeploymentManager) LoadDeploymentConfig(networkName string) (*RemoteNetworkConfig, error)

LoadDeploymentConfig loads deployment configuration from disk.

func (*DeploymentManager) RunCommandOnNode

func (d *DeploymentManager) RunCommandOnNode(ctx context.Context, host *models.Host, command string, timeout time.Duration) ([]byte, error)

RunCommandOnNode runs a command on a remote MPC node via SSH.

func (*DeploymentManager) StartRemoteNode

func (d *DeploymentManager) StartRemoteNode(ctx context.Context, networkName, nodeName string) error

StartRemoteNode starts an MPC node on a remote server.

func (*DeploymentManager) StopRemoteNode

func (d *DeploymentManager) StopRemoteNode(ctx context.Context, networkName, nodeName string) error

StopRemoteNode stops an MPC node on a remote server.

func (*DeploymentManager) UnlockNodeKeys

func (d *DeploymentManager) UnlockNodeKeys(ctx context.Context, networkName, nodeName string, ageIdentityPath string) error

UnlockNodeKeys unlocks encrypted keys on a remote node. Keys are encrypted with age and stored in ~/.lux/keys/mpc/ The identity file (private key) is needed to decrypt.

type EncryptionInfo

type EncryptionInfo struct {
	Algorithm  string   `json:"algorithm"` // age, gpg, aes-256-gcm
	KeyID      string   `json:"keyId,omitempty"`
	Recipients []string `json:"recipients,omitempty"`
}

EncryptionInfo describes how the backup is encrypted.

type NetworkConfig

type NetworkConfig struct {
	NetworkID   string        `json:"networkId"`
	NetworkName string        `json:"networkName"`
	NetworkType string        `json:"networkType"` // mainnet, testnet, devnet
	Threshold   int           `json:"threshold"`   // t in t-of-n
	TotalNodes  int           `json:"totalNodes"`  // n in t-of-n
	Nodes       []*NodeConfig `json:"nodes"`
	Created     time.Time     `json:"created"`
	BaseDir     string        `json:"baseDir"`
}

NetworkConfig holds configuration for an MPC network.

type NodeConfig

type NodeConfig struct {
	NodeID     string    `json:"nodeId"`
	NodeName   string    `json:"nodeName"`
	NodeIndex  int       `json:"nodeIndex"`  // 0-based index in the MPC network
	Threshold  int       `json:"threshold"`  // t in t-of-n threshold signing
	TotalNodes int       `json:"totalNodes"` // n in t-of-n
	Network    string    `json:"network"`    // mainnet, testnet, devnet
	ListenAddr string    `json:"listenAddr"` // gRPC listen address
	P2PPort    int       `json:"p2pPort"`    // P2P communication port
	APIPort    int       `json:"apiPort"`    // API/gRPC port
	Peers      []string  `json:"peers"`      // Other MPC node addresses
	DataDir    string    `json:"dataDir"`    // Data directory
	KeysDir    string    `json:"keysDir"`    // Encrypted keys directory
	LogLevel   string    `json:"logLevel"`
	Created    time.Time `json:"created"`
}

NodeConfig holds configuration for an MPC node.

type NodeInfo

type NodeInfo struct {
	Config    *NodeConfig `json:"config"`
	Status    NodeStatus  `json:"status"`
	PID       int         `json:"pid,omitempty"`
	Uptime    string      `json:"uptime,omitempty"`
	StartTime time.Time   `json:"startTime,omitempty"`
	Endpoint  string      `json:"endpoint,omitempty"`
	Error     string      `json:"error,omitempty"`
}

NodeInfo contains runtime information about an MPC node.

type NodeManager

type NodeManager struct {
	// contains filtered or unexported fields
}

NodeManager manages MPC node lifecycle.

func NewNodeManager

func NewNodeManager(baseDir string) *NodeManager

NewNodeManager creates a new node manager.

func (*NodeManager) BaseDir

func (m *NodeManager) BaseDir() string

BaseDir returns the base directory for MPC data.

func (*NodeManager) DeleteNetwork

func (m *NodeManager) DeleteNetwork(ctx context.Context, networkName string, force bool) error

DeleteNetwork removes an MPC network and all its data.

func (*NodeManager) GetNetworkStatus

func (m *NodeManager) GetNetworkStatus(networkName string) ([]*NodeInfo, error)

GetNetworkStatus returns the status of all nodes in a network.

func (*NodeManager) GetNodeStatus

func (m *NodeManager) GetNodeStatus(nodeName string) (*NodeInfo, error)

GetNodeStatus returns the status of a single node.

func (*NodeManager) InitNetwork

func (m *NodeManager) InitNetwork(ctx context.Context, networkType string, threshold, totalNodes int) (*NetworkConfig, error)

InitNetwork initializes a new MPC network with the specified configuration.

func (*NodeManager) ListNetworks

func (m *NodeManager) ListNetworks() ([]*NetworkConfig, error)

ListNetworks returns all MPC networks.

func (*NodeManager) LoadNetworkConfig

func (m *NodeManager) LoadNetworkConfig(networkName string) (*NetworkConfig, error)

LoadNetworkConfig loads a network configuration from disk.

func (*NodeManager) StartNetwork

func (m *NodeManager) StartNetwork(ctx context.Context, networkName string) error

StartNetwork starts all nodes in an MPC network.

func (*NodeManager) StartNode

func (m *NodeManager) StartNode(ctx context.Context, cfg *NodeConfig) error

StartNode starts a single MPC node.

func (*NodeManager) StopNetwork

func (m *NodeManager) StopNetwork(ctx context.Context, networkName string) error

StopNetwork stops all nodes in an MPC network.

func (*NodeManager) StopNode

func (m *NodeManager) StopNode(ctx context.Context, nodeName string) error

StopNode stops a single MPC node.

type NodeStatus

type NodeStatus string

NodeStatus represents the current state of an MPC node.

const (
	NodeStatusStopped  NodeStatus = "stopped"
	NodeStatusStarting NodeStatus = "starting"
	NodeStatusRunning  NodeStatus = "running"
	NodeStatusError    NodeStatus = "error"
)

type RemoteNetworkConfig

type RemoteNetworkConfig struct {
	NetworkConfig *NetworkConfig    `json:"networkConfig"`
	Deployment    *DeploymentConfig `json:"deployment"`
	Nodes         []*RemoteNode     `json:"nodes"`
	DeployedAt    time.Time         `json:"deployedAt"`
}

RemoteNetworkConfig holds configuration for a deployed MPC network.

type RemoteNode

type RemoteNode struct {
	NodeConfig   *NodeConfig   `json:"nodeConfig"`
	Host         *models.Host  `json:"host"`
	Provider     CloudProvider `json:"provider"`
	InstanceID   string        `json:"instanceId"`
	PublicIP     string        `json:"publicIp"`
	PrivateIP    string        `json:"privateIp"`
	Region       string        `json:"region"`
	DeployedAt   time.Time     `json:"deployedAt"`
	Status       NodeStatus    `json:"status"`
	KeyEncrypted bool          `json:"keyEncrypted"`
}

RemoteNode represents a deployed MPC node.

type RestoreOptions

type RestoreOptions struct {
	// TargetPath to restore to (default: original location)
	TargetPath string
	// AgeIdentities for decryption
	AgeIdentities []string
	// VerifyOnly checks integrity without restoring
	VerifyOnly bool
	// ProgressFunc reports restore progress
	ProgressFunc func(stage string, current, total int64)
}

RestoreOptions configures restore behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL