Skip to content

Commit

Permalink
Test Issue 52075 - generic impl panic when scalar has too many leadin…
Browse files Browse the repository at this point in the history
…g zeroes
  • Loading branch information
Emman committed Apr 8, 2022
1 parent 6450e27 commit fc6fce3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sm2/p256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,17 @@ func TestP256CombinedMult(t *testing.T) {
t.Errorf("1×G + (-1)×G = (%d, %d), should be ∞", x, y)
}
}

func TestIssue52075(t *testing.T) {
Gx, Gy := P256().Params().Gx, P256().Params().Gy
scalar := make([]byte, 33)
scalar[32] = 1
x, y := P256().ScalarBaseMult(scalar)
if x.Cmp(Gx) != 0 || y.Cmp(Gy) != 0 {
t.Errorf("unexpected output (%v,%v)", x, y)
}
x, y = P256().ScalarMult(Gx, Gy, scalar)
if x.Cmp(Gx) != 0 || y.Cmp(Gy) != 0 {
t.Errorf("unexpected output (%v,%v)", x, y)
}
}

0 comments on commit fc6fce3

Please sign in to comment.