mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Fix Pubkey Not Specified Issues in External Keystore Imports (#6914)
* utilize pubkey from privkey if missing pubkey field in keystore * change tool as well * Merge refs/heads/master into strange-keystore * Merge refs/heads/master into strange-keystore
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/k0kubun/go-ansi"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/promptutil"
|
||||
"github.com/prysmaticlabs/prysm/validator/flags"
|
||||
v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
|
||||
@@ -88,9 +89,20 @@ func (dr *Keymanager) attemptDecryptKeystore(
|
||||
} else if err != nil {
|
||||
return nil, nil, "", errors.Wrap(err, "could not decrypt keystore")
|
||||
}
|
||||
pubKeyBytes, err := hex.DecodeString(keystore.Pubkey)
|
||||
if err != nil {
|
||||
return nil, nil, "", errors.Wrap(err, "could not decode pubkey from keystore")
|
||||
var pubKeyBytes []byte
|
||||
// Attempt to use the pubkey present in the keystore itself as a field. If unavailable,
|
||||
// then utilize the public key directly from the private key.
|
||||
if keystore.Pubkey != "" {
|
||||
pubKeyBytes, err = hex.DecodeString(keystore.Pubkey)
|
||||
if err != nil {
|
||||
return nil, nil, "", errors.Wrap(err, "could not decode pubkey from keystore")
|
||||
}
|
||||
} else {
|
||||
privKey, err := bls.SecretKeyFromBytes(privKeyBytes)
|
||||
if err != nil {
|
||||
return nil, nil, "", errors.Wrap(err, "could not initialize private key from bytes")
|
||||
}
|
||||
pubKeyBytes = privKey.PublicKey().Marshal()
|
||||
}
|
||||
return privKeyBytes, pubKeyBytes, password, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user