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. // 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. 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) // The following operations will *only* work on locally-stored keys Rotate(name, oldpass string, getNewpass func() (string, error)) error Import(name string, armor string) (err error) ImportPrivKey(name, armor, decryptPassphrase, encryptPassphrase string) error ImportPrivKeyUnsafe(name, armor, encryptPassphrase string) error ImportPubKey(name string, armor string) (err error) Export(name string) (armor string, err error) ExportPubKey(name string) (armor string, err error) ExportPrivKey(name, decryptPassphrase, encryptPassphrase string) (armor string, err error) ExportPrivKeyUnsafe(name, decryptPassphrase string) (armor string, err error) // ExportPrivateKeyObject *only* works on locally-stored keys. Temporary method until we redo the exporting API ExportPrivateKeyObject(name string, passphrase 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.