CheckFieldElements() public static méthode

public static CheckFieldElements ( ECFieldElement a, ECFieldElement b ) : void
a ECFieldElement
b ECFieldElement
Résultat void
Exemple #1
0
        /**
         * @param curve base curve
         * @param x x point
         * @param y y point
         * @param withCompression true if encode with point compression.
         */
        public F2mPoint(
            ECCurve curve,
            ECFieldElement x,
            ECFieldElement y,
            bool withCompression)
            : base(curve, x, y)
        {
            if ((x != null && y == null) || (x == null && y != null))
            {
                throw new ArgumentException("Exactly one of the field elements is null");
            }

            if (x != null)
            {
                // Check if x and y are elements of the same field
                F2mFieldElement.CheckFieldElements(this.x, this.y);

                if (curve != null)
                {
                    // Check if x and a are elements of the same field
                    F2mFieldElement.CheckFieldElements(this.x, this.curve.A);
                }
            }

            this.withCompression = withCompression;
        }
Exemple #2
0
 public F2mPoint(ECCurve curve, ECFieldElement x, ECFieldElement y, bool withCompression) : base(curve, x, y, withCompression)
 {
     if ((x == null) != (y == null))
     {
         throw new ArgumentException("Exactly one of the field elements is null");
     }
     if (x != null)
     {
         F2mFieldElement.CheckFieldElements(x, y);
         if (curve != null)
         {
             F2mFieldElement.CheckFieldElements(x, curve.A);
         }
     }
 }
Exemple #3
0
        /* (non-Javadoc)
         * @see Org.BouncyCastle.Math.EC.ECPoint#add(Org.BouncyCastle.Math.EC.ECPoint)
         */
        public override ECPoint Add(
            ECPoint b)
        {
            // Check, if points are on the same curve
            if (!curve.Equals(b.Curve))
            {
                throw new ArgumentException("Only points on the same curve can be added");
            }

            if (this.IsInfinity)
            {
                return(b);
            }

            if (b.IsInfinity)
            {
                return(this);
            }

            F2mFieldElement.CheckFieldElements(this.x, b.X);
            F2mFieldElement x2 = (F2mFieldElement)b.X;
            F2mFieldElement y2 = (F2mFieldElement)b.Y;

            // Check if b = this or b = -this
            if (this.x.Equals(x2))
            {
                // this = b, i.e. this must be doubled
                if (this.y.Equals(y2))
                {
                    return(this.Twice());
                }

                // this = -b, i.e. the result is the point at infinity
                return(this.curve.Infinity);
            }

            F2mFieldElement lambda
                = (F2mFieldElement)(this.y.Add(y2)).Divide(this.x.Add(x2));

            F2mFieldElement x3
                = (F2mFieldElement)lambda.Square().Add(lambda).Add(this.x).Add(x2).Add(this.curve.A);

            F2mFieldElement y3
                = (F2mFieldElement)lambda.Multiply(this.x.Add(x3)).Add(x3).Add(this.y);

            return(new F2mPoint(curve, x3, y3, withCompression));
        }
Exemple #4
0
 public F2mPoint(ECCurve curve, ECFieldElement x, ECFieldElement y, bool withCompression)
     : base(curve, x, y, withCompression)
 {
     //IL_001a: Unknown result type (might be due to invalid IL or missing references)
     if (x == null != (y == null))
     {
         throw new ArgumentException("Exactly one of the field elements is null");
     }
     if (x != null)
     {
         F2mFieldElement.CheckFieldElements(x, y);
         if (curve != null)
         {
             F2mFieldElement.CheckFieldElements(x, curve.A);
         }
     }
 }