keyring

package
v0.0.0-...-77985df Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootName = "root"
)

Variables

View Source
var BcryptSecurityParameter = 12

BcryptSecurityParameter is security parameter var, and it can be changed within the lcd test. Making the bcrypt security parameter a var shouldn't be a security issue: One can't verify an invalid key by maliciously changing the bcrypt parameter during a runtime vulnerability. The main security threat this then exposes would be something that changes this during runtime before the user creates their key. This vulnerability must succeed to update this to that same value before every subsequent call to the keys command in future startups / or the attacker must get access to the filesystem. However, with a similar threat model (changing variables in runtime), one can cause the user to sign a different tx than what they see, which is a significantly cheaper attack then breaking a bcrypt hash. (Recall that the nonce still exists to break rainbow tables) For further notes on security parameter choice, see README.md

View Source
var CryptoCdc *codec.LegacyAmino

CryptoCdc defines the codec required for keys and info

View Source
var SigningAlgoList = keyring.SigningAlgoList{
	hd.Sm2,
	hd.Secp256k1,
}

Functions

func EncryptArmorPrivKey

func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, header map[string]string) string

Encrypt and armor the private key.

func GenHash

func GenHash(text string) string

func PrintInfo

func PrintInfo(w io.Writer, keyInfo ...cosmoskeyring.Info)

func RegisterLegacyAminoCodec

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec.

func VerifyHash

func VerifyHash(srcHash, srcText string) bool

Types

type KeyOutput

type KeyOutput struct {
	Name       string `json:"name" yaml:"name"`
	Type       string `json:"type" yaml:"type"`
	Address    string `json:"address" yaml:"address"`
	PubKey     string `json:"pub_key" yaml:"pub_key"`
	AddressIdx uint32 `json:"address_idx" yaml:"address_idx"`
}

KeyOutput defines a structure wrapping around an Info object used for output functionality.

type Keyring

type Keyring interface {
	keyring.Keyring
	Encrypt(bytes []byte, pass ...string) (string, error)
	Decrypt(bytes []byte) (string, error)
	Reset(password string) error
	RemoveAll() error
}

func NewFileKeyring

func NewFileKeyring(dir string, buf io.Reader) Keyring

type Keystore

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

func New

func New(rootDir string, userInput io.Reader, opts ...cosmoskeyring.Option) (Keystore, error)

New creates a new instance of a keyring. Keyring ptions can be applied when generating the new instance. Available backends are "file".

func (Keystore) Export

func (ks Keystore) Export(key string) (armor, pwd string, err error)

Export export a key private by a random password

func (Keystore) Has

func (ks Keystore) Has(uid string) bool

Has determine if a key exists

func (Keystore) HasInit

func (ks Keystore) HasInit() bool

HasInit determine if the wallet has been initialized

func (Keystore) Init

Init create a wallet instance and produce a mnemonic

func (Keystore) Key

func (ks Keystore) Key(uid string) (cosmoskeyring.Info, error)

Key return a key information by key name

func (Keystore) KeyByAddress

func (ks Keystore) KeyByAddress(address sdk.Address) (cosmoskeyring.Info, error)

Key return a key information by the address

func (Keystore) List

func (ks Keystore) List() ([]cosmoskeyring.Info, error)

Key return all the key information

func (Keystore) NewKey

func (ks Keystore) NewKey(name string) (cosmoskeyring.Info, error)

NewKey create a new key

func (Keystore) Recover

func (ks Keystore) Recover(mnemonic string, algo cosmoskeyring.SignatureAlgo) (cosmoskeyring.Info, error)

Recover recover a wallet instance by a mnemonic

func (Keystore) UpdateRoot

func (ks Keystore) UpdateRoot(mnemonic, newPwd string) error

UpdateRoot update a wallet root password by old password or mnemonic

Jump to

Keyboard shortcuts

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