]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/crypto/rsa/rsa.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / extra / crypto / rsa / rsa.factor
index b1eb90754768795da8b18fc4b72d8938121b2bd6..917e98a6ee52cc7f251e7abf19a99ee737de90e4 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: math.miller-rabin kernel math math.functions namespaces
+USING: math.primes kernel math math.functions namespaces
 sequences accessors ;
 IN: crypto.rsa
 
@@ -18,15 +18,15 @@ C: <rsa> rsa
 
 <PRIVATE
 
-: public-key 65537 ; inline
+CONSTANT: public-key 65537
 
 : rsa-primes ( numbits -- p q )
-    2/ 2 unique-primes first2 ;
+    2/ 2 swap unique-primes first2 ;
 
 : modulus-phi ( numbits -- n phi ) 
     #! Loop until phi is not divisible by the public key.
     dup rsa-primes [ * ] 2keep
-    [ 1- ] bi@ *
+    [ 1 - ] bi@ *
     dup public-key gcd nip 1 = [
         rot drop
     ] [