backup

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WalletFromKeyDirectBackupPayload added in v0.0.21

func WalletFromKeyDirectBackupPayload(p *KeyDirectBackupPayload, privateKey []byte) (*wallets.Wallet, error)

WalletFromKeyDirectBackupPayload reconstructs a wallets.Wallet from a direct-backup payload. The caller decrypts EncryptedPrivateKey out-of-band (typically with the destination TEE's ECIES key) and passes the plaintext private-key bytes in. The decrypted public key must match BackupID.PublicKey. The resulting wallet is marked Restored with a zero status.

Types

type EncryptedShares

type EncryptedShares struct {
	Splits           []hexutil.Bytes
	OwnersPublicKeys []types.PublicKey
	Threshold        uint64
	PublicKey        hexutil.Bytes
	Weights          []uint16
}

func (*EncryptedShares) Check

func (e *EncryptedShares) Check() error

Check ensures the encrypted shares meet threshold and weighting requirements.

type KeyDirectBackupPayload added in v0.0.21

type KeyDirectBackupPayload struct {
	BackupID wallets.WalletBackupID `json:"backupId"`

	// EncryptedPrivateKey is ECIES(destinationPub, w.PrivateKey).
	EncryptedPrivateKey hexutil.Bytes `json:"encryptedPrivateKey"`

	AdminPublicKeys    []types.PublicKey `json:"adminPublicKeys"`
	AdminsThreshold    uint64            `json:"adminsThreshold"`
	Cosigners          []common.Address  `json:"cosigners"`
	CosignersThreshold uint64            `json:"cosignersThreshold"`

	SettingsVersion common.Hash   `json:"settingsVersion"`
	Settings        hexutil.Bytes `json:"settings"`

	Status wallets.WalletStatus `json:"status"`
}

KeyDirectBackupPayload is the JSON-serializable form of a wallet produced by KEY_DIRECT_BACKUP. BackupID identifies the wallet+key and binds it to the source TEE, the reward epoch, and a per-backup random nonce. EncryptedPrivateKey is ECIES under the destination's public key; the remaining wallet-configuration fields are plaintext and are covered by the source TEE's signature over the payload.

func NewKeyDirectBackupPayload added in v0.0.21

func NewKeyDirectBackupPayload(
	w *wallets.Wallet,
	sourceTeeID common.Address,
	encryptedPrivateKey hexutil.Bytes,
	rewardEpochID uint32,
	randomNonce common.Hash,
) (*KeyDirectBackupPayload, error)

NewKeyDirectBackupPayload assembles the wire-format direct-backup payload. The caller supplies encryptedPrivateKey (typically ECIES of w.PrivateKey under the destination's public key); the helper derives the secp256k1 public key for BackupID, copies slices defensively, and stamps the freshness markers. Only signing algorithms in wallets.Algos are supported.

type KeySplit

type KeySplit struct {
	KeySplitData
	Signature []byte
}

func DecryptSplit

func DecryptSplit(encryptedShare []byte, privKeyECDSA *ecdsa.PrivateKey, chainID uint64) (*KeySplit, error)

DecryptSplit decrypts an encrypted key split and verifies its integrity.

func (*KeySplit) VerifySignature

func (ks *KeySplit) VerifySignature(chainID uint64) error

VerifySignature checks that the key split signature matches the owner key.

type KeySplitData

type KeySplitData struct {
	Shares []ShamirShare
	PartialWalletBackupID
	OwnerPublicKey types.PublicKey
}

func (*KeySplitData) HashForSigning

func (ksd *KeySplitData) HashForSigning() (common.Hash, error)

HashForSigning computes the hash used when signing the key split data.

func (*KeySplitData) Sign

func (ksd *KeySplitData) Sign(signer wallets.Signer, chainID uint64) ([]byte, error)

Sign signs the key split data with the provided private key.

func (*KeySplitData) SignHash added in v0.0.21

func (ksd *KeySplitData) SignHash(chainID uint64) (common.Hash, error)

SignHash returns the domain-separated, chain-bound preimage signed for a key split: signing.Payload{csigning.PMWKeySplit, chainID, HashForSigning()}.Hash().

type PartialWalletBackupID

type PartialWalletBackupID struct {
	wallets.WalletBackupID
	PartialPubKey hexutil.Bytes
	IsAdmin       bool
}

func (*PartialWalletBackupID) Equal

type ShamirShare

type ShamirShare struct {
	X *big.Int
	Y *big.Int
}

func (*ShamirShare) ID

func (s *ShamirShare) ID() string

ID returns the string identifier for the Shamir share.

type WalletBackup

type WalletBackup struct {
	WalletBackupMetaData
	AdminEncryptedParts    *EncryptedShares
	ProviderEncryptedParts *EncryptedShares
	Signature              hexutil.Bytes
	TEESignature           hexutil.Bytes
}

func (*WalletBackup) Check

func (wb *WalletBackup) Check(chainID uint64) error

Check validates the metadata and share alignment in the wallet backup.

func (*WalletBackup) HashForSigning

func (wb *WalletBackup) HashForSigning() (common.Hash, error)

HashForSigning produces the hash over the wallet backup content.

func (*WalletBackup) OwnerSignHash added in v0.0.21

func (wb *WalletBackup) OwnerSignHash(chainID uint64) (common.Hash, error)

OwnerSignHash returns the domain-separated, chain-bound preimage signed by the wallet (owner) key over the backup: signing.Payload{csigning.PMWWalletBackup, chainID, HashForSigning()}.Hash().

func (*WalletBackup) TEESignHash added in v0.0.21

func (wb *WalletBackup) TEESignHash(chainID uint64) (common.Hash, error)

TEESignHash returns the domain-separated, chain-bound preimage signed by the TEE identity key over the backup: signing.Payload{csigning.TEEWalletBackup, chainID, HashForSigning()}.Hash().

type WalletBackupMetaData

type WalletBackupMetaData struct {
	wallets.WalletBackupID

	AdminsPublicKeys   []types.PublicKey
	AdminsThreshold    uint64
	ProvidersThreshold uint64
	Cosigners          []common.Address
	CosignersThreshold uint64
}

Jump to

Keyboard shortcuts

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