Changeset 7674:33cb0113c435


Ignore:
Timestamp:
11/29/07 13:58:59 (5 years ago)
Author:
Robert Bradshaw <robertwb@…>
Branch:
default
Message:

Fix bug in char(k)=2 elliptic curve random element.

The code assumed that given an x, there were always exactly 2 possible y-values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/schemes/elliptic_curves/ell_finite_field.py

    r7673 r7674  
    217217                f = y**2 + a1*x*y + a3*y - x**3 + a2*x**2 + a4*x + a6 
    218218                roots = f.roots() 
    219                 if roots == []: 
    220                     continue 
    221                 if random.random() < 0.5: 
    222                     y = roots[0][0] 
    223                 else: 
    224                     y = roots[1][0] 
    225                 return self([x,y]) 
     219                n = len(roots) 
     220                if n: 
     221                    y = roots[random.randint(0,n-1)][0] 
     222                    return self([x,y]) 
    226223        else: 
    227224            while True: 
     
    230227                try: 
    231228                    m = d.sqrt(extend=False) 
     229                    if random.random() < 0.5: 
     230                        m = -m 
    232231                    y = (-(a1*x + a3) + m) / k(2) 
    233232                    return self([x,y]) 
Note: See TracChangeset for help on using the changeset viewer.