Esempio n. 1
0
 private static GroupElementP3 P1ToP3(ref GroupElementP1 p) => new GroupElementP3
 {
     X = FieldElementOperations.Multiplication(ref p.X, ref p.T),
     Y = FieldElementOperations.Multiplication(ref p.Y, ref p.Z),
     Z = FieldElementOperations.Multiplication(ref p.Z, ref p.T),
     T = FieldElementOperations.Multiplication(ref p.X, ref p.Y)
 };
Esempio n. 2
0
        private static GroupElementP1 Madd(ref GroupElementP3 p, ref GroupElementP4 q)
        {
            var t0 = FieldElementOperations.Add(ref p.Z, ref p.Z);             /* D = 2*Z1 */
            var r  = new GroupElementP1();

            /* YpX1 = Y1+X1 */
            r.X = FieldElementOperations.Add(ref p.Y, ref p.X);

            /* YmX1 = Y1-X1 */
            r.Y = FieldElementOperations.Sub(ref p.Y, ref p.X);

            /* A = YpX1*ypx2 */
            r.Z = FieldElementOperations.Multiplication(ref r.X, ref q.YplusX);

            /* B = YmX1*ymx2 */
            r.Y = FieldElementOperations.Multiplication(ref r.Y, ref q.YminusX);

            /* C = xy2d2*T1 */
            r.T = FieldElementOperations.Multiplication(ref q.XY2D, ref p.T);

            /* X3 = A-B */
            r.X = FieldElementOperations.Sub(ref r.Z, ref r.Y);

            /* Y3 = A+B */
            r.Y = FieldElementOperations.Add(ref r.Z, ref r.Y);

            /* Z3 = D+C */
            r.Z = FieldElementOperations.Add(ref t0, ref r.T);

            /* T3 = D-C */
            r.T = FieldElementOperations.Sub(ref t0, ref r.T);

            return(r);
        }
Esempio n. 3
0
        private static GroupElementP1 P2ToP1(ref GroupElementP2 p)
        {
            var r = new GroupElementP1();

            /* XX=X1^2 */
            r.X = FieldElementOperations.Squared(ref p.X);

            /* YY=Y1^2 */
            r.Z = FieldElementOperations.Squared(ref p.Y);

            /* B=2*Z1^2 */
            r.T = FieldElementOperations.DoubleSquare(ref p.Z);

            /* A=X1+Y1 */
            r.Y = FieldElementOperations.Add(ref p.X, ref p.Y);

            /* AA=A^2 */
            var t0 = FieldElementOperations.Squared(ref r.Y);

            /* Y3=YY+XX */
            r.Y = FieldElementOperations.Add(ref r.Z, ref r.X);

            /* Z3=YY-XX */
            r.Z = FieldElementOperations.Sub(ref r.Z, ref r.X);

            /* X3=AA-Y3 */
            r.X = FieldElementOperations.Sub(ref t0, ref r.Y);

            /* T3=B-Z3 */
            r.T = FieldElementOperations.Sub(ref r.T, ref r.Z);

            return(r);
        }