backup

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DataProvidersThreshold = uint64(666)
View Source
const NormalizationConstant = 1000

Variables

View Source
var P = secp256k1.S256().N
View Source
var Zero = big.NewInt(0)

Functions

func BackupWallet

func BackupWallet(wallet *wallets.Wallet, providerPubKeys []*ecdsa.PublicKey, signingPolicyWeights []uint16, rewardEpochID uint32, teeID common.Address, normalizationParam uint16, dataProviderThreshold uint64) (*backup.WalletBackup, error)

BackupWallet packages the wallet state and encrypted key shares for admins and providers so it can be reconstructed later. The result is signed with the key that is split, but remains to be signed by the TEE.

func CheckKeyShares

func CheckKeyShares(splits []*backup.KeySplit, backupMetaData *backup.WalletBackupMetaData) error

CheckKeyShares validates that the provided key shares belong to the expected wallet backup metadata and originate from authorized parties.

func CombineShamirShares

func CombineShamirShares(shamirShares []backup.ShamirShare) (*big.Int, error)

CombineShamirShares joins shares assuming that the threshold is at exactly the length of the input.

func JoinKeyShares

func JoinKeyShares(splits []*backup.KeySplit, threshold uint64) (*ecdsa.PrivateKey, error)

JoinKeyShares joins key shares in a private key. It assumes that all the splits have the same backup id and the signatures have been verified.

func JoinPrivateKeys

func JoinPrivateKeys(privateKeys ...*ecdsa.PrivateKey) (*ecdsa.PrivateKey, error)

JoinPrivateKeys recombines additive key shares back into a single key.

func RecoverWallet

func RecoverWallet(
	keyShares []*backup.KeySplit,
	backupMetaData *backup.WalletBackupMetaData,
) (*wallets.Wallet, error)

RecoverWallet rebuilds a wallet from key shares and backup metadata.

func SplitAndEncrypt

func SplitAndEncrypt(
	key *ecdsa.PrivateKey,
	encryptionPubKeys []*ecdsa.PublicKey,
	threshold uint64,
	weights []uint16,
	backupID wallets.WalletBackupID,
	signer wallets.Signer,
	isAdmin bool,
) (*backup.EncryptedShares, error)

SplitAndEncrypt shards the provided private key, encrypts each share for its owner, and returns the encoded share bundle.

func SplitPrivateKey

func SplitPrivateKey(privateKey *ecdsa.PrivateKey, n int) ([]*ecdsa.PrivateKey, error)

SplitPrivateKey splits the private key into n additive shares in the curve field.

func SplitToShamirShares

func SplitToShamirShares(val *big.Int, numShares uint64, threshold uint64) ([]backup.ShamirShare, error)

SplitToShamirShares generates Shamir secret shares for the provided value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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