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

     1  //go:build purego || !(amd64 || arm64 || ppc64 || ppc64le)
     2  
     3  package bn256
     4  
     5  func gfP12MovCond(res, a, b *gfP12, cond int) {
     6  	res.Select(a, b, cond)
     7  }
     8  
     9  func curvePointMovCond(res, a, b *curvePoint, cond int) {
    10  	res.x.Select(&a.x, &b.x, cond)
    11  	res.y.Select(&a.y, &b.y, cond)
    12  	res.z.Select(&a.z, &b.z, cond)
    13  	res.t.Select(&a.t, &b.t, cond)
    14  }
    15  
    16  func twistPointMovCond(res, a, b *twistPoint, cond int) {
    17  	// Select sets q to p1 if cond == 1, and to p2 if cond == 0.
    18  	res.x.Select(&a.x, &b.x, cond)
    19  	res.y.Select(&a.y, &b.y, cond)
    20  	res.z.Select(&a.z, &b.z, cond)
    21  	res.t.Select(&a.t, &b.t, cond)
    22  }
    23  
    24  func gfpCopy(res, in *gfP) {
    25  	res[0] = in[0]
    26  	res[1] = in[1]
    27  	res[2] = in[2]
    28  	res[3] = in[3]
    29  }
    30  
    31  func gfp2Copy(res, in *gfP2) {
    32  	gfpCopy(&res.x, &in.x)
    33  	gfpCopy(&res.y, &in.y)
    34  }
    35  
    36  func gfp4Copy(res, in *gfP4) {
    37  	gfpCopy(&res.x.x, &in.x.x)
    38  	gfpCopy(&res.x.y, &in.x.y)
    39  	gfpCopy(&res.y.x, &in.y.x)
    40  	gfpCopy(&res.y.y, &in.y.y)
    41  }
    42  
    43  func gfp6Copy(res, in *gfP6) {
    44  	gfpCopy(&res.x.x, &in.x.x)
    45  	gfpCopy(&res.x.y, &in.x.y)
    46  	gfpCopy(&res.y.x, &in.y.x)
    47  	gfpCopy(&res.y.y, &in.y.y)
    48  	gfpCopy(&res.z.x, &in.z.x)
    49  	gfpCopy(&res.z.y, &in.z.y)
    50  }
    51  
    52  func gfp12Copy(res, in *gfP12) {
    53  	gfpCopy(&res.x.x.x, &in.x.x.x)
    54  	gfpCopy(&res.x.x.y, &in.x.x.y)
    55  	gfpCopy(&res.x.y.x, &in.x.y.x)
    56  	gfpCopy(&res.x.y.y, &in.x.y.y)
    57  
    58  	gfpCopy(&res.y.x.x, &in.y.x.x)
    59  	gfpCopy(&res.y.x.y, &in.y.x.y)
    60  	gfpCopy(&res.y.y.x, &in.y.y.x)
    61  	gfpCopy(&res.y.y.y, &in.y.y.y)
    62  
    63  	gfpCopy(&res.z.x.x, &in.z.x.x)
    64  	gfpCopy(&res.z.x.y, &in.z.x.y)
    65  	gfpCopy(&res.z.y.x, &in.z.y.x)
    66  	gfpCopy(&res.z.y.y, &in.z.y.y)
    67  }