tris: rename pk to secretKey

This commit is contained in:
Henry de Valence 2017-06-06 11:37:09 -07:00 committed by Peter Wu
parent d4b8398461
commit cd63e47f2c

6
13.go
View File

@ -374,7 +374,7 @@ func (c *Config) generateKeyShare(curveID CurveID) ([]byte, keyShare, error) {
return privateKey, keyShare{group: curveID, data: ecdhePublic}, nil 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 ks.group == X25519 {
if len(ks.data) != 32 { if len(ks.data) != 32 {
return nil return nil
@ -382,7 +382,7 @@ func deriveECDHESecret(ks keyShare, pk []byte) []byte {
var theirPublic, sharedKey, scalar [32]byte var theirPublic, sharedKey, scalar [32]byte
copy(theirPublic[:], ks.data) copy(theirPublic[:], ks.data)
copy(scalar[:], pk) copy(scalar[:], secretKey)
curve25519.ScalarMult(&sharedKey, &scalar, &theirPublic) curve25519.ScalarMult(&sharedKey, &scalar, &theirPublic)
return sharedKey[:] return sharedKey[:]
} }
@ -395,7 +395,7 @@ func deriveECDHESecret(ks keyShare, pk []byte) []byte {
if x == nil { if x == nil {
return nil return nil
} }
x, _ = curve.ScalarMult(x, y, pk) x, _ = curve.ScalarMult(x, y, secretKey)
xBytes := x.Bytes() xBytes := x.Bytes()
curveSize := (curve.Params().BitSize + 8 - 1) >> 3 curveSize := (curve.Params().BitSize + 8 - 1) >> 3
if len(xBytes) == curveSize { if len(xBytes) == curveSize {