Adding Basic Private Key Management (#671)

* adding flags

* adding modified key utils

* adding more funcs

* more changes

* more changes

* documentation

* changes to node

* gazelle

* fixing bazel build

* gazelle

* adding tests

* more tests

* addressing terence's feedback

* adding geth header

* test

* changes

* fixedd it

* fixed marshalling

* adding more to tests

* gazelle

* adding more tests

* lint

* add cov

* cov

* fix imports
This commit is contained in:
Nishant Das
2018-11-08 11:22:31 +08:00
committed by GitHub
parent 6476fb54af
commit 37bc1c67be
23 changed files with 833 additions and 36 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/database"
"github.com/prysmaticlabs/prysm/shared/debug"
"github.com/prysmaticlabs/prysm/shared/keystore"
"github.com/prysmaticlabs/prysm/shared/p2p"
"github.com/prysmaticlabs/prysm/validator/attester"
"github.com/prysmaticlabs/prysm/validator/beacon"
@@ -60,17 +61,15 @@ func NewValidatorClient(ctx *cli.Context) (*ValidatorClient, error) {
var pubKey []byte
inputKey := ctx.GlobalString(types.PubKeyFlag.Name)
if inputKey == "" {
var err error
pubKey, err = GeneratePubKey()
keystorePath := ctx.GlobalString(cmd.KeystoreDirectoryFlag.Name)
password := ctx.GlobalString(cmd.KeystorePasswordFlag.Name)
if keystorePath != "" && password != "" {
blspubkey, err := keystore.RetrievePubKey(keystorePath, password)
if err != nil {
return nil, err
}
log.Warnf("PublicKey not detected, generating a new one: %v", pubKey)
} else {
pubKey = []byte(inputKey)
pubKey = blspubkey.BufferedPublicKey()
}
if err := ValidatorClient.startDB(ctx); err != nil {