Skip to content

Commit

Permalink
fix: ECPoint.ScalarMult
Browse files Browse the repository at this point in the history
  • Loading branch information
felicityin committed Apr 13, 2024
1 parent 7113b68 commit 859dd6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/ecpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func (p *ECPoint) Add(p1 *ECPoint) (*ECPoint, error) {
}

func (p *ECPoint) ScalarMult(k *big.Int) *ECPoint {
x, y := p.curve.ScalarMult(p.X(), p.Y(), k.Bytes())
kModN := new(big.Int).Mod(k, p.curve.Params().N)
x, y := p.curve.ScalarMult(p.X(), p.Y(), kModN.Bytes())
newP, err := NewECPoint(p.curve, x, y) // it must be on the curve, no need to check.
if err != nil {
panic(fmt.Errorf("scalar mult to an ecpoint %s", err.Error()))
Expand Down

0 comments on commit 859dd6b

Please sign in to comment.