Inheritance: ECFieldElement
示例#1
0
        public override ECFieldElement Add(ECFieldElement b)
        {
            LongArray       longArray       = x.Copy();
            F2mFieldElement f2mFieldElement = (F2mFieldElement)b;

            longArray.AddShiftedByWords(f2mFieldElement.x, 0);
            return(new F2mFieldElement(m, ks, longArray));
        }
示例#2
0
 public virtual bool Equals(F2mFieldElement other)
 {
     if (m == other.m && representation == other.representation && Arrays.AreEqual(ks, other.ks))
     {
         return(x.Equals(other.x));
     }
     return(false);
 }
 public virtual bool Equals(
     F2mFieldElement other)
 {
     return((this.m == other.m) &&
            (this.representation == other.representation) &&
            Arrays.AreEqual(this.ks, other.ks) &&
            (this.x.Equals(other.x)));
 }
        public override ECFieldElement Add(ECFieldElement b)
        {
            LongArray       x       = this.x.Copy();
            F2mFieldElement element = (F2mFieldElement)b;

            x.AddShiftedByWords(element.x, 0);
            return(new F2mFieldElement(this.m, this.ks, x));
        }
示例#5
0
        public override ECFieldElement Multiply(
            ECFieldElement b)
        {
            F2mFieldElement bF2m = (F2mFieldElement)b;
            IntArray        mult = x.Multiply(bF2m.x, m);

            mult.Reduce(m, new int[] { k1, k2, k3 });
            return(new F2mFieldElement(m, k1, k2, k3, mult));
        }
示例#6
0
        public override ECFieldElement Add(
            ECFieldElement b)
        {
            IntArray        iarrClone = (IntArray)this.x.Clone();
            F2mFieldElement bF2m      = (F2mFieldElement)b;

            iarrClone.AddShifted(bF2m.x, 0);
            return(new F2mFieldElement(m, k1, k2, k3, iarrClone));
        }
 protected bool Equals(
     F2mFieldElement other)
 {
     return(m == other.m &&
            k1 == other.k1 &&
            k2 == other.k2 &&
            k3 == other.k3 &&
            representation == other.representation &&
            base.Equals(other));
 }
示例#8
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            F2mFieldElement f2mFieldElement = obj as F2mFieldElement;

            return(f2mFieldElement != null && this.Equals(f2mFieldElement));
        }
示例#9
0
            private ECPoint CreatePoint(long[] x, long[] y)
            {
                int m = m_outer.m;

                int[] ks = m_outer.IsTrinomial() ? new int[] { m_outer.k1 } : new int[] { m_outer.k1, m_outer.k2, m_outer.k3 };

                ECFieldElement X = new F2mFieldElement(m, ks, new LongArray(x));
                ECFieldElement Y = new F2mFieldElement(m, ks, new LongArray(y));

                return(m_outer.CreateRawPoint(X, Y, false));
            }
示例#10
0
        public override ECFieldElement Add(
            ECFieldElement b)
        {
            // No check performed here for performance reasons. Instead the
            // elements involved are checked in ECPoint.F2m
            // checkFieldElements(this, b);
            LongArray       iarrClone = this.x.Copy();
            F2mFieldElement bF2m      = (F2mFieldElement)b;

            iarrClone.AddShiftedByWords(bF2m.x, 0);
            return(new F2mFieldElement(m, ks, iarrClone));
        }
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            F2mFieldElement other = obj as F2mFieldElement;

            if (other == null)
            {
                return(false);
            }
            return(this.Equals(other));
        }
示例#12
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            F2mFieldElement f2mFieldElement = obj as F2mFieldElement;

            if (f2mFieldElement == null)
            {
                return(false);
            }
            return(Equals(f2mFieldElement));
        }
