Пример #1
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));
            }
Пример #2
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));
        }
Пример #3
0
        public override bool Equals(
            object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            F2mFieldElement other = obj as F2mFieldElement;

            if (other == null)
            {
                return(false);
            }

            return(Equals(other));
        }
Пример #4
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");
            }
        }