// Check coefficient c is a valid element in ECField field. private static void CheckValidity(ECField field, System.Numerics.BigInteger c, String cName) { // can only perform check if field is ECFieldFp or ECFieldF2m. if (field is ECFieldFp) { System.Numerics.BigInteger p = ((ECFieldFp)field).P; if (p.CompareTo(c) != 1) { throw new IllegalArgumentException(cName + " is too large"); } else if (c.signum() < 0) { throw new IllegalArgumentException(cName + " is negative"); } } else if (field is ECFieldF2m) { int m = ((ECFieldF2m)field).M; if (c.bitLength() > m) { throw new IllegalArgumentException(cName + " is too large"); } } }