Skip to content

Commit

Permalink
Remove custom ed25519 private to public key conversion. (#15416)
Browse files Browse the repository at this point in the history
* Minor.

* Minor
  • Loading branch information
pavel-raykov authored Dec 2, 2024
1 parent 04fb045 commit dcc6a36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-penguins-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#updated Remove custom ed25519 private to public key conversion.
10 changes: 2 additions & 8 deletions core/services/keystore/keys/csakey/key_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (raw Raw) Key() KeyV2 {
privKey := ed25519.PrivateKey(raw)
return KeyV2{
privateKey: &privKey,
PublicKey: ed25519PubKeyFromPrivKey(privKey),
PublicKey: privKey.Public().(ed25519.PublicKey),
}
}

Expand Down Expand Up @@ -66,7 +66,7 @@ func MustNewV2XXXTestingOnly(k *big.Int) KeyV2 {
privKey := ed25519.NewKeyFromSeed(seed)
return KeyV2{
privateKey: &privKey,
PublicKey: ed25519PubKeyFromPrivKey(privKey),
PublicKey: privKey.Public().(ed25519.PublicKey),
Version: 2,
}
}
Expand All @@ -90,9 +90,3 @@ func (k KeyV2) String() string {
func (k KeyV2) GoString() string {
return k.String()
}

func ed25519PubKeyFromPrivKey(privKey ed25519.PrivateKey) ed25519.PublicKey {
publicKey := make([]byte, ed25519.PublicKeySize)
copy(publicKey, privKey[32:])
return publicKey
}
4 changes: 1 addition & 3 deletions core/services/keystore/keys/solkey/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ type Raw []byte
// Key gets the Key
func (raw Raw) Key() Key {
privKey := ed25519.NewKeyFromSeed(raw)
pubKey := make([]byte, ed25519.PublicKeySize)
copy(pubKey, privKey[ed25519.PublicKeySize:])
return Key{
privkey: privKey,
pubKey: pubKey,
pubKey: privKey.Public().(ed25519.PublicKey),
}
}

Expand Down

0 comments on commit dcc6a36

Please sign in to comment.