Documentation ¶
Overview ¶
Package crypto provides common functions for manipulating and generating keys
Index ¶
- func EncryptKey(key *keystore.Key, auth string, scryptN, scryptP int) ([]byte, error)
- func GenerateKeyfile(keyfilepath, passwordFile, privateKeyfile string, outputJSON bool) (*keystore.Key, error)
- func GetPassphrase(passwordFile string, confirmation bool) (string, error)
- func GetPrivateKey(keyfilepath string, PasswordFile string) (*ecdsa.PrivateKey, error)
- func GetPrivateKeyString(keyfilePath string, passwordFile string) (string, error)
- func InspectKey(keyfilepath string, PasswordFile string, showPrivate bool, outputJSON bool) error
- func InspectKeyByMoniker(keystore string, moniker string, PasswordFile string, showPrivate bool, ...) error
- func NewKeyfile(keystore, moniker, passwordFile string) (*keystore.Key, error)
- func NewKeyfileFull(keystore, moniker, passwordFile string, privateKeyfile string, outputJSON bool) (*keystore.Key, error)
- func PromptPassphrase(confirmation bool) (string, error)
- func PublicKeyHexToAddressHex(publicKey string) (string, error)
- func RandomPassphrase(n int) string
- func UpdateKey(keyfilepath string, PasswordFile string, newPasswordFile string) error
- func UpdateKeyByMoniker(keystore, moniker string, passwordFile string, newPasswordFile string) error
- func WrapKey(privateKey *ecdsa.PrivateKey) *keystore.Key
- type EncryptedKeyJSONMonet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncryptKey ¶
EncryptKey encrypts a key using the specified scrypt parameters into a json blob that can be decrypted later on.
func GenerateKeyfile ¶ added in v0.3.0
func GenerateKeyfile(keyfilepath, passwordFile, privateKeyfile string, outputJSON bool) (*keystore.Key, error)
GenerateKeyfile generates an Ethereum keyfile and writes it.
keyfilepath: path to write the new keyfile to. passwordFile: plain text file containing the passphrase to use for the
keyfile.
privateKeyfile: the path to an unencrypted private key. If specified, this
function does not generate a new keyfile, it instead generates a keyfile from the unencrypted private key.
outputJSON: controls whether the output to stdio is in JSON format or not.
The function returns a key object which can be used to retrieve public or private keys or the address.
func GetPassphrase ¶
GetPassphrase obtains a passphrase given by the user. It first checks the --passfile command line flag and ultimately prompts the user for a passphrase.
func GetPrivateKey ¶
func GetPrivateKey(keyfilepath string, PasswordFile string) (*ecdsa.PrivateKey, error)
GetPrivateKey decrypts a keystore and returns the private key
func GetPrivateKeyString ¶
GetPrivateKeyString decrypts a keystore and returns the private key as a string
func InspectKey ¶
InspectKey inspects an encrypted keyfile
func InspectKeyByMoniker ¶ added in v0.3.0
func InspectKeyByMoniker(keystore string, moniker string, PasswordFile string, showPrivate bool, outputJSON bool) error
InspectKeyByMoniker is a wrapper around InspectKey to add moniker support
func NewKeyfile ¶ added in v0.3.0
NewKeyfile is a wrapper to NewKeyfileFull and thus GenerateKeyfile. It does not support setting a private key. Additionally it does not support outputting to JSON format - if required, that can be achieved calling GenerateKeyfile directly.
func NewKeyfileFull ¶ added in v0.3.0
func NewKeyfileFull(keystore, moniker, passwordFile string, privateKeyfile string, outputJSON bool) (*keystore.Key, error)
NewKeyfileFull is a wrapper to GenerateKeyfile adding moniker support
func PromptPassphrase ¶
PromptPassphrase prompts the user for a passphrase. Set confirmation to true to require the user to confirm the passphrase.
func PublicKeyHexToAddressHex ¶
PublicKeyHexToAddressHex takes a Hex string public key and returns a hex string Ethereum style address.
func RandomPassphrase ¶
RandomPassphrase generates a random passphrase
func UpdateKeyByMoniker ¶ added in v0.3.0
func UpdateKeyByMoniker(keystore, moniker string, passwordFile string, newPasswordFile string) error
UpdateKeyByMoniker wraps UpdateKey adding moniker support
func WrapKey ¶
func WrapKey(privateKey *ecdsa.PrivateKey) *keystore.Key
WrapKey creates the keyfile object with a random UUID. It would be preferable to create the key manually, rather then calling this function, but we cannot use pborman/uuid directly because it is vendored in go-ethereum. That package defines the type of keystore.Key.Id.
Types ¶
type EncryptedKeyJSONMonet ¶
type EncryptedKeyJSONMonet struct { Address string `json:"address"` PublicKey string `json:"pub"` Crypto keystore.CryptoJSON `json:"crypto"` ID string `json:"id"` Version int `json:"version"` }
EncryptedKeyJSONMonet is an extension of a regular Ethereum keyfile with an added public key. It makes our lives easier when working with Babble. We could change the Version number, but then other non-monet tools, would not be able to decrypt keys