Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

p2p: store private keys as PKCS#8 ASN.1 DER PEM #6119

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

algorandskiy
Copy link
Contributor

Summary

Before: p2p private key is stored raw in *.pem file. It is misleading since it does not contain an expected PEM content.
After: ED25519 key encoded as PKCS#8 ASN.1 DER and stored in PEM format, block type "PRIVATE KEY" in a *.key file.

Note: this implementation relies libp2p/crypto's implementation details that it uses golang's standard crypto.ed25519.PrivateKey underlying representation. It looks OK since we already have the same assumption in PeerIDChallengeSigner implementation.

Test Plan

Existing tests passed
Checked openssl understand this key

goal node -d . generate-p2pid
[Data Directory: /data]
PeerID: 12D3KooWLwzibGo6GkGVnyasbfQxxcjng3QJEAqXgMTPm7VtG9TG
Private key saved to /data/peerIDPrivKey.key

goal node -d . generate-p2pid
[Data Directory: /data]
PeerID: 12D3KooWLwzibGo6GkGVnyasbfQxxcjng3QJEAqXgMTPm7VtG9TG
Used existing key /data/peerIDPrivKey.key

openssl pkey -in peerIDPrivKey.key -text -noout
ED25519 Private-Key:
priv:
    34:10:37:ef:9e:31:38:e0:e8:89:28:b1:28:28:6f:
    80:17:48:20:ee:1e:dc:59:5f:3d:8e:16:2f:44:7e:
    ca:5a
pub:
    a5:64:f2:b2:e4:4f:b9:2d:25:74:84:61:1a:b4:71:
    5b:d1:ef:a7:81:59:2d:53:e7:5d:a6:bf:3f:18:3b:
    64:9b

cce
cce previously approved these changes Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 56.18%. Comparing base (81edd96) to head (52027bd).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
network/p2p/peerID.go 50.00% 6 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6119      +/-   ##
==========================================
- Coverage   56.20%   56.18%   -0.03%     
==========================================
  Files         492      492              
  Lines       69829    69851      +22     
==========================================
- Hits        39248    39244       -4     
- Misses      27915    27924       +9     
- Partials     2666     2683      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@algorandskiy algorandskiy merged commit d105841 into algorand:master Sep 3, 2024
19 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants