Skip to content

Commit

Permalink
tris: rename pk to secretKey
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalence authored and FiloSottile committed Jul 5, 2017
1 parent bc4864b commit 6e74107
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 13.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ 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
}

var theirPublic, sharedKey, scalar [32]byte
copy(theirPublic[:], ks.data)
copy(scalar[:], pk)
copy(scalar[:], secretKey)
curve25519.ScalarMult(&sharedKey, &scalar, &theirPublic)
return sharedKey[:]
}
Expand All @@ -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 {
Expand Down

0 comments on commit 6e74107

Please sign in to comment.