diff --git a/13.go b/13.go index f1b94f1a60..c5fa95fcbd 100644 --- a/13.go +++ b/13.go @@ -384,7 +384,7 @@ func (c *Config) generateKeyShare(curveID CurveID) ([]byte, keyShare, error) { return privateKey, keyShare{group: curveID, data: ecdhePublic}, nil } -func deriveECDHESecret(ks keyShare, pk []byte) []byte { +func deriveECDHESecret(ks keyShare, secretKey []byte) []byte { if ks.group == X25519 { if len(ks.data) != 32 { return nil @@ -392,7 +392,7 @@ func deriveECDHESecret(ks keyShare, pk []byte) []byte { var theirPublic, sharedKey, scalar [32]byte copy(theirPublic[:], ks.data) - copy(scalar[:], pk) + copy(scalar[:], secretKey) curve25519.ScalarMult(&sharedKey, &scalar, &theirPublic) return sharedKey[:] } @@ -405,7 +405,7 @@ func deriveECDHESecret(ks keyShare, pk []byte) []byte { if x == nil { return nil } - x, _ = curve.ScalarMult(x, y, pk) + x, _ = curve.ScalarMult(x, y, secretKey) xBytes := x.Bytes() curveSize := (curve.Params().BitSize + 8 - 1) >> 3 if len(xBytes) == curveSize {