wallet_manager

package
v0.0.0-...-192d190 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEd25519KeyPairHex

func GenerateEd25519KeyPairHex() (string, string, error)

func UnwrapTinkKeyset

func UnwrapTinkKeyset(wrapped WrappedTinkKeyset, password string) (*keyset.Handle, error)

Types

type EncryptionFile

type EncryptionFile struct {
	FilePath string
}

func (*EncryptionFile) Decrypt

func (e *EncryptionFile) Decrypt(localFile LocalEncryptedWalletFile, password string) ([]byte, error)

func (*EncryptionFile) Encrypt

func (e *EncryptionFile) Encrypt(data []byte, password string) (*LocalEncryptedWalletFile, error)

func (*EncryptionFile) Read

func (*EncryptionFile) Write

func (e *EncryptionFile) Write(localFile LocalEncryptedWalletFile) error

type EncryptionKey

type EncryptionKey struct {
	Primitive tink.AEAD
	Owner     string
}

func (*EncryptionKey) DecryptPrivateKey

func (e *EncryptionKey) DecryptPrivateKey(encryptedPrivateKey []byte) ([]byte, error)

func (*EncryptionKey) EncryptPrivateKey

func (e *EncryptionKey) EncryptPrivateKey(privateKey []byte) ([]byte, error)

func (*EncryptionKey) LoadAEAD

func (e *EncryptionKey) LoadAEAD(kh *keyset.Handle) error

func (*EncryptionKey) NewAEAD

func (e *EncryptionKey) NewAEAD() (*keyset.Handle, error)

type IEncryptionFile

type IEncryptionFile interface {
	Encrypt(data []byte, password string) (*LocalEncryptedWalletFile, error)
	Decrypt(localFile LocalEncryptedWalletFile, password string) ([]byte, error)
	Write(localFile LocalEncryptedWalletFile) error
	Read() (*LocalEncryptedWalletFile, error)
}

func NewEncryptionFile

func NewEncryptionFile(filePath string) IEncryptionFile

type IEncryptionKey

type IEncryptionKey interface {
	NewAEAD() (*keyset.Handle, error)
	LoadAEAD(kh *keyset.Handle) error
	EncryptPrivateKey(privateKey []byte) ([]byte, error)
	DecryptPrivateKey(encryptedPrivateKey []byte) ([]byte, error)
}

func NewEncryption

func NewEncryption(owner string) IEncryptionKey

type IWalletManager

type IWalletManager interface {
	ImportPrivateKey(privateKey []byte, password string) error

	Lock() error
	UnlockWithPassword(password string) error
	IsUnlocked() bool

	ChangePassword(currentPassword string, newPassword string) error

	OwnerAddress() string

	SignTransaction(input SignTransactionInput) (*transaction.Transaction, error)
	SignPreparedTransaction(input protocol.PreparedTransaction) (protocol.SignedTransaction, error)
}

func NewWalletManager

func NewWalletManager(filePath string) IWalletManager

type KeysetKDFParams

type KeysetKDFParams struct {
	Alg      string `json:"alg"`
	Time     uint32 `json:"time"`
	MemoryKB uint32 `json:"memory_kb"`
	Parallel uint8  `json:"parallel"`
	KeyLen   uint32 `json:"key_len"`
	Salt     []byte `json:"salt"`
}

func NewKeysetKDFParams

func NewKeysetKDFParams() (KeysetKDFParams, error)

type LocalEncryptedWalletFile

type LocalEncryptedWalletFile struct {
	KDF    KeysetKDFParams `json:"kdf"`
	Cipher []byte          `json:"cipher"`
}

type PasswordAEAD

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

func NewPasswordAEAD

func NewPasswordAEAD(password string, params KeysetKDFParams) (*PasswordAEAD, error)

func (*PasswordAEAD) Decrypt

func (p *PasswordAEAD) Decrypt(ciphertext, associatedData []byte) ([]byte, error)

func (*PasswordAEAD) Encrypt

func (p *PasswordAEAD) Encrypt(plaintext, associatedData []byte) ([]byte, error)

type SignTransactionInput

type SignTransactionInput struct {
	ChainID uint8
	From    string
	To      string
	Method  string
	Data    map[string]interface{}
	Version uint8
	UUID7   string
}

type WalletAction

type WalletAction string
const (
	ActionExportPrivateKey WalletAction = "export_private_key"
	ActionChangePassword   WalletAction = "change_password"
	ActionDeleteWallet     WalletAction = "delete_wallet"
	ActionWithdraw         WalletAction = "withdraw"
)

type WalletFile

type WalletFile struct {
	Version             int               `json:"version"`
	Owner               string            `json:"owner"`
	EncryptedPrivateKey []byte            `json:"encrypted_private_key"`
	WrappedKeyset       WrappedTinkKeyset `json:"wrapped_keyset"`
	CreatedAt           time.Time         `json:"created_at"`
	UpdatedAt           time.Time         `json:"updated_at"`
}

type WalletManager

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

func (*WalletManager) ChangePassword

func (w *WalletManager) ChangePassword(currentPassword string, newPassword string) error

func (*WalletManager) ImportPrivateKey

func (w *WalletManager) ImportPrivateKey(privateKey []byte, password string) error

func (*WalletManager) IsUnlocked

func (w *WalletManager) IsUnlocked() bool

func (*WalletManager) Lock

func (w *WalletManager) Lock() error

func (*WalletManager) OwnerAddress

func (w *WalletManager) OwnerAddress() string

func (*WalletManager) SignPreparedTransaction

func (w *WalletManager) SignPreparedTransaction(input protocol.PreparedTransaction) (protocol.SignedTransaction, error)

func (*WalletManager) SignTransaction

func (w *WalletManager) SignTransaction(input SignTransactionInput) (*transaction.Transaction, error)

func (*WalletManager) UnlockWithPassword

func (w *WalletManager) UnlockWithPassword(password string) error

type WrappedTinkKeyset

type WrappedTinkKeyset struct {
	KDF                 KeysetKDFParams `json:"kdf"`
	EncryptedKeysetJSON []byte          `json:"encrypted_keyset_json"`
}

func WrapTinkKeyset

func WrapTinkKeyset(kh *keyset.Handle, password string) (WrappedTinkKeyset, error)

Jump to

Keyboard shortcuts

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