示例#13
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);
         }
     }
 }
        public override ECFieldElement Multiply(
            ECFieldElement b)
        {
            // Right-to-left comb multiplication in the IntArray
            // Input: Binary polynomials a(z) and b(z) of degree at most m-1
            // Output: c(z) = a(z) * b(z) mod f(z)

            // No check performed here for performance reasons. Instead the
            // elements involved are checked in ECPoint.F2m
            // checkFieldElements(this, b);
            F2mFieldElement bF2m = (F2mFieldElement)b;
            IntArray        mult = x.Multiply(bF2m.x, m);

            mult.Reduce(m, new int[] { k1, k2, k3 });
            return(new F2mFieldElement(m, k1, k2, k3, mult));
        }
示例#15
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));
        }
示例#16
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);
         }
     }
 }
示例#17
0
        public static void CheckFieldElements(ECFieldElement a, ECFieldElement b)
        {
            if (!(a is F2mFieldElement) || !(b is F2mFieldElement))
            {
                throw new ArgumentException("Field elements are not both instances of F2mFieldElement");
            }
            F2mFieldElement f2mFieldElement  = (F2mFieldElement)a;
            F2mFieldElement f2mFieldElement2 = (F2mFieldElement)b;

            if (f2mFieldElement.representation != f2mFieldElement2.representation)
            {
                throw new ArgumentException("One of the F2m field elements has incorrect representation");
            }
            if (f2mFieldElement.m != f2mFieldElement2.m || !Arrays.AreEqual(f2mFieldElement.ks, f2mFieldElement2.ks))
            {
                throw new ArgumentException("Field elements are not elements of the same field F2m");
            }
        }
示例#18
0
        public override ECPoint Twice()
        {
            if (this.IsInfinity)
            {
                return(this);
            }

            if (this.x.ToBigInteger().SignValue == 0)
            {
                return(this.curve.Infinity);
            }

            F2mFieldElement lambda = (F2mFieldElement)this.x.Add(this.y.Divide(this.x));
            F2mFieldElement x2     = (F2mFieldElement)lambda.Square().Add(lambda).Add(this.curve.A);
            ECFieldElement  ONE    = this.curve.FromBigInteger(BigInteger.One);
            F2mFieldElement y2     = (F2mFieldElement)this.x.Square().Add(
                x2.Multiply(lambda.Add(ONE)));

            return(new F2mPoint(this.curve, x2, y2, withCompression));
        }
示例#19
0
        /**
         * Adds another <code>ECPoints.F2m</code> to <code>this</code> without
         * checking if both points are on the same curve. Used by multiplication
         * algorithms, because there all points are a multiple of the same point
         * and hence the checks can be omitted.
         * @param b The other <code>ECPoints.F2m</code> to add to
         * <code>this</code>.
         * @return <code>this + b</code>
         */
        internal F2mPoint AddSimple(F2mPoint b)
        {
            if (this.IsInfinity)
            {
                return(b);
            }

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

            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((F2mPoint)this.Twice());
                }

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

            ECFieldElement xSum = this.x.Add(x2);

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

            F2mFieldElement x3
                = (F2mFieldElement)lambda.Square().Add(lambda).Add(xSum).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));
        }
示例#20
0
        /* (non-Javadoc)
         * @see Org.BouncyCastle.Math.EC.ECPoint#twice()
         */
        public override ECPoint Twice()
        {
            // Twice identity element (point at infinity) is identity
            if (this.IsInfinity)
            {
                return(this);
            }

            // if x1 == 0, then (x1, y1) == (x1, x1 + y1)
            // and hence this = -this and thus 2(x1, y1) == infinity
            if (this.x.ToBigInteger().SignValue == 0)
            {
                return(this.curve.Infinity);
            }

            F2mFieldElement lambda = (F2mFieldElement)this.x.Add(this.y.Divide(this.x));
            F2mFieldElement x3     = (F2mFieldElement)lambda.Square().Add(lambda).Add(this.curve.A);
            F2mFieldElement y3     = (F2mFieldElement)this.x.Square().Add(lambda.Multiply(x3)).Add(x3);

            return(new F2mPoint(this.curve, x3, y3, withCompression));
        }
