Documentation
¶
Index ¶
- Variables
- func DecryptDataV3(CipherJSON CipherJSON, auth string) ([]byte, error)
- func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error)
- func MakeKeystoreV3(privKeyHex, passphrase string, fn string) error
- type CipherJSON
- type EncryptedKeyJSONV3
- type Key
- type KeyStore
- func (ks *KeyStore) Accounts() []common.Address
- func (ks *KeyStore) Delete(a common.Address) error
- func (ks *KeyStore) GetKey(a common.Address) (signature.PrivateKey, error)
- func (ks *KeyStore) HasAddress(addr common.Address) bool
- func (ks *KeyStore) SetKey(key signature.PrivateKey) (common.Address, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFailedToReadKeystoreFile = errors.New("failed to read keystore file") ErrInvalidKeystoreVersion = errors.New("cannot parse old version") ErrFailedToUnmarshalKeystoreJSON = errors.New("failed unmarshal keystore json") ErrWrongPassphrase = errors.New("wrong passphrase for keystore") ErrFailedToDecrypt = errors.New("failed to decrypt keystore by passphrase") )
View Source
var ( // ErrNoMatch address key doesn't match error. ErrNoMatch = errors.New("no key for given address") )
Functions ¶
func DecryptDataV3 ¶
func DecryptDataV3(CipherJSON CipherJSON, auth string) ([]byte, error)
DecryptDataV3 decrypts CipherJSON file with auth string
func EncryptKey ¶
EncryptKey encrypts a key using the specified scrypt parameters into a json
func MakeKeystoreV3 ¶
MakeKeystoreV3 makes keystore file by version 3.
Types ¶
type CipherJSON ¶
type CipherJSON struct { Cipher string `json:"cipher"` CipherText string `json:"ciphertext"` CipherParams cipherparamsJSON `json:"cipherparams"` KDF string `json:"kdf"` KDFParams map[string]interface{} `json:"kdfparams"` MAC string `json:"mac"` }
CipherJSON json format for crypto field in keystore file
func EncryptDataV3 ¶
func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CipherJSON, error)
EncryptDataV3 encrypts the data given as 'data' with the password 'auth'.
type EncryptedKeyJSONV3 ¶
type EncryptedKeyJSONV3 struct { Address string `json:"address"` Crypto CipherJSON `json:"crypto"` ID string `json:"id"` Version int `json:"version"` }
EncryptedKeyJSONV3 is a struct for encrypted key
type Key ¶
type Key struct { ID uuid.UUID // Version 4 "random" for unique id not derived from key data // to simplify lookups we also store the address Address common.Address // we only store privkey as pubkey/address can be derived from it // privkey in this struct is always in plaintext PrivateKey signature.PrivateKey }
Key key struct for encryption key argument
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore manages private keys.
func NewKeyStore ¶
func NewKeyStore() *KeyStore
NewKeyStore creates a keystore for the given directory.
func (*KeyStore) HasAddress ¶
HasAddress reports whether a key with the given address is present.
Click to show internal directories.
Click to hide internal directories.