Showing posts with label cryptography. Show all posts

Factoring Large Numbers With Distributed Quadratic Sieve

Integer factorization is a problem that has its roots in the very far history, it is a fascinating problem (to me especially) that has gained a lot of attention in the recent years for cracking the RSA cryptosystem for example.

While having no time to blog about the internals of one of the very efficient methods to factorize relatively large numbers, I present here a simple implementation I have developed of the Quadratic Sieve to factorize relatively big RSA numbers. For a reference about the mathematical premises, the 6th chapter entitled Subexponential Factoring Algorithms of the Prime Numbers, A Computational Perspective book is pretty great.

The program available here is composed of 4 different versions, 3 centralized (sequential) and 1 distributed using MPI. The distributed version needs to be run on at least 2 nodes. The centralized versions consist of different implementation experiments : 
  • The first one keeps the exponent vector of each smooth number (impractical due to the huge memory needed to keep the vectors).
  • The second one sieves at an interval centralized at sqrt(N); according to my testing, this has no visible improvements over the standard one. 
  • The last version which is the same as the first one but which uses only a binary exponent vector (saving one bit for each prime in the base) for the smooth numbers.

One of the caveats of this implementation is the linear algebra step that performs the Gaussian elimination. The method I am using is the most naive one (though goes pretty fast using XOR operations on GMP integers) which keeps an identity matrix besides the effective matrix while performing the Gaussian elimination, and hence the program needs twice the memory needed for the matrix.

The distributed version spawns as many nodes as needed and makes them all perform the sieving step, after some very hundreds of thousands of steps, the slaves communicate their found smooth numbers to the master which decides if they must stop or should continue sieving for more numbers. Sending GMP integers mpz_t over MPI was very challenging due to the way MPI handles the string representation of these numbers (sometimes '\0' are included at the end and the length returned does not represent exactly the number of characters in the string).  You can take a look at the functions doing the MPI send/receive of mpz_t here.

You will need the mpfr library too (for logarithm calculations) in case you want to test the programs, for the distributed version, compile with mpicc and run with mpirun as usual.

Results:
Centralized version:
Distributed version (60 intel i7 nodes):

Posted in , , |

Win a Free Domain Name (Registered For 3 Years), 3rd & Last Message

This is the 3rd and last message of the series to win a domain name registered for 3 years.

Once decoded, send the clear message and your email from the “contact me” page, remember, first to decipher the 3 messages wins.

 

Message:

ADACACACBDXCCAAABCABBACAXCCCAABCCDC
BXAACACBCCXBXDXDAAADACBABDACABXXAAB
AXCAXAABCDAACAACBDACADBACDXBXXCACCC
CAACCAABCCBDXAADBDBX

 

Instructions :

YJAV CWQ : LMJAFY, LJSFKHGKALAGF CWQ : CAFVA.

You need to decipher the first (fairly easy) two messages (the second is easier than the first). Message 1 here, message 2 here.

 

(competition always open closed)

Winner : Mohieddine Abd-kader, http://mitgux.com/

Posted in |

Cracking The Vigenere Cipher

I wanted to use Vigenere as the cipher for the 3rd message on the competition to win a domain name, but changed my mind due to the number of online tools that might help decode this cipher easily even if you know nothing about how Vigenere works.

Before you start reading about how deciphering Veginere works, I invite you to take a look how Vigenere is used to cipher messages from the Wikipedia article here. In fact, Vigenere was called “le chiffre indĂ©chiffrable” or the undecipherable cipher, because any means of cryptanalysis invented before it was defeated, till Charles Babbage found a clever, very clever, way to crack it.

After finishing reading the Code Book the last week, I started decoding the different enigmas proposed at the end of the book; and yesterday I started deciphering the 4th enigma which is a Vigenere cipher (that I finished yesterday too), and I find it pretty amazing for starters to try. I must mention that this short article will contain the solution to the enigma.

I chose to go old way while deciphering this, finding the key by hand, then decoding the message step by step.

0. The message to decode :

K Q O W E F V J P U J U U N U K G L M E K J I
N M W U X F Q M K J B G W R L F N F G H U D W
U U M B S V L P S N C M U E K Q C T E S W R E
E K O Y S S I W C T U A X Y O T A P X P L W P
...

The complete message can be found here.

1. Finding the key length:

Babbage’s method for finding the key length was that the repeated text in the ciphered message is probably produced from the same repeated letters from the clear message and which are ciphered with the same part of the key. Hence, finding an estimate between the repeated series of letters in the ciphered message would give us a good hint about the length of the key.

Clear : T H I S I S A C L E A R T E X T T H I S C A N B E E A S L Y D E C
Key :   C O D E C O D E C O D E C O D E C O D E C O D E C O D E C O D E C
Crypt : V V L W K G D G N S D V V S A X V V L W E O Q F G S D W N M G I E

As you can see the series of letters T, H, I is ciphered to the same series V, V, L, because they were situated at the same relative position according the key; notice also that E, A is ciphered to the same S, D.
The key length is at worst the spacing between these repetitions in the ciphered text, and usually it is the greatest common divisor of the spacing of (most) the repetitions (why? give it a second thought.).

285181560

Posted in , |

Win a Free Domain Name (Registered For 3 Years), 2nd Message

By decrypting the message and following the rules you reveal, or just have fun!

After decrypting the first one, you won’t find any difficulty decrypting this one.

Sans titre

Hint: Phonemic, Linear, starting from the end is a good idea sometimes.

Hint 2 : This was a widely used code (language) in the past.

(if you decode the message, don’t forget to send your answer from the “contact me” page along with your email).

Decoded by : @oh_la_love, @27_hope, @mowahed23 , Mohieddine Abd-kader, @zirconias (competition always open closed).

 

Winner : Mohieddine Abd-kader, http://mitgux.com/

Posted in |

Win a Free Domain Name (Registered For 3 Years)

By decrypting the message and following the rules you reveal, or just have fun!

Sans titre

Hint : People used to love playing Angry Birds in ancient Rome.

 

Decoded by : @oh_la_love, @27_hope, @mowahed23, Mohieddine Abd-kader, @zirconias (competition always open closed).

 

Winner : Mohieddine Abd-kader, http://mitgux.com/

Posted in |

Swedish Greys - a WordPress theme from Nordic Themepark. Converted by LiteThemes.com.