示例#21
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, withCompression)
        {
            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);

                // Check if x and a are elements of the same field
                F2mFieldElement.CheckFieldElements(this.x, this.curve.A);
            }
        }
示例#22
0
        public static void CheckFieldElements(ECFieldElement a, ECFieldElement b)
        {
            //IL_0015: Unknown result type (might be due to invalid IL or missing references)
            //IL_003c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0068: Unknown result type (might be due to invalid IL or missing references)
            if (!(a is F2mFieldElement) || !(b is F2mFieldElement))
            {
                throw new ArgumentException("Field elements are not both instances of F2mFieldElement");
            }
            F2mFieldElement f2mFieldElement  = (F2mFieldElement)a;
            F2mFieldElement f2mFieldElement2 = (F2mFieldElement)b;

            if (f2mFieldElement.representation != f2mFieldElement2.representation)
            {
                throw new ArgumentException("One of the F2m field elements has incorrect representation");
            }
            if (f2mFieldElement.m != f2mFieldElement2.m || !Arrays.AreEqual(f2mFieldElement.ks, f2mFieldElement2.ks))
            {
                throw new ArgumentException("Field elements are not elements of the same field F2m");
            }
        }
示例#23
0
        /**
         * Decompresses a compressed point P = (xp, yp) (X9.62 s 4.2.2).
         *
         * @param xEnc
         *            The encoding of field element xp.
         * @param ypBit
         *            ~yp, an indication bit for the decompression of yp.
         * @return the decompressed point.
         */
        private ECPoint decompressPoint(
            byte[] xEnc,
            int ypBit)
        {
            ECFieldElement xp = new F2mFieldElement(
                this.m, this.k1, this.k2, this.k3, new BigInteger(1, xEnc));
            ECFieldElement yp = null;

            if (xp.x.SignValue == 0)
            {
                yp = (F2mFieldElement)b;
                for (int i = 0; i < m - 1; i++)
                {
                    yp = yp.Square();
                }
            }
            else
            {
                ECFieldElement beta = xp.Add(a).Add(
                    b.Multiply(xp.Square().Invert()));
                ECFieldElement z = solveQuadradicEquation(beta);
                if (z == null)
                {
                    throw new ArithmeticException("Invalid point compression");
                }
                int zBit = 0;
                if (z.x.TestBit(0))
                {
                    zBit = 1;
                }
                if (zBit != ypBit)
                {
                    z = z.Add(new F2mFieldElement(this.m, this.k1, this.k2,
                                                  this.k3, BigInteger.One));
                }
                yp = xp.Multiply(z);
            }

            return(new F2mPoint(this, xp, yp));
        }
示例#24
0
        internal F2mPoint AddSimple(F2mPoint b)
        {
            if (this.IsInfinity)
            {
                return(b);
            }

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

            F2mFieldElement x2 = (F2mFieldElement)b.X;
            F2mFieldElement y2 = (F2mFieldElement)b.Y;

            if (this.x.Equals(x2))
            {
                if (this.y.Equals(y2))
                {
                    return((F2mPoint)this.Twice());
                }

                return((F2mPoint)this.curve.Infinity);
            }

            ECFieldElement xSum = this.x.Add(x2);

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

            F2mFieldElement x3
                = (F2mFieldElement)lambda.Square().Add(lambda).Add(xSum).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));
        }
示例#25
0
        /**
         * Checks, if the ECFieldElements <code>a</code> and <code>b</code>
         * are elements of the same field <code>F<sub>2<sup>m</sup></sub></code>
         * (having the same representation).
         * @param a field element.
         * @param b field element to be compared.
         * @throws ArgumentException if <code>a</code> and <code>b</code>
         * are not elements of the same field
         * <code>F<sub>2<sup>m</sup></sub></code> (having the same
         * representation).
         */
        public static void CheckFieldElements(
            ECFieldElement a,
            ECFieldElement b)
        {
            if (!(a is F2mFieldElement) || !(b is F2mFieldElement))
            {
                throw new ArgumentException("Field elements are not "
                                            + "both instances of F2mFieldElement");
            }

            F2mFieldElement aF2m = (F2mFieldElement)a;
            F2mFieldElement bF2m = (F2mFieldElement)b;

            if (aF2m.representation != bF2m.representation)
            {
                // Should never occur
                throw new ArgumentException("One of the F2m field elements has incorrect representation");
            }

            if ((aF2m.m != bF2m.m) || !Arrays.AreEqual(aF2m.ks, bF2m.ks))
            {
                throw new ArgumentException("Field elements are not elements of the same field F2m");
            }
        }
