1 package goldilocks
2
3 import fp "github.com/cloudflare/circl/math/fp448"
4
5 func (Curve) pull(P *twistPoint) *Point { return twistCurve{}.push(P) }
6 func (twistCurve) pull(P *Point) *twistPoint { return Curve{}.push(P) }
7
8
9 func (Curve) push(P *Point) *twistPoint {
10 Q := &twistPoint{}
11 Px, Py, Pz := &P.x, &P.y, &P.z
12 a, b, c, d, e, f, g, h := &Q.x, &Q.y, &Q.z, &fp.Elt{}, &Q.ta, &Q.x, &Q.y, &Q.tb
13 fp.Add(e, Px, Py)
14 fp.Sqr(a, Px)
15 fp.Sqr(b, Py)
16 fp.Sqr(c, Pz)
17 fp.Add(c, c, c)
18 *d = *a
19 fp.Sqr(e, e)
20 fp.Sub(e, e, a)
21 fp.Sub(e, e, b)
22 fp.Add(h, b, d)
23 fp.Sub(g, b, d)
24 fp.Sub(f, c, h)
25 fp.Mul(&Q.z, f, g)
26 fp.Mul(&Q.x, e, f)
27 fp.Mul(&Q.y, g, h)
28 return Q
29 }
30
31
32 func (twistCurve) push(P *twistPoint) *Point {
33 Q := &Point{}
34 Px, Py, Pz := &P.x, &P.y, &P.z
35 a, b, c, d, e, f, g, h := &Q.x, &Q.y, &Q.z, &fp.Elt{}, &Q.ta, &Q.x, &Q.y, &Q.tb
36 fp.Add(e, Px, Py)
37 fp.Sqr(a, Px)
38 fp.Sqr(b, Py)
39 fp.Sqr(c, Pz)
40 fp.Add(c, c, c)
41 fp.Neg(d, a)
42 fp.Sqr(e, e)
43 fp.Sub(e, e, a)
44 fp.Sub(e, e, b)
45 fp.Add(h, b, d)
46 fp.Sub(g, b, d)
47 fp.Sub(f, c, h)
48 fp.Mul(&Q.z, f, g)
49 fp.Mul(&Q.x, e, f)
50 fp.Mul(&Q.y, g, h)
51 return Q
52 }
53
View as plain text