Пример #1
0
        private static void PointDouble(PointExt r)
        {
            uint[] B = X448Field.Create();
            uint[] C = X448Field.Create();
            uint[] D = X448Field.Create();
            uint[] E = X448Field.Create();
            uint[] H = X448Field.Create();
            uint[] J = X448Field.Create();

            X448Field.Add(r.x, r.y, B);
            X448Field.Sqr(B, B);
            X448Field.Sqr(r.x, C);
            X448Field.Sqr(r.y, D);
            X448Field.Add(C, D, E);
            X448Field.Carry(E);
            X448Field.Sqr(r.z, H);
            X448Field.Add(H, H, H);
            X448Field.Carry(H);
            X448Field.Sub(E, H, J);
            X448Field.Sub(B, E, B);
            X448Field.Sub(C, D, C);
            X448Field.Mul(B, J, r.x);
            X448Field.Mul(E, C, r.y);
            X448Field.Mul(E, J, r.z);
        }
Пример #2
0
        private static void PointAddPrecomp(PointPrecomp p, PointExt r)
        {
            uint[] B = X448Field.Create();
            uint[] C = X448Field.Create();
            uint[] D = X448Field.Create();
            uint[] E = X448Field.Create();
            uint[] F = X448Field.Create();
            uint[] G = X448Field.Create();
            uint[] H = X448Field.Create();

            X448Field.Sqr(r.z, B);
            X448Field.Mul(p.x, r.x, C);
            X448Field.Mul(p.y, r.y, D);
            X448Field.Mul(C, D, E);
            X448Field.Mul(E, -C_d, E);
            //X448Field.Apm(B, E, F, G);
            X448Field.Add(B, E, F);
            X448Field.Sub(B, E, G);
            X448Field.Add(p.x, p.y, B);
            X448Field.Add(r.x, r.y, E);
            X448Field.Mul(B, E, H);
            //X448Field.Apm(D, C, B, E);
            X448Field.Add(D, C, B);
            X448Field.Sub(D, C, E);
            X448Field.Carry(B);
            X448Field.Sub(H, B, H);
            X448Field.Mul(H, r.z, H);
            X448Field.Mul(E, r.z, E);
            X448Field.Mul(F, H, r.x);
            X448Field.Mul(E, G, r.y);
            X448Field.Mul(F, G, r.z);
        }
Пример #3
0
        private static void PointAddVar(bool negate, PointExt p, PointExt r)
        {
            uint[] A = X448Field.Create();
            uint[] B = X448Field.Create();
            uint[] C = X448Field.Create();
            uint[] D = X448Field.Create();
            uint[] E = X448Field.Create();
            uint[] F = X448Field.Create();
            uint[] G = X448Field.Create();
            uint[] H = X448Field.Create();

            uint[] b, e, f, g;
            if (negate)
            {
                b = E; e = B; f = G; g = F;
                X448Field.Sub(p.y, p.x, H);
            }
            else
            {
                b = B; e = E; f = F; g = G;
                X448Field.Add(p.y, p.x, H);
            }

            X448Field.Mul(p.z, r.z, A);
            X448Field.Sqr(A, B);
            X448Field.Mul(p.x, r.x, C);
            X448Field.Mul(p.y, r.y, D);
            X448Field.Mul(C, D, E);
            X448Field.Mul(E, -C_d, E);
            //X448Field.Apm(B, E, F, G);
            X448Field.Add(B, E, f);
            X448Field.Sub(B, E, g);
            X448Field.Add(r.x, r.y, E);
            X448Field.Mul(H, E, H);
            //X448Field.Apm(D, C, B, E);
            X448Field.Add(D, C, b);
            X448Field.Sub(D, C, e);
            X448Field.Carry(b);
            X448Field.Sub(H, B, H);
            X448Field.Mul(H, A, H);
            X448Field.Mul(E, A, E);
            X448Field.Mul(F, H, r.x);
            X448Field.Mul(E, G, r.y);
            X448Field.Mul(F, G, r.z);
        }
Пример #4
0
        private static int CheckPoint(uint[] x, uint[] y, uint[] z)
        {
            uint[] t = X448Field.Create();
            uint[] u = X448Field.Create();
            uint[] v = X448Field.Create();
            uint[] w = X448Field.Create();

            X448Field.Sqr(x, u);
            X448Field.Sqr(y, v);
            X448Field.Sqr(z, w);
            X448Field.Mul(u, v, t);
            X448Field.Add(u, v, u);
            X448Field.Mul(u, w, u);
            X448Field.Sqr(w, w);
            X448Field.Mul(t, -C_d, t);
            X448Field.Sub(t, w, t);
            X448Field.Add(t, u, t);
            X448Field.Normalize(t);

            return(X448Field.IsZero(t));
        }