示例#26
0
            protected override X9ECParameters CreateParameters()
            {
                // a = 1
                BigInteger sect163r2a = BigInteger.One;

                // b = 20a601907b8c953ca1481eb10512f78744a3205fd
                BigInteger sect163r2b = new BigInteger("20a601907b8c953ca1481eb10512f78744a3205fd", 16);

                ECCurve sect163r2Curve = new F2mCurve(sect163r2m, sect163r2k1, sect163r2k2, sect163r2k3, sect163r2a, sect163r2b);

                // x = 3f0eba16286a2d57ea0991168d4994637e8343e36
                ECFieldElement sect163r2x = new F2mFieldElement(
                    sect163r2m, sect163r2k1, sect163r2k2, sect163r2k3,
                    new BigInteger("3f0eba16286a2d57ea0991168d4994637e8343e36", 16));

                // y = 0d51fbc6c71a0094fa2cdd545b11c5c0c797324f1
                ECFieldElement sect163r2y = new F2mFieldElement(
                    sect163r2m, sect163r2k1, sect163r2k2, sect163r2k3,
                    new BigInteger("0d51fbc6c71a0094fa2cdd545b11c5c0c797324f1", 16));

                ECPoint sect163r2BasePoint = new F2mPoint(
                    sect163r2Curve, sect163r2x, sect163r2y, false);

                BigInteger sect163r2n = new BigInteger("5846006549323611672814742442876390689256843201587");

                BigInteger sect163r2h = BigInteger.Two;

                byte[] sect163r2Seed = null;

                return new X9ECParameters(
                    sect163r2Curve,
                    sect163r2BasePoint,
                    sect163r2n,
                    sect163r2h,
                    sect163r2Seed);
            }
示例#27
0
 public virtual bool Equals(
     F2mFieldElement other)
 {
     return ((this.m == other.m)
         && (this.representation == other.representation)
         && Arrays.AreEqual(this.ks, other.ks)
         && (this.x.Equals(other.x)));
 }
示例#28
0
		protected bool Equals(
			F2mFieldElement other)
		{
			return m == other.m
				&& k1 == other.k1
				&& k2 == other.k2
				&& k3 == other.k3
				&& representation == other.representation
				&& base.Equals(other);
		}
示例#29
0
            protected override X9ECParameters CreateParameters()
            {
                // a = 1
                BigInteger sect233r1a = BigInteger.One;

                // b = 066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad
                BigInteger sect233r1b = new BigInteger("066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad", 16);

                ECCurve sect233r1Curve = new F2mCurve(sect233r1m, sect233r1k1, sect233r1k2, sect233r1k3, sect233r1a, sect233r1b);

                // x = 0fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b
                ECFieldElement sect233r1x = new F2mFieldElement(
                    sect233r1m, sect233r1k1, sect233r1k2, sect233r1k3,
                    new BigInteger("0fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b", 16));

                // y = 1006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052
                ECFieldElement sect233r1y = new F2mFieldElement(
                    sect233r1m, sect233r1k1, sect233r1k2, sect233r1k3,
                    new BigInteger("1006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052", 16));

                ECPoint sect233r1BasePoint = new F2mPoint(
                    sect233r1Curve, sect233r1x, sect233r1y, false);

                BigInteger sect233r1n = new BigInteger("6901746346790563787434755862277025555839812737345013555379383634485463");

                BigInteger sect233r1h = BigInteger.Two;

                byte[] sect233r1Seed = null;

                return new X9ECParameters(
                    sect233r1Curve,
                    sect233r1BasePoint,
                    sect233r1n,
                    sect233r1h,
                    sect233r1Seed);
            }
