...
1
2
3
4
5
6
7 package fiat
8
9
10
11
12 func (e *P224Element) Invert(x *P224Element) *P224Element {
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 var z = new(P224Element).Set(e)
34 var t0 = new(P224Element)
35 var t1 = new(P224Element)
36 var t2 = new(P224Element)
37
38 z.Square(x)
39 t0.Mul(x, z)
40 z.Square(t0)
41 z.Mul(x, z)
42 t1.Square(z)
43 for s := 1; s < 3; s++ {
44 t1.Square(t1)
45 }
46 t1.Mul(z, t1)
47 t2.Square(t1)
48 for s := 1; s < 6; s++ {
49 t2.Square(t2)
50 }
51 t1.Mul(t1, t2)
52 for s := 0; s < 2; s++ {
53 t1.Square(t1)
54 }
55 t0.Mul(t0, t1)
56 t1.Square(t0)
57 for s := 1; s < 3; s++ {
58 t1.Square(t1)
59 }
60 z.Mul(z, t1)
61 t1.Square(z)
62 for s := 1; s < 14; s++ {
63 t1.Square(t1)
64 }
65 t0.Mul(t0, t1)
66 t1.Square(t0)
67 for s := 1; s < 17; s++ {
68 t1.Square(t1)
69 }
70 z.Mul(z, t1)
71 t1.Square(z)
72 for s := 1; s < 48; s++ {
73 t1.Square(t1)
74 }
75 z.Mul(z, t1)
76 t1.Square(z)
77 for s := 1; s < 31; s++ {
78 t1.Square(t1)
79 }
80 t0.Mul(t0, t1)
81 for s := 0; s < 97; s++ {
82 t0.Square(t0)
83 }
84 z.Mul(z, t0)
85
86 return e.Set(z)
87 }
88
View as plain text