Documentation
¶
Index ¶
Constants ¶
const ( // Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters. Secp256k1 = SigningAlgo("secp256k1") // Ed25519 represents the Ed25519 signature system. // It is currently not supported for end-user keys (wallets/ledgers). Ed25519 = SigningAlgo("ed25519") )
Variables ¶
var ( // ErrUnsupportedSigningAlgo is raised when the caller tries to use a // different signing scheme than secp256k1. ErrUnsupportedSigningAlgo = errors.New("unsupported signing algo: only secp256k1 is supported") // ErrUnsupportedLanguage is raised when the caller tries to use a // different language than english for creating a mnemonic sentence. ErrUnsupportedLanguage = errors.New("unsupported language: only english is supported") )
var Package = amino.RegisterPackage(amino.NewPackage( "github.com/gnolang/gno/tm2/pkg/crypto/keys", "tm.keys", amino.GetCallersDirname(), ).WithDependencies().WithTypes( localInfo{}, "LocalInfo", ledgerInfo{}, "LedgerInfo", offlineInfo{}, "OfflineInfo", multiInfo{}, "MultiInfo", ))
Functions ¶
Types ¶
type Info ¶
type Info interface {
// Human-readable type for key listing
GetType() KeyType
// Name of the key
GetName() string
// Public key
GetPubKey() crypto.PubKey
// Address
GetAddress() crypto.Address
// Bip44 Path
GetPath() (*hd.BIP44Params, error)
}
Info is the publicly exposed information about a keypair
type KeyType ¶
type KeyType uint
KeyType reflects a human-readable type for key listing.
type Keybase ¶
type Keybase interface {
// CRUD on the keystore
List() ([]Info, error)
HasByNameOrAddress(nameOrBech32 string) (bool, error)
HasByName(name string) (bool, error)
HasByAddress(address crypto.Address) (bool, error)
GetByNameOrAddress(nameOrBech32 string) (Info, error)
GetByName(name string) (Info, error)
GetByAddress(address crypto.Address) (Info, error)
Delete(name, passphrase string, skipPass bool) error
// Sign some bytes, looking up the private key to use
Sign(name, passphrase string, msg []byte) ([]byte, crypto.PubKey, error)
Verify(name string, msg, sig []byte) error
// CreateAccount creates an account based using the BIP44 path (44'/118'/{account}'/0/{index}
// Encrypt the key to disk using encryptPasswd.
// If an account exists with the same address but a different name, it is replaced by the new name.
// See https://github.com/tendermint/classic/sdk/issues/2095
CreateAccount(name, mnemonic, bip39Passwd, encryptPasswd string, account uint32, index uint32) (Info, error)
// Like CreateAccount but from general bip44 params.
// If an account exists with the same address but a different name, it is replaced by the new name.
CreateAccountBip44(name, mnemonic, bip39Passwd, encryptPasswd string, params hd.BIP44Params) (Info, error)
// CreateLedger creates, stores, and returns a new Ledger key reference
CreateLedger(name string, algo SigningAlgo, hrp string, account, index uint32) (info Info, err error)
// CreateOffline creates, stores, and returns a new offline key reference
CreateOffline(name string, pubkey crypto.PubKey) (info Info, err error)
// CreateMulti creates, stores, and returns a new multsig (offline) key reference
CreateMulti(name string, pubkey crypto.PubKey) (info Info, err error)
// Rotate replaces the encryption password for a given key
Rotate(name, oldpass string, getNewpass func() (string, error)) error
// ImportPrivKey imports the given private key into the keybase.
// In all import operations, if an account exists with the same address but a different name, it is replaced by the new name
ImportPrivKey(name string, key crypto.PrivKey, encryptPass string) error
// ExportPrivKey exports the private key from the keybase. It *only* works on locally-stored keys
ExportPrivKey(name string, decryptPass string) (crypto.PrivKey, error)
// CloseDB closes the database.
CloseDB()
}
Keybase exposes operations on a generic keystore
func NewDBKeybase ¶
NewDBKeybase creates a new keybase instance using the passed DB for reading and writing keys.
func NewInMemory ¶
func NewInMemory() Keybase
NewInMemory creates a transient keybase on top of in-memory storage instance useful for testing purposes and on-the-fly key generation.
func NewKeyBaseFromDir ¶
NewKeyBaseFromDir initializes a keybase at a particular dir.
func NewLazyDBKeybase ¶
New creates a new instance of a lazy keybase.
type Language ¶
type Language int
Language is a language to create the BIP 39 mnemonic in. Currently, only english is supported though. Find a list of all supported languages in the BIP 39 spec (word lists).
const ( // English is the default language to create a mnemonic. // It is the only supported language by this package. English Language = iota + 1 // Japanese is currently not supported. Japanese // Korean is currently not supported. Korean // Spanish is currently not supported. Spanish // ChineseSimplified is currently not supported. ChineseSimplified // ChineseTraditional is currently not supported. ChineseTraditional // French is currently not supported. French // Italian is currently not supported. Italian )
noinspection ALL
type SigningAlgo ¶
type SigningAlgo string
SigningAlgo defines an algorithm to derive key-pairs which can be used for cryptographic signing.