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.

27 lines
541 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.MulScalar(bn128.G2.G, bn128.Fq1.Copy(r1))
  13. gr2 := bn128.G2.MulScalar(bn128.G2.G, bn128.Fq1.Copy(r2))
  14. grsum1 := bn128.G2.Add(gr1, gr2)
  15. r1r2 := bn128.Fq1.Add(r1, r2)
  16. grsum2 := bn128.G2.MulScalar(bn128.G2.G, r1r2)
  17. a := bn128.G2.Affine(grsum1)
  18. b := bn128.G2.Affine(grsum2)
  19. assert.Equal(t, a, b)
  20. }