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 GenerateKeyPair(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 InspectKeyMoniker(configDir string, moniker string, PasswordFile string, showPrivate bool, ...) error
- func NewKeyPair(configDir, moniker, passwordFile string) (*keystore.Key, error)
- func NewKeyPairFull(configDir, moniker, passwordFile string, privateKeyfile string, ...) (*keystore.Key, error)
- func PromptPassphrase(confirmation bool) (string, error)
- func PublicKeyHexToAddressHex(publicKey string) (string, error)
- func RandomPassphrase(n int) string
- func UpdateKeys(keyfilepath string, PasswordFile string, newPasswordFile string) error
- func UpdateKeysMoniker(configDir string, 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 GenerateKeyPair ¶
func GenerateKeyPair(keyfilepath, passwordFile, privateKeyfile string, outputJSON bool) (*keystore.Key, error)
GenerateKeyPair generates an Ethereum key pair.
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 InspectKeyMoniker ¶
func InspectKeyMoniker(configDir string, moniker string, PasswordFile string, showPrivate bool, outputJSON bool) error
InspectKeyMoniker is a wrapper around InspectKey to add moniker support
func NewKeyPair ¶
NewKeyPair is a wrapper to NewKeyPairFull and thus GenerateKeyPair. It does not support setting a private key. Additionally it does not support outputting to JSON format - if required, that can be achieved calling GenerateKeyPair directly.
func NewKeyPairFull ¶
func NewKeyPairFull(configDir, moniker, passwordFile string, privateKeyfile string, outputJSON bool) (*keystore.Key, error)
NewKeyPairFull is a wrapper to GenerateKeyPair 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 UpdateKeys ¶
UpdateKeys changes the passphrase on an encrypted keyfile
func UpdateKeysMoniker ¶
func UpdateKeysMoniker(configDir string, moniker string, PasswordFile string, newPasswordFile string) error
UpdateKeysMoniker wraps UpdateKeys adding moniker support
func WrapKey ¶
func WrapKey(privateKey *ecdsa.PrivateKey) *keystore.Key
WrapKey Create 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"`
}
We just added the public key as one of the fields in the JSON object because 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