Rabin Cryptosystem is an public-key cryptosystem invented by Michael Rabin. It uses asymmetric key encryption for communicating between two parties and encrypting the message.
The security of Rabin cryptosystem is related to the difficulty of factorization. It has the advantage over the others that the problem on which it banks has proved to be hard as integer factorization. It has the disadvantage also, that each output of the Rabin function can be generated by any of four possible inputs. if each output is a ciphertext, extra complexity is required on decryption to identify which of the four possible inputs was the true plaintext.
Steps in Rabin cryptosystem
Generate two very large prime numbers, p and q, which satisfies the condition
p ≠ q → p ≡ q ≡ 3 (mod 4)
p=139 and q=191
Calculate the value of n
n = p.q
- Publish n as public key and save p and q as private key
- Get the public key n.
- Convert the message to ASCII value. Then convert it to binary and extend the binary value with itself, and change the binary value back to decimal m.
Encrypt with the formula:
C = m2 mod n
- Send C to recipient.
- Accept C from sender.
- Specify a and b with Extended Euclidean GCD such that, a.p + b.q = 1
Compute r and s using following formula:
r = C(p+1)/4 mod p
s = C(q+1)/4 mod q
Now, calculate X and Y using following formula:
X = ( a.p.r + b.q.s ) mod p
Y = ( a.p.r – b.q.s ) mod q
The four roots are, m1=X, m2=-X, m3=Y, m4=-Y
Now, Convert them to binary and divide them all in half.
- Determine in which the left and right half are same. Keep that binary’s one half and convert it to decimal m. Get the ASCII character for the decimal value m. The resultant character gives the correct message sent by sender.
Following is the implementation of Rabin cryptosystem in Java
Message sent by sender : Hello Encrypted Message : 96683217050639837550625 Message received by Receiver : Hello
- Java Program for Rabin-Karp Algorithm for Pattern Searching
- Hamming code Implementation in Java
- Java Implementation of Deffi-Hellman Algorithm between Client and Server
- Count the number of words with given prefix using Trie
- Deploy Python Flask App on Heroku
- How to Convert a Float value to String value in Java with Examples
- How to Convert a Short value to String value in Java with Examples
- How to Convert a Double value to String value in Java with Examples
- How to Convert a Byte value to String value in Java with Examples
- How to Convert a String value to Float value in Java with Examples
- 10 Important Android Studio Shortcuts You Need the Most
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.