github.com/cloudflare/circl@v1.5.0/ecc/fourq/point_generic.go (about)

     1  //go:build !amd64 || purego
     2  // +build !amd64 purego
     3  
     4  package fourq
     5  
     6  func doubleGeneric(P *pointR1) {
     7  	Px := &P.X
     8  	Py := &P.Y
     9  	Pz := &P.Z
    10  	Pta := &P.Ta
    11  	Ptb := &P.Tb
    12  	a := Px
    13  	b := Py
    14  	c := Pz
    15  	d := Pta
    16  	e := Ptb
    17  	f := b
    18  	g := a
    19  	fqAdd(e, Px, Py)
    20  	fqSqr(a, Px)
    21  	fqSqr(b, Py)
    22  	fqSqr(c, Pz)
    23  	fqAdd(c, c, c)
    24  	fqAdd(d, a, b)
    25  	fqSqr(e, e)
    26  	fqSub(e, e, d)
    27  	fqSub(f, b, a)
    28  	fqSub(g, c, f)
    29  	fqMul(Pz, f, g)
    30  	fqMul(Px, e, g)
    31  	fqMul(Py, d, f)
    32  }
    33  
    34  func addGeneric(P *pointR1, Q *pointR2) {
    35  	addYX := &Q.addYX
    36  	subYX := &Q.subYX
    37  	z2 := &Q.z2
    38  	dt2 := &Q.dt2
    39  	Px := &P.X
    40  	Py := &P.Y
    41  	Pz := &P.Z
    42  	Pta := &P.Ta
    43  	Ptb := &P.Tb
    44  	a := Px
    45  	b := Py
    46  	c := &Fq{}
    47  	d := b
    48  	e := Pta
    49  	f := a
    50  	g := b
    51  	h := Ptb
    52  	fqMul(c, Pta, Ptb)
    53  	fqSub(h, b, a)
    54  	fqAdd(b, b, a)
    55  	fqMul(a, h, subYX)
    56  	fqMul(b, b, addYX)
    57  	fqSub(e, b, a)
    58  	fqAdd(h, b, a)
    59  	fqMul(d, Pz, z2)
    60  	fqMul(c, c, dt2)
    61  	fqSub(f, d, c)
    62  	fqAdd(g, d, c)
    63  	fqMul(Pz, f, g)
    64  	fqMul(Px, e, f)
    65  	fqMul(Py, g, h)
    66  }
    67  
    68  func mixAddGeneric(P *pointR1, Q *pointR3) {
    69  	addYX := &Q.addYX
    70  	subYX := &Q.subYX
    71  	dt2 := &Q.dt2
    72  	Px := &P.X
    73  	Py := &P.Y
    74  	Pz := &P.Z
    75  	Pta := &P.Ta
    76  	Ptb := &P.Tb
    77  	a := Px
    78  	b := Py
    79  	c := &Fq{}
    80  	d := b
    81  	e := Pta
    82  	f := a
    83  	g := b
    84  	h := Ptb
    85  	fqMul(c, Pta, Ptb)
    86  	fqSub(h, b, a)
    87  	fqAdd(b, b, a)
    88  	fqMul(a, h, subYX)
    89  	fqMul(b, b, addYX)
    90  	fqSub(e, b, a)
    91  	fqAdd(h, b, a)
    92  	fqAdd(d, Pz, Pz)
    93  	fqMul(c, c, dt2)
    94  	fqSub(f, d, c)
    95  	fqAdd(g, d, c)
    96  	fqMul(Pz, f, g)
    97  	fqMul(Px, e, f)
    98  	fqMul(Py, g, h)
    99  }