Documentation ¶
Index ¶
- Constants
- Variables
- func EncryptKey(key *Key, password string, scryptN, scryptP int) ([]byte, error)
- func Keccak256(data ...[]byte) []byte
- type Key
- type Keystore
- func (ks Keystore) GetKey(filename, password string) (*Key, error)
- func (ks Keystore) GetKeys(directory, filePrefix, password string, warnOnFail bool) (map[string]*Key, error)
- func (ks Keystore) JoinPath(filename string) string
- func (ks Keystore) StoreKey(filename string, key *Key, auth string) error
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 is the standard error message when decryption is a failure. ErrDecrypt = errors.New("could not decrypt key with given passphrase") )
Functions ¶
func EncryptKey ¶
EncryptKey encrypts a key using the specified scrypt parameters into a JSON blob that can be decrypted later on.
Types ¶
type Key ¶
type Key struct { ID uuid.UUID // Version 4 "random" for unique id not derived from key data PublicKey bls.PublicKey // Represents the public key of the user. SecretKey bls.SecretKey // Represents the private key of the user. }
Key is the object that stores all the user data related to their public/secret keys.
func DecryptKey ¶
DecryptKey decrypts a key from a JSON blob, returning the private key itself.
func NewKeyFromBLS ¶
NewKeyFromBLS creates a new keystore Key type using a BLS private key.
func (*Key) MarshalJSON ¶
MarshalJSON marshals a key struct into a JSON blob.
func (*Key) UnmarshalJSON ¶
UnmarshalJSON unmarshals a blob into a key struct.
type Keystore ¶ added in v1.0.0
type Keystore struct {
// contains filtered or unexported fields
}
Keystore defines a keystore with a directory path and scrypt values.
func (Keystore) GetKey ¶ added in v1.0.0
GetKey from file using the filename path and a decryption password.
func (Keystore) GetKeys ¶ added in v1.0.0
func (ks Keystore) GetKeys(directory, filePrefix, password string, warnOnFail bool) (map[string]*Key, error)
GetKeys from directory using the prefix to filter relevant files and a decryption password.
Click to show internal directories.
Click to hide internal directories.