github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/crypto/keys/README.md (about) 1 # Keys API 2 3 [](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys) 4 5 6 ## The Keybase interface 7 8 The [Keybase](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys#Keybase) interface defines 9 the methods that a type needs to implement to be used as key storage backend. This package provides 10 few implementations out-of-the-box. 11 12 ## Constructors 13 14 ### New 15 16 The [New](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys#New) constructor returns 17 an on-disk implementation backed by LevelDB storage that has been the default implementation used by the SDK until v0.38.0. 18 Due to [security concerns](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-006-secret-store-replacement.md), we recommend to drop 19 it in favor of the `NewKeyring` or `NewKeyringFile` constructors. We strongly advise to migrate away from this function as **it may be removed in a future 20 release**. 21 22 ### NewInMemory 23 24 The [NewInMemory](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys#NewInMemory) constructor returns 25 an implementation backed by an in-memory, goroutine-safe map that we've historically used for testing purposes or on-the-fly 26 key generation and we consider safe for the aforementioned use cases since the generated keys are discarded when the process 27 terminates or the type instance is garbage collected. 28 29 ### NewKeyring 30 31 The [NewKeyring](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys#NewKeyring) constructor returns 32 an implementation backed by the [Keyring](https://github.com/99designs/keyring) library, whose aim is to provide a common 33 abstraction and uniform interface between secret stores available for Windows, macOS, and most GNU/Linux distributions. 34 The instance returned by this constructor will use the operating system's default credentials store, which will then handle 35 keys storage operations securely. 36 37 ### NewKeyringFile, NewTestKeyring 38 39 Both [NewKeyringFile](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys#NewKeyringFile) and 40 [NewTestKeyring](https://godoc.org/github.com/cosmos/cosmos-sdk/crypto/keys#NewTestKeyring) constructors return 41 on-disk implementations backed by the [Keyring](https://github.com/99designs/keyring) `file` backend. 42 Whilst `NewKeyringFile` returns a secure, encrypted file-based type that requires user's password in order to 43 function correctly, the implementation returned by `NewTestKeyring` stores keys information in clear text and **must be used 44 only for testing purposes**. 45 46 `NewKeyringFile` and `NewTestKeyring` store key files in the client home directory's `keyring` 47 and `keyring-test` subdirectories respectively.