Skip to content

Commit 75e4df3

Browse files
author
gojuukaze
committed
copy fix: ECPoint.ScalarMult bnb-chain#295
1 parent 0ade537 commit 75e4df3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

crypto/ecpoint.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ func (p *ECPoint) Add(p1 *ECPoint) (*ECPoint, error) {
6060
}
6161

6262
func (p *ECPoint) ScalarMult(k *big.Int) *ECPoint {
63-
x, y := p.curve.ScalarMult(p.X(), p.Y(), k.Bytes())
63+
// fix by https://github.com/bnb-chain/tss-lib/pull/295/files
64+
kModN := new(big.Int).Mod(k, p.curve.Params().N)
65+
x, y := p.curve.ScalarMult(p.X(), p.Y(), kModN.Bytes())
6466
newP, err := NewECPoint(p.curve, x, y) // it must be on the curve, no need to check.
6567
if err != nil {
6668
panic(fmt.Errorf("scalar mult to an ecpoint %s", err.Error()))
@@ -105,7 +107,9 @@ func (p *ECPoint) EightInvEight() *ECPoint {
105107
}
106108

107109
func ScalarBaseMult(curve elliptic.Curve, k *big.Int) *ECPoint {
108-
x, y := curve.ScalarBaseMult(k.Bytes())
110+
// fix by https://github.com/bnb-chain/tss-lib/pull/295/files
111+
kModN := new(big.Int).Mod(k, curve.Params().N)
112+
x, y := curve.ScalarBaseMult(kModN.Bytes())
109113
p, err := NewECPoint(curve, x, y) // it must be on the curve, no need to check.
110114
if err != nil {
111115
panic(fmt.Errorf("scalar mult to an ecpoint %s", err.Error()))

0 commit comments

Comments
 (0)