You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
559 B

  1. package bn128
  2. import (
  3. "math/big"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestG2(t *testing.T) {
  8. bn128, err := NewBn128()
  9. assert.Nil(t, err)
  10. r1 := big.NewInt(int64(33))
  11. r2 := big.NewInt(int64(44))
  12. gr1 := bn128.G2.Affine(bn128.G2.MulScalar(bn128.G2.G, r1))
  13. gr2 := bn128.G2.Affine(bn128.G2.MulScalar(bn128.G2.G, r2))
  14. grsum1 := bn128.G2.Affine(bn128.G2.Add(gr1, gr2))
  15. r1r2 := bn128.Fq1.Affine(bn128.Fq1.Add(r1, r2))
  16. grsum2 := bn128.G2.Affine(bn128.G2.MulScalar(bn128.G2.G, r1r2))
  17. assert.True(t, bn128.G2.Equal(grsum1, grsum2))
  18. }