arnaucube
arnaucube/cryptofunPublic Self-hosted repository
cryptofun/bn128/g2_test.go
bn128/g2_test.goRaw
 1package bn128
 2
 3import (
 4	"math/big"
 5	"testing"
 6
 7	"github.com/stretchr/testify/assert"
 8)
 9
10func TestG2(t *testing.T) {
11	bn128, err := NewBn128()
12	assert.Nil(t, err)
13
14	r1 := big.NewInt(int64(33))
15	r2 := big.NewInt(int64(44))
16
17	gr1 := bn128.G2.MulScalar(bn128.G2.G, bn128.Fq1.Copy(r1))
18	gr2 := bn128.G2.MulScalar(bn128.G2.G, bn128.Fq1.Copy(r2))
19
20	grsum1 := bn128.G2.Add(gr1, gr2)
21	r1r2 := bn128.Fq1.Add(r1, r2)
22	grsum2 := bn128.G2.MulScalar(bn128.G2.G, r1r2)
23
24	a := bn128.G2.Affine(grsum1)
25	b := bn128.G2.Affine(grsum2)
26	assert.Equal(t, a, b)
27}