{"id":20108,"date":"2022-11-26T14:09:01","date_gmt":"2022-11-26T14:09:01","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=10291"},"modified":"2022-11-26T14:09:01","modified_gmt":"2022-11-26T14:09:01","slug":"encryption-and-decryption","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/11\/26\/encryption-and-decryption\/","title":{"rendered":"Encryption and Decryption"},"content":{"rendered":"\n<p>The generation of an ElGamal key pair is comparatively simpler than the equivalent process for RSA. But the encryption and decryption are slightly more complex than RSA.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ElGamal Encryption<\/h3>\n\n\n\n<p>Suppose sender wishes to send a plaintext to someone whose ElGamal public key is (p, g, y), then \u2212<\/p>\n\n\n\n<ul>\n<li>Sender represents the plaintext as a series of numbers modulo p.<\/li>\n\n\n\n<li>To encrypt the first plaintext P, which is represented as a number modulo p. The encryption process to obtain the ciphertext C is as follows \u2212\n<ul>\n<li>Randomly generate a number k;<\/li>\n\n\n\n<li>Compute two values C1 and C2, where \u2212<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">C1 = g<sup>k<\/sup> mod p\nC2 = (P<sup>*<\/sup>y<sup>k<\/sup>) mod p\n<\/pre>\n\n\n\n<ul>\n<li>Send the ciphertext C, consisting of the two separate values (C1, C2), sent together.<\/li>\n\n\n\n<li>Referring to our ElGamal key generation example given above, the plaintext P = 13 is encrypted as follows \u2212\n<ul>\n<li>Randomly generate a number, say k = 10<\/li>\n\n\n\n<li>Compute the two values C1 and C2, where \u2212<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">C1 = 6<sup>10<\/sup> mod 17\nC2 = (13<sup>*<\/sup>7<sup>10<\/sup>) mod 17 = 9\n<\/pre>\n\n\n\n<ul>\n<li>Send the ciphertext C = (C1, C2) = (15, 9).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">ElGamal Decryption<\/h3>\n\n\n\n<ul>\n<li>To decrypt the ciphertext (C1, C2) using private key x, the following two steps are taken \u2212\n<ul>\n<li>Compute the modular inverse of (C1)<sup>x<\/sup>&nbsp;modulo p, which is (C1)<sup>-x&nbsp;<\/sup>, generally referred to as decryption factor.<\/li>\n\n\n\n<li>Obtain the plaintext by using the following formula \u2212<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">C2 \u00d7 (C1)<sup>-x <\/sup> mod p = Plaintext\n<\/pre>\n\n\n\n<ul>\n<li>In our example, to decrypt the ciphertext C = (C1, C2) = (15, 9) using private key x = 5, the decryption factor is<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">15<sup>-5 <\/sup> mod 17 = 9\n<\/pre>\n\n\n\n<ul>\n<li>Extract plaintext P = (9 \u00d7 9) mod 17 = 13.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The generation of an ElGamal key pair is comparatively simpler than the equivalent process for RSA. But the encryption and decryption are slightly more complex than RSA. ElGamal Encryption Suppose sender wishes to send a plaintext to someone whose ElGamal public key is (p, g, y), then \u2212 C1 = gk mod p C2 = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[495],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/20108"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=20108"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/20108\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=20108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=20108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=20108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}