github.com/emmansun/gmsm@v0.29.1/sm9/bn256/select_test.go (about)

     1  package bn256
     2  
     3  import "testing"
     4  
     5  func BenchmarkGfP12Copy(b *testing.B) {
     6  	x := &gfP12{
     7  		testdataP4,
     8  		testdataP4,
     9  		testdataP4,
    10  	}
    11  	res := &gfP12{}
    12  	b.ReportAllocs()
    13  	b.ResetTimer()
    14  	for i := 0; i < b.N; i++ {
    15  		gfp12Copy(res, x)
    16  	}
    17  }
    18  
    19  func gfpCopyForTest(res, in *gfP) {
    20  	res[0] = in[0]
    21  	res[1] = in[1]
    22  	res[2] = in[2]
    23  	res[3] = in[3]
    24  }
    25  
    26  func gfp2CopyForTest(res, in *gfP2) {
    27  	gfpCopyForTest(&res.x, &in.x)
    28  	gfpCopyForTest(&res.y, &in.y)
    29  }
    30  
    31  func gfp4CopyForTest(res, in *gfP4) {
    32  	gfp2CopyForTest(&res.x, &in.x)
    33  	gfp2CopyForTest(&res.y, &in.y)
    34  }
    35  
    36  func gfp12CopyForTest(res, in *gfP12) {
    37  	gfp4CopyForTest(&res.x, &in.x)
    38  	gfp4CopyForTest(&res.y, &in.y)
    39  	gfp4CopyForTest(&res.z, &in.z)
    40  }
    41  
    42  func BenchmarkGfP12Set(b *testing.B) {
    43  	x := &gfP12{
    44  		testdataP4,
    45  		testdataP4,
    46  		testdataP4,
    47  	}
    48  	res := &gfP12{}
    49  	b.ReportAllocs()
    50  	b.ResetTimer()
    51  	for i := 0; i < b.N; i++ {
    52  		gfp12CopyForTest(res, x)
    53  	}
    54  }
    55  
    56  func TestCurvePointMovCond(t *testing.T) {
    57  	curve1 := &curvePoint{}
    58  	res := &curvePoint{}
    59  	curvePointMovCond(res, curve1, curveGen, 0)
    60  	if !res.Equal(curveGen) {
    61  		t.Errorf("not expected")
    62  	}
    63  }