Skip to content

Commit a164ed0

Browse files
committed
sphinx: access curve interface via btcec.S256()
1 parent a90e2d9 commit a164ed0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sphinx.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ func computeBlindingFactor(hopPubKey *btcec.PublicKey, hopSharedSecret []byte) [
504504
// blindGroupElement blinds the group element by performing scalar
505505
// multiplication of the group element by blindingFactor: G x blindingFactor.
506506
func blindGroupElement(hopPubKey *btcec.PublicKey, blindingFactor []byte) *btcec.PublicKey {
507-
newX, newY := hopPubKey.Curve.ScalarMult(hopPubKey.X, hopPubKey.Y, blindingFactor[:])
508-
return &btcec.PublicKey{hopPubKey.Curve, newX, newY}
507+
newX, newY := btcec.S256().ScalarMult(hopPubKey.X, hopPubKey.Y, blindingFactor[:])
508+
return &btcec.PublicKey{btcec.S256(), newX, newY}
509509
}
510510

511511
// generateSharedSecret generates the shared secret for a particular hop. The
@@ -516,7 +516,7 @@ func blindGroupElement(hopPubKey *btcec.PublicKey, blindingFactor []byte) *btcec
516516
// single SHA256 invocation. The resulting value is the shared secret.
517517
func generateSharedSecret(pub *btcec.PublicKey, priv *btcec.PrivateKey) [32]byte {
518518
s := &btcec.PublicKey{}
519-
x, y := pub.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes())
519+
x, y := btcec.S256().ScalarMult(pub.X, pub.Y, priv.D.Bytes())
520520
s.X = x
521521
s.Y = y
522522

@@ -739,7 +739,7 @@ func (r *Router) generateSharedSecret(dhKey *btcec.PublicKey) ([sha256.Size]byte
739739
var sharedSecret [sha256.Size]byte
740740

741741
// Ensure that the public key is on our curve.
742-
if !r.onionKey.Curve.IsOnCurve(dhKey.X, dhKey.Y) {
742+
if !btcec.S256().IsOnCurve(dhKey.X, dhKey.Y) {
743743
return sharedSecret, ErrInvalidOnionKey
744744
}
745745

0 commit comments

Comments
 (0)