keyshare

package
v0.0.48 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyshareNotFound = errors.New("keyshare not found")
	ErrInvalidID        = errors.New("invalid ID")
	ErrInvalidKey       = errors.New("invalid encryption key")
	ErrDecryptionFailed = errors.New("decryption failed")
)

Functions

This section is empty.

Types

type Config added in v0.0.48

type Config struct {
	Keyshares     KeyshareStore
	PushCore      PushCoreClient
	CheckInterval time.Duration
	Logger        zerolog.Logger
}

Config holds configuration for the keyshare sweeper.

type KeyshareStore added in v0.0.48

type KeyshareStore interface {
	List() ([]string, error)
	Delete(id string) error
}

KeyshareStore is the subset of keyshare.Manager the sweeper depends on.

type Manager

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

Manager provides methods for storing and retrieving encrypted keyshares from files.

func NewManager

func NewManager(homeDir string, encryptionPassword string) (*Manager, error)

NewManager creates a new keyshare manager instance. homeDir: Base directory (e.g., $HOME/.puniversal) encryptionPassword: Password for encrypting/decrypting keyshares

func (*Manager) Delete added in v0.0.48

func (m *Manager) Delete(id string) error

Delete removes a stored keyshare. It overwrites the file with random bytes before unlinking; on SSD/COW filesystems that is best-effort, so the real protection remains the at-rest encryption. Deleting a missing ID is a no-op.

func (*Manager) Exists

func (m *Manager) Exists(id string) (bool, error)

Exists checks if a keyshare file exists for the given id.

func (*Manager) Get

func (m *Manager) Get(id string) ([]byte, error)

Get retrieves and decrypts a keyshare from a file. Returns the decrypted keyshare bytes.

func (*Manager) List added in v0.0.48

func (m *Manager) List() ([]string, error)

List returns the IDs of all stored keyshares.

func (*Manager) Store

func (m *Manager) Store(keyshareBytes []byte, id string) error

Store stores an encrypted keyshare as a file. keyshareBytes: Raw keyshare bytes from DKLS library id: Unique identifier (used as filename)

type PushCoreClient added in v0.0.48

type PushCoreClient interface {
	GetCurrentKey(ctx context.Context) (*utsstypes.TssKey, error)
	GetKeyByID(ctx context.Context, keyID string) (*utsstypes.TssKey, error)
}

PushCoreClient is the subset of pushcore.Client the sweeper depends on. Defined as an interface so tests can inject a mock. *pushcore.Client satisfies it.

type Sweeper added in v0.0.48

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

Sweeper deletes local keyshares that chain state proves are redundant.

A keyshare is deleted only when every one of these holds:

  • it is not the current key ID;
  • its TSS pubkey equals the current key's pubkey, i.e. a quorum change or key refresh superseded it while preserving the vault key.

Those two conditions are sufficient. The current key only changes when a key process finalizes, so while one is in flight the predecessor is still current and therefore never a deletion candidate. Fund migrations only exist across a pubkey rotation, so they can only reference a key this sweeper already keeps.

Shares whose pubkey differs from the current one are kept: they belong to a rotated-away key that fund migration still needs to sweep its vault. Retiring those is an explicit operator action, since a chain that was never migrated is indistinguishable from one with nothing to migrate.

Every chain-state lookup fails closed: on error the sweep is skipped and retried next tick rather than deleting on incomplete information. Pubkeys are resolved per held share rather than from the full key history, which grows unbounded and would need paging.

func NewSweeper added in v0.0.48

func NewSweeper(cfg Config) *Sweeper

NewSweeper creates a new keyshare sweeper.

func (*Sweeper) Start added in v0.0.48

func (s *Sweeper) Start(ctx context.Context)

Start begins the background sweep loop. Repeat calls are no-ops, so a restarted node cannot end up with two sweepers deleting concurrently.

Jump to

Keyboard shortcuts

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