mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-22 00:15:37 +01:00
refactor: use X25519 instead of ScalarBaseMult (#533)
As suggested in https://pkg.go.dev/golang.org/x/crypto/curve25519#ScalarBaseMult, use X25519 instead of ScalarBaseMult. When using Basepoint, it may employ some precomputed values, enhancing performance. Co-authored-by: Wade Simmons <wade@wades.im> Co-authored-by: Wade Simmons <wadey@slack-corp.com>
This commit is contained in:
@@ -337,10 +337,11 @@ func (nc *NebulaCertificate) VerifyPrivateKey(key []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var dst, key32 [32]byte
|
||||
copy(key32[:], key)
|
||||
curve25519.ScalarBaseMult(&dst, &key32)
|
||||
if !bytes.Equal(dst[:], nc.Details.PublicKey) {
|
||||
pub, err := curve25519.X25519(key, curve25519.Basepoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !bytes.Equal(pub, nc.Details.PublicKey) {
|
||||
return fmt.Errorf("public key in cert and private key supplied don't match")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user