wallets

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EVMSignAlgo = utils.ToHash("keccak256-secp256k1-ecdsa")
View Source
var EVMType = utils.ToHash("EVM")
View Source
var VRFAlgo = utils.ToHash("keccak256-secp256k1-vrf")
View Source
var XRPSignAlgo = utils.ToHash("sha512half-secp256k1-ecdsa")
View Source
var XRPType = utils.ToHash("XRP")

Functions

func CheckKeyGenerate

func CheckKeyGenerate(newWalletRequest wallet.IWalletKeyManagerKeyGenerate, teeID common.Address) error

CheckKeyGenerate performs basic validation on the key generation request.

func ExtractKeyExistence

func ExtractKeyExistence(b []byte, teeID common.Address, chainID uint64) (*wallet.IWalletKeyManagerKeyExistence, error)

ExtractKeyExistence parses a signed existence proof from bytes and verifies the TEE signature against the canonical chain-bound preimage signing.Payload{TeeKeyExistenceTag, chainID, KeyExistenceDataHash(proof)}.Hash(). chainID must match the chain whose WalletKeyManagerFacet.confirmKey will recover the signer.

func GenerateKey

func GenerateKey(signingAlgo common.Hash) ([]byte, error)

GenerateKey creates a new private key for the signing algorithm.

func ParseKeyDataProviderRestore

func ParseKeyDataProviderRestore(instructionData *instruction.DataFixed) (wallet.IWalletBackupManagerKeyDataProviderRestore, error)

ParseKeyDataProviderRestore decodes the key data provider restore payload.

func ParseKeyDelete

func ParseKeyDelete(instructionData *instruction.DataFixed) (wallet.IWalletKeyManagerKeyDelete, error)

ParseKeyDelete decodes the key deletion instruction payload.

func ParseKeyDirectBackup added in v0.0.21

func ParseKeyDirectBackup(instructionData *instruction.DataFixed) (wallet.IWalletBackupManagerKeyDirectBackup, error)

ParseKeyDirectBackup decodes the key direct-backup instruction payload.

func ParseKeyDirectRestore added in v0.0.21

func ParseKeyDirectRestore(instructionData *instruction.DataFixed) (wallet.IWalletBackupManagerKeyDirectRestore, error)

ParseKeyDirectRestore decodes the key direct-restore instruction payload.

func ParseKeyGenerate

func ParseKeyGenerate(instructionData *instruction.DataFixed) (wallet.IWalletKeyManagerKeyGenerate, error)

ParseKeyGenerate decodes the key generation instruction payload.

func ToECDSAUnsafe

func ToECDSAUnsafe(sk []byte) *ecdsa.PrivateKey

ToECDSAUnsafe converts a private key from byte slice to *ecdsa.PrivateKey. Use only if you are sure that bytes represent a valid private key.

Based on go-ethereum's crypto.ToECDSAUnsafe.

func ValidateWalletMemberCounts added in v0.0.23

func ValidateWalletMemberCounts(adminCount, cosignerCount int) error

ValidateWalletMemberCounts enforces the maximum number of administrators and cosigners that may be associated with a wallet key.

func VerifySignature

func VerifySignature(msg, signature, publicKey []byte, signingAlgo common.Hash) error

VerifySignature checks that the signature over msg is valid for the given public key and signing algorithm.

Types

type KeyDataProviderRestoreResultStatus

type KeyDataProviderRestoreResultStatus struct {
	ErrorPositions []int
	ErrorLogs      []string
}

func NewKeyDataProviderRestoreResultStatus

func NewKeyDataProviderRestoreResultStatus() *KeyDataProviderRestoreResultStatus

NewKeyDataProviderRestoreResultStatus returns an empty restore result status tracker.

func (*KeyDataProviderRestoreResultStatus) AddError

func (s *KeyDataProviderRestoreResultStatus) AddError(i int, err error)

AddError records a decryption or validation error at the given signer index.

func (*KeyDataProviderRestoreResultStatus) Empty

Empty reports whether no errors were recorded.

type KeyIDPair

type KeyIDPair struct {
	WalletID common.Hash `json:"walletId"`
	KeyID    uint64      `json:"keyId"`
}

type SignedKeyExistenceProof

type SignedKeyExistenceProof struct {
	KeyExistence hexutil.Bytes `json:"keyExistence"`
	Signature    hexutil.Bytes `json:"signature"`
}

type Signer

type Signer interface {
	Sign([]byte) ([]byte, error)
}

type TEEBackupResponse

type TEEBackupResponse struct {
	BackupID     WalletBackupID `json:"backupId"`
	WalletBackup []byte         `json:"walletBackup"`
}

type Wallet

type Wallet struct {
	WalletID    common.Hash
	KeyID       uint64
	PrivateKey  []byte
	KeyType     common.Hash
	SigningAlgo common.Hash

	Restored bool

	AdminPublicKeys    []*ecdsa.PublicKey
	AdminsThreshold    uint64
	Cosigners          []common.Address
	CosignersThreshold uint64

	SettingsVersion common.Hash
	Settings        hexutil.Bytes

	Status *WalletStatus
}

Wallet is a struct carrying the private key of particular wallet. It should never be modified (apart from WalletStatus), after being created.

func GenerateNewKey

func GenerateNewKey(kg wallet.IWalletKeyManagerKeyGenerate) (*Wallet, error)

GenerateNewKey creates a wallet from the key generate instruction payload.

func (*Wallet) Copy

func (w *Wallet) Copy() *Wallet

Copy returns a deep copy of the wallet.

func (*Wallet) Decrypt

func (w *Wallet) Decrypt(cipher []byte) ([]byte, error)

Decrypt decrypts an encrypted message using the supplied private key based on type of key.

func (*Wallet) KeyExistenceProof

func (w *Wallet) KeyExistenceProof(teeID common.Address) *wallet.IWalletKeyManagerKeyExistence

KeyExistenceProof builds a key existence proof for the wallet.

func (*Wallet) Sign

func (w *Wallet) Sign(msg []byte) ([]byte, error)

Sign returns a cryptographic signature of the message using the wallet's signing algorithm.

type WalletBackupID

type WalletBackupID struct {
	TeeID     common.Address `json:"teeId"`
	WalletID  common.Hash    `json:"walletId"`
	KeyID     uint64         `json:"keyId"`
	PublicKey hexutil.Bytes  `json:"publicKey"`

	KeyType       common.Hash `json:"keyType"`
	SigningAlgo   common.Hash `json:"signingAlgo"`
	RewardEpochID uint32      `json:"rewardEpochId"`
	RandomNonce   common.Hash `json:"randomNonce"`
}

func (*WalletBackupID) Equal

func (wid *WalletBackupID) Equal(w *WalletBackupID) error

Equal checks if two wallet backup identifiers are equal.

func (*WalletBackupID) Hash

func (wid *WalletBackupID) Hash() (common.Hash, error)

Hash returns the keccak hash of the wallet backup identifier.

type WalletStatus

type WalletStatus struct {
	Nonce        uint64
	PausingNonce common.Hash
	StatusCode   uint8
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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