/// <summary> /// Creates an elliptic curve characteristic 2 finite /// field which has 2^{@code m} elements with /// polynomial basis. The reduction polynomial for this /// field is based on {@code ks} whose content /// contains the order of the middle term(s) of the /// reduction polynomial. /// Note: A valid reduction polynomial is either a /// trinomial (X^{@code m} + X^{@code k} + 1 /// with {@code m} > {@code k} >= 1) or a /// pentanomial (X^{@code m} + X^{@code k3} /// + X^{@code k2} + X^{@code k1} + 1 with /// {@code m} > {@code k3} > {@code k2} /// > {@code k1} >= 1), so {@code ks} should /// have length 1 or 3. </summary> /// <param name="m"> with 2^{@code m} being the number of elements. </param> /// <param name="ks"> the order of the middle term(s) of the /// reduction polynomial. Contents of this array are copied /// to protect against subsequent modification. </param> /// <exception cref="NullPointerException"> if {@code ks} is null. </exception> /// <exception cref="IllegalArgumentException"> if{@code m} /// is not positive, or the length of {@code ks} /// is neither 1 nor 3, or values in {@code ks} /// are not between {@code m}-1 and 1 (inclusive) /// and in descending order. </exception> public ECFieldF2m(int m, int[] ks) { // check m and ks this.m = m; this.Ks = ks.clone(); if (m <= 0) { throw new IllegalArgumentException("m is not positive"); } if ((this.Ks.Length != 1) && (this.Ks.Length != 3)) { throw new IllegalArgumentException("length of ks is neither 1 nor 3"); } for (int i = 0; i < this.Ks.Length; i++) { if ((this.Ks[i] < 1) || (this.Ks[i] > m - 1)) { throw new IllegalArgumentException("ks[" + i + "] is out of range"); } if ((i != 0) && (this.Ks[i] >= this.Ks[i - 1])) { throw new IllegalArgumentException("values in ks are not in descending order"); } } // convert ks into rp this.Rp = System.Numerics.BigInteger.ONE; this.Rp = Rp.setBit(m); for (int j = 0; j < this.Ks.Length; j++) { Rp = Rp.setBit(this.Ks[j]); } }