Documentation ¶
Overview ¶
Package keyStore stores private keys according to Web3 Secret Storage Definition. Extends format to optionally store mnemonic similarly to Ethers.js. Supports storing of `KeyStoreItem`s to variety `Backend`s (eg disk, system keychain).
Index ¶
Constants ¶
const ( ScryptN = 1 << 18 ScryptP = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // List all items in `Backend` List() ([]*KeyStoreItem, error) // Add `KeyStoreItem` to `Backend` Add(item *KeyStoreItem) error // Remove `KeyStoreItem` to `Backend` Remove(item *KeyStoreItem) error }
Backend `Item`s can be stored at disk, system keychain etc.
type DiskBackEnd ¶
type DiskBackEnd struct {
// contains filtered or unexported fields
}
DiskBackEnd stores `Item`s at disk
func NewDiskBackEnd ¶
func NewDiskBackEnd(storePath string) *DiskBackEnd
NewDiskBackEnd checks if there is existing folder and path, it not attempts to create one. Panics if unable to create folder when needed
func (*DiskBackEnd) Add ¶
func (d *DiskBackEnd) Add(item *KeyStoreItem) error
Add json serializes `KeyStoreItem` to file
func (*DiskBackEnd) List ¶
func (d *DiskBackEnd) List() ([]*KeyStoreItem, error)
List all the files at `storePath` and unmarshals them to `KeyStoreItem`s
func (*DiskBackEnd) Remove ¶
func (d *DiskBackEnd) Remove(item *KeyStoreItem) error
Remove file from store
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
func NewKeyStore ¶
func (*KeyStore) List ¶
func (k *KeyStore) List() ([]*KeyStoreItem, error)
type KeyStoreItem ¶
type KeyStoreItem struct { Address string `json:"address"` Crypto Web3SecretStorage `json:"crypto"` Uuid string `json:"id"` Version int `json:"version"` Mnemonic *Mnemonic `json:"x-soc-mnemonic-entropy-crypto"` FileName string `json:"x-sos-fileName"` }
KeyStoreItem implementation of web3 secure storage. Extended to support mnemonic storing
func NewKeyStoreItem ¶
func NewKeyStoreItem( uuid *string, privateKey ecdsa.PrivateKey, address string, mnemonicData *MnemonicInfo, password string, scryptN int, scryptP int, ) *KeyStoreItem
NewKeyStoreItem encrypts private key following web3 secret storage standard. If `MnemonicInfo` present, encrypts entropy using same method as private key.
type Mnemonic ¶
type Mnemonic struct { Crypto Web3SecretStorage `json:"crypto"` LangLocale string `json:"langLocale"` Path string `json:"path"` Version int `json:"version"` }
Mnemonic web3 secret storage format extension
func NewMnemonic ¶
func NewMnemonic(data *MnemonicInfo, pswd []byte, n, p int) *Mnemonic
NewMnemonic encrypts data according to web3 secret storage standard.
type MnemonicInfo ¶
type MnemonicInfo struct {
// contains filtered or unexported fields
}
MnemonicInfo data needed to store mnemonic in `Web3SecretStorage`.
type Web3SecretStorage ¶
type Web3SecretStorage struct { Cipher string `json:"cipher"` CipherText string `json:"ciphertext"` CipherParams CipherParams `json:"cipherparams"` KDF string `json:"kdf"` KDFParams map[string]interface{} `json:"kdfparams"` MAC string `json:"mac"` }
Web3SecretStorage v3 format
func NewWeb3SecretStorage ¶
func NewWeb3SecretStorage(data, pswd []byte, n, p int) *Web3SecretStorage
NewWeb3SecretStorage encrypts data according to web3 secret storage standard.