示例#30
0
            protected override X9ECParameters CreateParameters()
            {
                // a = 1
                BigInteger sect283r1a = BigInteger.One;

                // b = 27b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5
                BigInteger sect283r1b = new BigInteger("27b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5", 16);

                ECCurve sect283r1Curve = new F2mCurve(sect283r1m, sect283r1k1, sect283r1k2, sect283r1k3, sect283r1a, sect283r1b);

                // x = 5f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053
                ECFieldElement sect283r1x = new F2mFieldElement(
                    sect283r1m, sect283r1k1, sect283r1k2, sect283r1k3,
                    new BigInteger("5f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053", 16));

                // y = 3676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4
                ECFieldElement sect283r1y = new F2mFieldElement(
                    sect283r1m, sect283r1k1, sect283r1k2, sect283r1k3,
                    new BigInteger("3676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4", 16));

                ECPoint sect283r1BasePoint = new F2mPoint(
                    sect283r1Curve, sect283r1x, sect283r1y, false);

                BigInteger sect283r1n = new BigInteger("7770675568902916283677847627294075626569625924376904889109196526770044277787378692871");

                BigInteger sect283r1h = BigInteger.Two;

                byte[] sect283r1Seed = null;

                return new X9ECParameters(
                    sect283r1Curve,
                    sect283r1BasePoint,
                    sect283r1n,
                    sect283r1h,
                    sect283r1Seed);
            }
示例#31
0
 /**
  * Solves a quadratic equation <code>z<sup>2</sup> + z = beta</code>(X9.62
  * D.1.6) The other solution is <code>z + 1</code>.
  *
  * @param beta
  *            The value to solve the qradratic equation for.
  * @return the solution for <code>z<sup>2</sup> + z = beta</code> or
  *         <code>null</code> if no solution exists.
  */
 private ECFieldElement solveQuadradicEquation(ECFieldElement beta)
 {
     if (beta.x.SignValue == 0)
     {
         return new F2mFieldElement(
                 this.m, this.k1, this.k2, this.k3, BigInteger.Zero);
     }
     ECFieldElement z = null;
     ECFieldElement gamma = new F2mFieldElement(this.m, this.k1,
             this.k2, this.k3, BigInteger.Zero);
     while (gamma.ToBigInteger().SignValue == 0)
     {
         ECFieldElement t = new F2mFieldElement(this.m, this.k1,
                 this.k2, this.k3, new BigInteger(m, new Random()));
         z = new F2mFieldElement(this.m, this.k1, this.k2, this.k3,
                 BigInteger.Zero);
         ECFieldElement w = beta;
         for (int i = 1; i <= m - 1; i++)
         {
             ECFieldElement w2 = w.Square();
             z = z.Square().Add(w2.Multiply(t));
             w = w2.Add(beta);
         }
         if (w.x.SignValue != 0)
         {
             return null;
         }
         gamma = z.Square().Add(z);
     }
     return z;
 }
示例#32
0
        /**
         * Decompresses a compressed point P = (xp, yp) (X9.62 s 4.2.2).
         *
         * @param xEnc
         *            The encoding of field element xp.
         * @param ypBit
         *            ~yp, an indication bit for the decompression of yp.
         * @return the decompressed point.
         */
        private ECPoint decompressPoint(
            byte[] xEnc,
            int ypBit)
        {
            ECFieldElement xp = new F2mFieldElement(
                    this.m, this.k1, this.k2, this.k3, new BigInteger(1, xEnc));
            ECFieldElement yp = null;
            if (xp.x.SignValue == 0)
            {
                yp = (F2mFieldElement)b;
                for (int i = 0; i < m - 1; i++)
                {
                    yp = yp.Square();
                }
            }
            else
            {
                ECFieldElement beta = xp.Add(a).Add(
                        b.Multiply(xp.Square().Invert()));
                ECFieldElement z = solveQuadradicEquation(beta);
                if (z == null)
                {
                    throw new ArithmeticException("Invalid point compression");
                }
                int zBit = 0;
                if (z.x.TestBit(0))
                {
                    zBit = 1;
                }
                if (zBit != ypBit)
                {
                    z = z.Add(new F2mFieldElement(this.m, this.k1, this.k2,
                            this.k3, BigInteger.One));
                }
                yp = xp.Multiply(z);
            }

            return new F2mPoint(this, xp, yp);
        }
