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
- Implementation of Blockchain in Java
- Hamming code Implementation in Java
- Java Implementation of Deffi-Hellman Algorithm between Client and Server
- Find a Mother vertex in a Graph using Bit Masking
- Queries for count of even digit sum elements in given range using MO's Algorithm
- Find distance between two nodes in the given Binary tree for Q queries
- Query to count odd and even parity elements in subarray after XOR with K
- Binary string with given frequencies of sums of consecutive pairs of characters
- Count of the non-prime divisors of a given number
- Priority queue of pairs in C++ with ordering by first and second element