vault

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDecryptPassphrase

func GetDecryptPassphrase() (string, error)

func GetEncryptPassphrase

func GetEncryptPassphrase() (string, error)

func GetPassword

func GetPassword(input string) (string, error)

func NewRandomPrivateKey

func NewRandomPrivateKey() (PublicKey, PrivateKey, error)

Types

type PassphraseBoxer

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

func NewPassphraseBoxer

func NewPassphraseBoxer(password string) *PassphraseBoxer

func (*PassphraseBoxer) Open

func (b *PassphraseBoxer) Open(in string) ([]byte, error)

func (*PassphraseBoxer) Seal

func (b *PassphraseBoxer) Seal(in []byte) (string, error)

func (*PassphraseBoxer) WrapType

func (b *PassphraseBoxer) WrapType() string

type PrivateKey

type PrivateKey []byte

func MustPrivateKeyFromBase58

func MustPrivateKeyFromBase58(in string) PrivateKey

func PrivateKeyFromBase58

func PrivateKeyFromBase58(privkey string) (PrivateKey, error)

func PrivateKeyFromSolanaKeygenFile

func PrivateKeyFromSolanaKeygenFile(file string) (PrivateKey, error)

func (PrivateKey) PublicKey

func (k PrivateKey) PublicKey() PublicKey

func (PrivateKey) String

func (k PrivateKey) String() string

type PublicKey

type PublicKey [32]byte

func MustPublicKeyFromBase58

func MustPublicKeyFromBase58(in string) PublicKey

func PublicKeyFromBase58

func PublicKeyFromBase58(in string) (out PublicKey, err error)

func PublicKeyFromBytes

func PublicKeyFromBytes(in []byte) (out PublicKey)

func (PublicKey) Equals

func (p PublicKey) Equals(pb PublicKey) bool

func (PublicKey) IsZero

func (p PublicKey) IsZero() bool

func (PublicKey) MarshalJSON

func (p PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) String

func (p PublicKey) String() string

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(data []byte) (err error)

type SecretBoxer

type SecretBoxer interface {
	Seal(in []byte) (string, error)
	Open(in string) ([]byte, error)
	WrapType() string
}

func SecretBoxerForType

func SecretBoxerForType(boxerType string) (SecretBoxer, error)

type Vault

type Vault struct {
	Kind    string `json:"kind"`
	Version int    `json:"version"`
	Comment string `json:"comment"`

	SecretBoxWrap       string `json:"secretbox_wrap"`
	SecretBoxCiphertext string `json:"secretbox_ciphertext"`

	KeyBag []PrivateKey `json:"-"`
}

Vault represents a `solana-go` wallet. It contains the encrypted material to load a KeyBag, which is the signing provider for signing transactions using the `solana-go` library.

func MustGetWallet

func MustGetWallet() *Vault

func NewVault

func NewVault() *Vault

NewVault returns an empty vault, unsaved and with no keys.

func NewVaultFromSingleKey

func NewVaultFromSingleKey(privKey string) (*Vault, error)

NewVaultFromSingleKey creates a new Vault from the provided private key.

func NewVaultFromWalletFile

func NewVaultFromWalletFile(filename string) (*Vault, error)

NewVaultFromWalletFile returns a new Vault instance from the provided filename of an eos wallet.

func (*Vault) AddPrivateKey

func (v *Vault) AddPrivateKey(privateKey PrivateKey) PublicKey

AddPrivateKey appends the provided private key into the Vault's KeyBag

func (*Vault) NewKeyPair

func (v *Vault) NewKeyPair() (pub PublicKey, err error)

NewKeyPair creates a new keypair, saves the private key in the local wallet and returns the public key. It does NOT save the wallet, you better do that soon after.

func (*Vault) Open

func (v *Vault) Open(boxer SecretBoxer) error

func (*Vault) PrintPrivateKeys

func (v *Vault) PrintPrivateKeys()

func (*Vault) PrintPublicKeys

func (v *Vault) PrintPublicKeys()

PrintPublicKeys prints a PublicKey corresponding to each PrivateKey in the Vault's KeyBag.

func (*Vault) Seal

func (v *Vault) Seal(boxer SecretBoxer) error

func (*Vault) WriteToFile

func (v *Vault) WriteToFile(filename string) error

WriteToFile writes the Vault to disk. You need to encrypt before writing to file, otherwise you might lose much :)

Jump to

Keyboard shortcuts

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