示例#33
0
            protected override X9ECParameters CreateParameters()
            {
                // a = 1
                BigInteger sect409r1a = BigInteger.One;

                // b = 21a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f
                BigInteger sect409r1b = new BigInteger("21a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f", 16);

                ECCurve sect409r1Curve = new F2mCurve(sect409r1m, sect409r1k1, sect409r1k2, sect409r1k3, sect409r1a, sect409r1b);

                // x = 15d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7
                ECFieldElement sect409r1x = new F2mFieldElement(
                    sect409r1m, sect409r1k1, sect409r1k2, sect409r1k3,
                    new BigInteger("15d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7", 16));

                // y = 61b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706
                ECFieldElement sect409r1y = new F2mFieldElement(
                    sect409r1m, sect409r1k1, sect409r1k2, sect409r1k3,
                    new BigInteger("61b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706", 16));

                ECPoint sect409r1BasePoint = new F2mPoint(
                    sect409r1Curve, sect409r1x, sect409r1y, false);

                BigInteger sect409r1n = new BigInteger("661055968790248598951915308032771039828404682964281219284648798304157774827374805208143723762179110965979867288366567526771");

                BigInteger sect409r1h = BigInteger.Two;

                byte[] sect409r1Seed = null;

                return new X9ECParameters(
                    sect409r1Curve,
                    sect409r1BasePoint,
                    sect409r1n,
                    sect409r1h,
                    sect409r1Seed);
            }
示例#34
0
            protected override X9ECParameters CreateParameters()
            {
                // a = 1
                BigInteger sect571r1a = BigInteger.One;

                // b = 2f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a
                BigInteger sect571r1b = new BigInteger("2f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a", 16);

                ECCurve sect571r1Curve = new F2mCurve(sect571r1m, sect571r1k1, sect571r1k2, sect571r1k3, sect571r1a, sect571r1b);

                // x = 303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19
                ECFieldElement sect571r1x = new F2mFieldElement(
                    sect571r1m, sect571r1k1, sect571r1k2, sect571r1k3,
                    new BigInteger("303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19", 16));

                // y = 37bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b
                ECFieldElement sect571r1y = new F2mFieldElement(
                    sect571r1m, sect571r1k1, sect571r1k2, sect571r1k3,
                    new BigInteger("37bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b", 16));

                ECPoint sect571r1BasePoint = new F2mPoint(
                    sect571r1Curve, sect571r1x, sect571r1y, false);

                BigInteger sect571r1n = new BigInteger("3864537523017258344695351890931987344298927329706434998657235251451519142289560424536143999389415773083133881121926944486246872462816813070234528288303332411393191105285703");

                BigInteger sect571r1h = BigInteger.Two;

                byte[] sect571r1Seed = null;

                return new X9ECParameters(
                    sect571r1Curve,
                    sect571r1BasePoint,
                    sect571r1n,
                    sect571r1h,
                    sect571r1Seed);
            }
示例#35
0
			/**
			 * Creates the points on the curve with literature values.
			 */
			internal static void createPoints()
			{
				for (int i = 0; i < pointSource.Length / 2; i++)
				{
					F2mFieldElement x = new F2mFieldElement(m, k1,
						new BigInteger(pointSource[2 * i], 16));
					F2mFieldElement y = new F2mFieldElement(m, k1,
						new BigInteger(pointSource[2 * i + 1], 16));
					p[i] = new F2mPoint(curve, x, y);
				}
			}