Ejemplo n.º 1
0
 public AffineNielsPoint BitXor(AffineNielsPoint a)
 {
     return(new AffineNielsPoint
     {
         Y_plus_X = Y_plus_X.BitXor(a.Y_plus_X),
         Y_minus_X = Y_minus_X.BitXor(a.Y_minus_X),
         XY2d = XY2d.BitXor(XY2d)
     });
 }
Ejemplo n.º 2
0
        public CompletedPoint Add(AffineNielsPoint other)
        {
            var Y_plus_X  = Y.Add(X);
            var Y_minus_X = Y.Sub(X);
            var PP        = Y_plus_X.Mul(other.Y_plus_X);
            var MM        = Y_minus_X.Mul(other.Y_minus_X);
            var Txy2d     = T.Mul(other.XY2d);
            var Z2        = Z.Add(Z);

            return(new CompletedPoint
            {
                X = PP.Sub(MM),
                Y = PP.Add(MM),
                Z = Z2.Add(Txy2d),
                T = Z2.Sub(Txy2d)
            });
        }
            public AffineNielsPoint Select(sbyte x)
            {
                // Compute xabs = |x|
                var   xmask = x >> 7;
                sbyte xabs  = (sbyte)((x + xmask) ^ xmask);

                // Set t = 0 * P = identity
                var t = new AffineNielsPoint();

                for (var i = 1; i < 9; i++)
                {
                    // Copy `points[j-1] == j*P` onto `t` in constant time if `|x| == j`.
                    t.ConditionalAssign(affineNielsPoints[i - 1], xabs == i);
                }

                // Now t == |x| * P.
                byte neg_mask = (byte)(xmask & 1);

                t.ConditionalNegate(neg_mask == 1);
                // Now t == x * P.

                return(t);
            }
Ejemplo n.º 4
0
 public void ConditionalAssign(AffineNielsPoint a, bool choice)
 {
     Y_plus_X.ConditionalAssign(a.Y_plus_X, choice);
     Y_minus_X.ConditionalAssign(a.Y_minus_X, choice);
     XY2d.ConditionalAssign(a.XY2d, choice);
 }