Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToCryptoNode(data []byte, auth string) (node *types.Node, errRef error)
- func DecryptData(cryptoNode CryptedNode, auth string) ([]byte, error)
- type CacheStore
- func (cacheStore *CacheStore) ClearKey(addr *crypto.CommonAddress)
- func (cacheStore *CacheStore) ExportKey(auth string) ([]*types.Node, error)
- func (cacheStore *CacheStore) GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error)
- func (cacheStore *CacheStore) JoinPath(filename string) string
- func (cacheStore *CacheStore) ListAddr(auth string) ([]string, error)
- func (cacheStore *CacheStore) LoadKeys(addr *crypto.CommonAddress, auth string) error
- func (cacheStore *CacheStore) StoreKey(k *types.Node, auth string) error
- type CipherParams
- type CryptedNode
- type DbStore
- func (dbStore *DbStore) Close()
- func (dbStore *DbStore) ExportAddrs(auth string) ([]string, error)
- func (dbStore *DbStore) ExportKey(auth string) ([]*types.Node, error)
- func (db *DbStore) GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error)
- func (dbStore *DbStore) JoinPath(filename string) string
- func (dbStore *DbStore) StoreKey(key *types.Node, auth string) error
- type FileStore
- func (fs FileStore) ExportAddrs(auth string) ([]string, error)
- func (fs FileStore) ExportKey(auth string) ([]*types.Node, error)
- func (fs FileStore) GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error)
- func (fs FileStore) JoinPath(filename string) string
- func (fs FileStore) StoreKey(key *types.Node, auth string) error
- type KeyStore
- type MemoryStore
- func (mstore *MemoryStore) ExportAddrs(auth string) ([]string, error)
- func (mstore *MemoryStore) ExportKey(auth string) ([]*types.Node, error)
- func (mstore *MemoryStore) GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error)
- func (mstore *MemoryStore) JoinPath(filename string) string
- func (mstore *MemoryStore) StoreKey(k *types.Node, auth string) error
- type ScryptParams
Constants ¶
const ( // StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptN = 1 << 18 // StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptP = 1 // LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB // memory and taking approximately 100ms CPU time on a modern processor. LightScryptN = 1 << 12 // LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB // memory and taking approximately 100ms CPU time on a modern processor. LightScryptP = 6 )
const (
MODULENAME = "accounts"
)
Variables ¶
var ( ErrKeyNotExistOrUnlock = errors.New("key not exit or not unlock account") ErrKeyNotFound = errors.New("key not found") ErrDecryptFail = errors.New("decryption failed") ErrPassword = errors.New("password not correct") ErrSaveKey = errors.New("save key failed") ErrDecrypt = errors.New("could not decrypt key with given passphrase") )
Functions ¶
func BytesToCryptoNode ¶
BytesToCryptoNode cocnvert given bytes and password to a node
func DecryptData ¶
func DecryptData(cryptoNode CryptedNode, auth string) ([]byte, error)
Types ¶
type CacheStore ¶
type CacheStore struct {
// contains filtered or unexported fields
}
accountCache This is used for buffering real storage and upper applications to speed up reading. TODO If the write speed becomes a bottleneck, write caching can be added
func NewCacheStore ¶
func NewCacheStore(keyStore KeyStore, password string) (*CacheStore, error)
NewCacheStore receive an path and password as argument path refer to the file that contain all key password used to decrypto content in key file
func (*CacheStore) ClearKey ¶
func (cacheStore *CacheStore) ClearKey(addr *crypto.CommonAddress)
func (*CacheStore) ExportKey ¶
func (cacheStore *CacheStore) ExportKey(auth string) ([]*types.Node, error)
ExportKey export all key in cache by password
func (*CacheStore) GetKey ¶
func (cacheStore *CacheStore) GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error)
GetKey Get the private key by address and password Notice if you wallet is locked ,private key cant be found
func (*CacheStore) JoinPath ¶
func (cacheStore *CacheStore) JoinPath(filename string) string
JoinPath refer to local file
func (*CacheStore) LoadKeys ¶
func (cacheStore *CacheStore) LoadKeys(addr *crypto.CommonAddress, auth string) error
add private key to buff
type CipherParams ¶
type CipherParams struct {
IV []byte `json:"iv"`
}
type CryptedNode ¶
type CryptedNode struct { Version int `json:"version"` Data []byte `json:"-"` CipherText []byte `json:"cipherText"` ChainId types.ChainIdType `json:"chainId"` ChainCode []byte `json:"chainCode"` Cipher string `json:"cipher"` CipherParams CipherParams `json:"cipherParams"` KDFParams ScryptParams `json:"KDFParams"` MAC []byte `json:"mac"` }
func (*CryptedNode) EncryptData ¶
func (node *CryptedNode) EncryptData(auth []byte) error
Encryptdata encrypts the data given as 'data' with the password 'auth'.
type DbStore ¶
type DbStore struct {
// contains filtered or unexported fields
}
DbStore use leveldb as the storegae
func NewDbStore ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
func NewFileStore ¶
type KeyStore ¶
type KeyStore interface { // Loads and decrypts the key from disk. GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error) // Writes and encrypts the key. StoreKey(k *types.Node, auth string) error // Writes and encrypts the key. ExportKey(auth string) ([]*types.Node, error) // Joins filename with the key directory unless it is already absolute. JoinPath(filename string) string //export all addresses ExportAddrs(auth string) ([]string, error) }
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) ExportAddrs ¶
func (mstore *MemoryStore) ExportAddrs(auth string) ([]string, error)
func (*MemoryStore) ExportKey ¶
func (mstore *MemoryStore) ExportKey(auth string) ([]*types.Node, error)
func (*MemoryStore) GetKey ¶
func (mstore *MemoryStore) GetKey(addr *crypto.CommonAddress, auth string) (*types.Node, error)
func (*MemoryStore) JoinPath ¶
func (mstore *MemoryStore) JoinPath(filename string) string