wallets

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 17 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 ErrWalletNonExistent = errors.New("wallet non-existent")
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.ITeeWalletKeyManagerKeyGenerate, teeID common.Address) error

CheckKeyGenerate performs basic validation on the key generation request.

func ExtractKeyExistence

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

ExtractKeyExistence parses a signed existence proof from bytes.

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.ITeeWalletBackupManagerKeyDataProviderRestore, error)

ParseKeyDataProviderRestore decodes the key data provider restore payload.

func ParseKeyDelete

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

ParseKeyDelete decodes the key deletion instruction payload.

func ParseKeyGenerate

func ParseKeyGenerate(instructionData *instruction.DataFixed) (wallet.ITeeWalletKeyManagerKeyGenerate, 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 VerifySignature

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

Types

type KeyDataProviderRestoreResultStatus

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

func NewKeyDataProviderRestoreResultStatus

func NewKeyDataProviderRestoreResultStatus() *KeyDataProviderRestoreResultStatus

func (*KeyDataProviderRestoreResultStatus) AddError

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

func (*KeyDataProviderRestoreResultStatus) Empty

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 Storage

type Storage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func InitializeStorage

func InitializeStorage() *Storage

InitializeStorage returns an empty wallet storage instance.

func (*Storage) CheckNonce

func (s *Storage) CheckNonce(idPair KeyIDPair, nonce uint64) error

CheckNonce ensures the provided nonce is newer than the stored one.

s.RWMutex RLock should be used when calling this method.

func (*Storage) Get

func (s *Storage) Get(idPair KeyIDPair) (*Wallet, error)

Get retrieves a copy of the wallet or returns ErrWalletNonExistent.

s.RWMutex RLock should be used when calling this method.

func (*Storage) GetWallets

func (s *Storage) GetWallets() []*Wallet

GetWallets returns deep copies of all stored wallets.

s.RWMutex RLock should be used when calling this method.

func (*Storage) Nonce

func (s *Storage) Nonce(idPair KeyIDPair) (uint64, error)

Nonce returns the stored nonce for the wallet.

s.RWMutex RLock should be used when calling this method.

func (*Storage) Remove

func (s *Storage) Remove(idPair KeyIDPair) bool

Remove deletes the wallet entry for the given identifier pair.

s.RWMutex Lock should be used when calling this method.

func (*Storage) Store

func (s *Storage) Store(wallet *Wallet) error

Store adds the wallet to storage while preserving status state.

s.RWMutex Lock should be used when calling this method.

func (*Storage) UpdateNonce

func (s *Storage) UpdateNonce(idPair KeyIDPair, nonce uint64)

UpdateNonce sets the wallet's nonce to the provided value.

s.RWMutex Lock should be used when calling this method.

func (*Storage) WalletExists

func (s *Storage) WalletExists(idPair KeyIDPair) bool

WalletExists reports whether the wallet is present in storage.

s.RWMutex RLock should be used when calling this method.

func (*Storage) WalletExistsPermanent

func (s *Storage) WalletExistsPermanent(idPair KeyIDPair) bool

WalletExistsPermanent reports whether the wallet is present in permanent storage.

s.RWMutex RLock should be used when calling this method.

type TEEBackupResponse

type TEEBackupResponse struct {
	BackupID     WalletBackupID
	WalletBackup []byte
}

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.ITeeWalletKeyManagerKeyGenerate) (*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.ITeeWalletKeyManagerKeyExistence

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