Пример #1
0
 def listRandomECs(m, irred, n):
     if (m & (m-1)) != 0: # only powers of 2 don't have this property
         return "" + str(m) + " is not a power of 2."
     count = 0
     rval = ""
     deg = int(math.log(m, 2))
     while count < n:
         a = Polynomial.random(deg-1)
         b = Polynomial.random(deg-1)
         E = BinaryEllipticCurve(a, b, irred)
         if E.isEC():
             rval += str(E) + "\n"
             count += 1
     rval += str(count) + " curves were generated.\n"
     return rval
Пример #2
0
 def listRandomPoints(self, n):
     count = 0
     s = ""
     a = self.getA()
     b = self.getB()
     modulus = self.getModulus()
     deg = modulus.degree()
     while count < n:
         foundPoint = False
         while not foundPoint:
             x = Polynomial.random(deg-1)
             y = Polynomial.random(deg-1)
             leftside = (y*y + x*y) % modulus
             rightside = (x*x*x + a*x*x + b) % modulus
             if leftside == rightside:
                 foundPoint = True
         s += str(PolynomialPoint(x, y, Polynomial("1"))) + "\n"
         count += 1
     s += str(count) + " points were generated.\n"
     return s