Пример #1
0
 /// <summary>
 /// Creates elliptic curve domain parameters based on the
 /// specified values. </summary>
 /// <param name="curve"> the elliptic curve which this parameter
 /// defines. </param>
 /// <param name="g"> the generator which is also known as the base point. </param>
 /// <param name="n"> the order of the generator {@code g}. </param>
 /// <param name="h"> the cofactor. </param>
 /// <exception cref="NullPointerException"> if {@code curve},
 /// {@code g}, or {@code n} is null. </exception>
 /// <exception cref="IllegalArgumentException"> if {@code n}
 /// or {@code h} is not positive. </exception>
 public ECParameterSpec(EllipticCurve curve, ECPoint g, System.Numerics.BigInteger n, int h)
 {
     if (curve == null)
     {
         throw new NullPointerException("curve is null");
     }
     if (g == null)
     {
         throw new NullPointerException("g is null");
     }
     if (n == null)
     {
         throw new NullPointerException("n is null");
     }
     if (n.signum() != 1)
     {
         throw new IllegalArgumentException("n is not positive");
     }
     if (h <= 0)
     {
         throw new IllegalArgumentException("h is not positive");
     }
     this.Curve_Renamed = curve;
     this.g             = g;
     this.n             = n;
     this.h             = h;
 }
Пример #2
0
 /// <summary>
 /// Creates an elliptic curve prime finite field
 /// with the specified prime {@code p}. </summary>
 /// <param name="p"> the prime. </param>
 /// <exception cref="NullPointerException"> if {@code p} is null. </exception>
 /// <exception cref="IllegalArgumentException"> if {@code p}
 /// is not positive. </exception>
 public ECFieldFp(System.Numerics.BigInteger p)
 {
     if (p.signum() != 1)
     {
         throw new IllegalArgumentException("p is not positive");
     }
     this.p = p;
 }
Пример #3
0
 // 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");
         }
     }
 }