Documentation ¶
Overview ¶
Package keystore encrypt private key and save on disk uses JSON encoding.
This key store behaves as KeyStorePlain with the difference that the private key is encrypted and on disk uses another JSON encoding.
The crypto is documented at https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
Index ¶
Constants ¶
View Source
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 )
Variables ¶
View Source
var ErrDecrypt = errors.New("could not decrypt key with given password")
ErrDecrypt decrypt error
Functions ¶
func DecryptDataV3 ¶
func DecryptDataV3(cryptoJSON *CryptoJSON, auth string) ([]byte, error)
DecryptDataV3 decrypt
Types ¶
type CryptoJSON ¶
type CryptoJSON 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"` }
CryptoJSON struct
func EncryptDataV3 ¶
func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error)
EncryptDataV3 encrypts the data given as 'data' with the password 'auth'.
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 *ecdsa.PrivateKey }
Key struct
func DecryptKey ¶
DecryptKey decrypts a key from a json blob, returning the private key itself.
func (*Key) MarshalJSON ¶
MarshalJSON marshal json
func (*Key) UnmarshalJSON ¶
UnmarshalJSON unmarshal json
Click to show internal directories.
Click to hide internal directories.