sm9/bn256: fix add same bug

This commit is contained in:
Sun Yimin 2023-07-19 15:26:38 +08:00 committed by GitHub
parent b9bbf94b47
commit bbbf2612bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -133,7 +133,7 @@ func (c *curvePoint) Add(a, b *curvePoint) {
gfpSub(t, s2, s1)
if h.Equal(zero) == 1 && t.Equal(one) == 1 {
if h.Equal(zero) == 1 && t.Equal(zero) == 1 {
c.Double(a)
return
}

View File

@ -24,6 +24,16 @@ func TestG1AddNeg(t *testing.T) {
}
}
func TestG1AddSame(t *testing.T) {
g1, g2 := &G1{}, &G1{}
g1.Add(Gen1, Gen1)
g2.Double(Gen1)
if !g1.Equal(g2) {
t.Fail()
}
}
type g1BaseMultTest struct {
k string
}