Re: Random Prime Generator/Modular Arithmetic

2006-03-06 Thread Tuvas
Actually, there was a small bug fix that I found, and I had a teacher who told me once that there was only 5 pseudoprimes. I realized that large numbers of prime numbers were returning false, and discovered the root of the problem, which was that my M-R test ended too late... But, it works now, tha

Re: Random Prime Generator/Modular Arithmetic

2006-03-06 Thread Bryan Olson
Tuvas wrote: > Okay, now I get the correct number of 561 pseudoprimes, 5, so I can > assume that it is indeed working right. Your code now looks right, so I'm guessing "5" was a typo, perhaps because "5" is just below "8" on the numeric keypad. You can simplify your loop like: def is_strong_pse

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
Okay, now I get the correct number of 561 pseudoprimes, 5, so I can assume that it is indeed working right. Whew. Thanks for the help on that one. Now, I only wish I could change the answer to my last homework assignment... Oh well. -- http://mail.python.org/mailman/listinfo/python-list

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
Ahh, I see, I missed doing the last step in my M-R test. Hmmm. Well, got that one fixed now, time for a new release I guess. Sigh. I do seem to be going through them rather quickly... -- http://mail.python.org/mailman/listinfo/python-list

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Bryan Olson
Tuvas wrote: [...] > Actually, I did another test, and realized that it was indeed a bug in > the code. Yikes. Oh well, thanks for the help in identifying it! > > An example that would be alot easier is this: > Mod(16,561).is_strong_pseudo_prime() > > True Hmmm...my M-R tester disagrees...

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
Bryan Olson wrote: > Tuvas wrote: > > Okay, I don't know if your farmiliar with the miller-rabin primality > > test, > > Paul is familiar with it. When he referred to your Miller-Rabin > test, he meant all the rounds. > > > but it's what's called a probabalistic test. Meaning that trying > > it ou

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Bryan Olson
Tuvas wrote: > Okay, I don't know if your farmiliar with the miller-rabin primality > test, Paul is familiar with it. When he referred to your Miller-Rabin test, he meant all the rounds. > but it's what's called a probabalistic test. Meaning that trying > it out once can give fake results. In t

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
Although, I have to brag quickly, adding in this simple prime check speed up the algorithm to the point that it's actually faster to find a prime number with my program than to verify a number prime with GP/PARI, so, I feel good. -- http://mail.python.org/mailman/listinfo/python-list

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
Actually, it wasn't very nice, it returned composites instead of primes... There was alot of little bugs, I'm glad I checked it again. The new code once again is uploaded, the previews are on their way... I did set up a system to check for primality up to 1000, I think any more than that and it wil

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Astan Chee
Also I think the snippet code [p for p in range(2,N) if 0 not in [pow(w,p-1,p)==1 for w in [2, 3, 5, 7, 11] if p>w]] is probably nicer to generate a list of primes for up to N (instead of hard coded) Aside from that looks nice. Thanks Tuvas wrote: >Yep, you guessed correctly about the s2num fun

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
Yep, you guessed correctly about the s2num function, I knew I should have put a bit more.. It just converts an ascii string to a number, however many numbers that are nessicary. I could indeed check for all primes below a certain number, however, it still seems to run quite fast, at least to a 400

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Astan Chee
Also you last code which looked like: def cran_rand(min,max): if(min>max): x=max max=min min=x range=round(log(max-min)/log(256)) if range==0: range=1 num=max+1 while(num>max): num=min+s2num(urandom(range)) return num what does s2nu

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Tuvas
H. Well, I don't know what else I could do, except for to write a function that doesn't require recursion. Still, 300 digits isn't too bad... I have also realized that if you try is_prime(3) it will return false. I'll have to work on it... Thanks for the help! -- http://mail.python.org/mailma

Re: Random Prime Generator/Modular Arithmetic

2006-03-05 Thread Astan Chee
thanks for the webpage info, however theres a small error I found when trying to generate a prime number with more than 300 decimal digits. It comes up with File "prime.py", line 84, in mod_square_pow return x*mod_square_pow(((a**2)%n),t,n,p*2) File "prime.py", line 84, in mod_square_pow

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
Okay, I don't know if your farmiliar with the miller-rabin primality test, but it's what's called a probabalistic test. Meaning that trying it out once can give fake results. For instance, if you use the number 31 to test if 561 is prime, you will see the results say that it isn't. Mathematically,

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Paul Rubin
"Tuvas" <[EMAIL PROTECTED]> writes: > I have made and recently posted a libary I made to do Modular > Arithmetic and Prime numbers on my website at > http://www.geocities.com/brp13/Python/index.html . I am currently in a > crypotology class, and am working on building a RSA public key > cryptology

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
Okay, the bug in my code has been fixed, it should work alot better now... I thought I had tested the power function, but I appearently wasn't even close... But now it works just fine. I guess you are right, I will have to work on a better system to be cryptologically secure. But, at least I have

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
Well, the RSA element's never going to encrypt more than a small, 1 block system except under rare occasions, the primary encryption will be AES128. Thanks for the help though! -- http://mail.python.org/mailman/listinfo/python-list

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Alex Martelli
Tuvas <[EMAIL PROTECTED]> wrote: ... > to make sure. For simpler than going to the website, I used the ranint I assume you mean random.randint here. > function to pick a random prime number, then ran it through the miller > rabin primality test. It's a probabalistic test, which means it isn't

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
I have discoved that the mod function isn't quite right in dealing with powers, but, I'll have it fixed shortly. -- http://mail.python.org/mailman/listinfo/python-list

Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
I have made and recently posted a libary I made to do Modular Arithmetic and Prime numbers on my website at http://www.geocities.com/brp13/Python/index.html . I am currently in a crypotology class, and am working on building a RSA public key cryptology system for a class project. I am building the