-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load pem file for p2p signing #4478
Conversation
Codecov ReportBase: 73.87% // Head: 73.85% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## rc/v1.4.0 #4478 +/- ##
=============================================
- Coverage 73.87% 73.85% -0.02%
=============================================
Files 692 692
Lines 88308 88331 +23
=============================================
+ Hits 65234 65240 +6
- Misses 18160 18174 +14
- Partials 4914 4917 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
} | ||
|
||
func generateP2pKey(list []key) ([]key, error) { | ||
privateKey, publicKey, err := libp2pCrypto.GenerateSecp256k1Key(rand.Reader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from crypto/rand
cmd/keygenerator/main.go
Outdated
|
||
log = logger.GetOrCreate("keygenerator") | ||
|
||
validatorPubKeyConverter, _ = pubkeyConverter.NewHexPubkeyConverter(blsPubkeyLen) | ||
p2pPubKeyConverter, _ = pubkeyConverter.NewHexPubkeyConverter(blsPubkeyLen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not use the hex pub key converter here as we might want to see in the pem file something like:
-----BEGIN PRIVATE KEY for 16Uiu2HAm7deAWdBU41D6SUgtUEKC2VpXuRay4QqWnnPLqa8358Yv-----
https://github.com/ElrondNetwork/elrond-go/blob/5aed6c6ac41ded6321323a5195a03e6329fa50d0/p2p/libp2p/p2pSigner.go#L23
suggestion to check how is it done in the
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a separate converter for p2p encoding
p2p/libp2p/netMessenger.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
|
||
prvKey, _ := ecdsa.GenerateKey(btcec.S256(), randReader) | ||
log.Warn("createP2PPrivKey: using an already existing privary key for p2p signing") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use WARN here, a plain INFO will do the job. Also, we might display the ID generated from the key. There is a typo privary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the comment; since i don't have access to the peer ID here yet i did not displayed it later since it's already visible in the listening addr string
@@ -152,7 +153,7 @@ func newNetworkMessenger(args ArgsNetworkMessenger, messageSigning messageSignin | |||
return nil, fmt.Errorf("%w when creating a new network messenger", p2p.ErrNilPeersRatingHandler) | |||
} | |||
|
|||
p2pPrivKey, err := createP2PPrivKey(args.P2pConfig.Node.Seed) | |||
p2pPrivKey, err := createP2PPrivKey(args.P2pPrivKeyBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the cleanup for the p2p/libp2p/rand package? We should delete that package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted rand package
cmd/keygenerator/p2pConverter.go
Outdated
|
||
// Decode does nothing | ||
func (p *p2pConverter) Decode(humanReadable string) ([]byte, error) { | ||
return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might return ErrNotImplemented or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added not implemented error on return
func createP2PPrivKey(seed string) (*libp2pCrypto.Secp256k1PrivateKey, error) { | ||
randReader, err := randFactory.NewRandFactory(seed) | ||
func createP2PPrivKey(p2pPrivKeyBytes []byte) (libp2pCrypto.PrivKey, error) { | ||
if len(p2pPrivKeyBytes) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also log when you generate a p2p key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…-key-for-p2p Merge v1.4.0 into load private key for p2p
a0af5ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System test passed.
Description of the reasoning behind the pull request (what feature was missing / how the problem was manifesting itself / what was the motive behind the refactoring)
Proposed Changes
Testing procedure