wallet

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 29 Imported by: 4

Documentation

Overview

Use this code snippet in your app. If you need more information about configurations or implementing the sample code, visit the AWS docs: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/setting-up.html

Index

Constants

View Source
const (
	EncryptSaltSize = 4
	HKDFInfo        = "BTP_SECRET_HKDF"
	AES128KeySize   = 16
	HKDFKeySize     = 2 * AES128KeySize
)

Variables

This section is empty.

Functions

func DecryptEvmKeyStore

func DecryptEvmKeyStore(ksData, pw []byte) (*ecdsa.PrivateKey, error)

func DecryptICONKeyStore

func DecryptICONKeyStore(ksData *KeyStoreData, pw []byte) (*crypto.PrivateKey, error)

func DecryptNearKeyStore

func DecryptNearKeyStore(ksData, pw []byte) (*ed25519.PrivateKey, error)

func EncryptKeyAsKeyStore

func EncryptKeyAsKeyStore(s *crypto.PrivateKey, pw []byte) ([]byte, error)

func GetSecret

func GetSecret(secretName string, region string) (string, error)

func KeyStoreFromWallet

func KeyStoreFromWallet(w interface{}, pw []byte) ([]byte, error)

func New

func New() *softwareWallet

func NewIcxWalletFromPrivateKey

func NewIcxWalletFromPrivateKey(sk *crypto.PrivateKey) (*softwareWallet, error)

func ReadAddressFromKeyStore

func ReadAddressFromKeyStore(data []byte) (*common.Address, error)

func SHA3SumKeccak256

func SHA3SumKeccak256(data ...[]byte) []byte

Types

type AES128CTRParams

type AES128CTRParams struct {
	IV common.RawHexBytes `json:"iv"`
}

type CryptoData

type CryptoData struct {
	Cipher       string             `json:"cipher"`
	CipherParams json.RawMessage    `json:"cipherparams"`
	CipherText   common.RawHexBytes `json:"ciphertext"`
	KDF          string             `json:"kdf"`
	KDFParams    json.RawMessage    `json:"kdfparams"`
	MAC          common.RawHexBytes `json:"mac"`
}

type Encrypted

type Encrypted struct {
	Param      []byte `json:"param"`
	CipherText []byte `json:"cipher_text"`
}

func NewEncrypted

func NewEncrypted(w Wallet, pubKey, b []byte) (*Encrypted, error)

func (*Encrypted) Aes128CTRStream

func (e *Encrypted) Aes128CTRStream(w Wallet) (cipher.Stream, error)

func (*Encrypted) Decrypt

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

func (*Encrypted) Encrypt

func (e *Encrypted) Encrypt(w Wallet, b []byte) error

type EvmWallet

type EvmWallet struct {
	Skey *ecdsa.PrivateKey
	Pkey *ecdsa.PublicKey
}

func NewEvmWalletFromPrivateKey

func NewEvmWalletFromPrivateKey(sk *ecdsa.PrivateKey) (*EvmWallet, error)

func (*EvmWallet) Address

func (w *EvmWallet) Address() string

func (*EvmWallet) ECDH

func (w *EvmWallet) ECDH(pubKey []byte) ([]byte, error)

func (*EvmWallet) PublicKey

func (w *EvmWallet) PublicKey() []byte

func (*EvmWallet) Sign

func (w *EvmWallet) Sign(data []byte) ([]byte, error)

type KeyStoreData

type KeyStoreData struct {
	Address  common.Address `json:"address"`
	ID       string         `json:"id"`
	Version  int            `json:"version"`
	CoinType string         `json:"coinType"`
	Crypto   CryptoData     `json:"crypto"`
}

func NewKeyStoreData

func NewKeyStoreData(data []byte) (*KeyStoreData, error)

type NearWallet

type NearWallet struct {
	Skey *ed25519.PrivateKey
	Pkey *ed25519.PublicKey
}

func NewNearwalletFromPrivateKey

func NewNearwalletFromPrivateKey(sk *ed25519.PrivateKey) (*NearWallet, error)

func (*NearWallet) Address

func (w *NearWallet) Address() string

func (*NearWallet) ECDH

func (w *NearWallet) ECDH(pubkey []byte) ([]byte, error)

func (*NearWallet) PublicKey

func (w *NearWallet) PublicKey() []byte

func (*NearWallet) Sign

func (w *NearWallet) Sign(data []byte) ([]byte, error)

type ScryptParams

type ScryptParams struct {
	DKLen int                `json:"dklen"`
	N     int                `json:"n"`
	R     int                `json:"r"`
	P     int                `json:"p"`
	Salt  common.RawHexBytes `json:"salt"`
}

func (*ScryptParams) Init

func (p *ScryptParams) Init() error

func (*ScryptParams) Key

func (p *ScryptParams) Key(pw []byte) ([]byte, error)

type Wallet

type Wallet interface {
	Address() string
	Sign(data []byte) ([]byte, error)
	PublicKey() []byte
	ECDH(pubKey []byte) ([]byte, error)
}

func DecryptKeyStore

func DecryptKeyStore(data, pw []byte) (Wallet, error)

Jump to

Keyboard shortcuts

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