Question

In: Computer Science

use ELGMAL algorithm. let p = 11. find a generator number for p in case of...

use ELGMAL algorithm.

let p = 11. find a generator number for p in case of elgmal algorithm. alice selects an integer number x = 5. calculate public and private key for alice in elgmal algorithm. alice wants to send plaintext "AGE" to Bob. assume that Alice selects random k values as 6, 4, 7 respectively for encryption. what is the ciphertext???

Solutions

Expert Solution

ANS :a)

CODE FOR IMPLEMENTATION :

import random

from math import pow

  

a = random.randint(2, 10)

  

def gcd(a, b):

    if a < b:

        return gcd(b, a)

    elif a % b == 0:

        return b;

    else:

        return gcd(b, a % b)

  

# Generating large random numbers

def gen_key(q):

  

    key = random.randint(pow(10, 20), q)

    while gcd(q, key) != 1:

        key = random.randint(pow(10, 20), q)

  

    return key

  

# Modular exponentiation

def power(a, b, c):

    x = 1

    y = a

  

    while b > 0:

        if b % 2 == 0:

            x = (x * y) % c;

        y = (y * y) % c

        b = int(b / 2)

  

    return x % c

  

# Asymmetric encryption

def encrypt(msg, q, h, g):

  

    en_msg = []

  

    k = gen_key(q)# Private key for sender

    s = power(h, k, q)

    p = power(g, k, q)

      

    for i in range(0, len(msg)):

        en_msg.append(msg[i])

  

    print("g^k used : ", p)

    print("g^ak used : ", s)

    for i in range(0, len(en_msg)):

        en_msg[i] = s * ord(en_msg[i])

  

    return en_msg, p

  

def decrypt(en_msg, p, key, q):

  

    dr_msg = []

    h = power(p, key, q)

    for i in range(0, len(en_msg)):

        dr_msg.append(chr(int(en_msg[i]/h)))

          

    return dr_msg

  

# Driver code

def main():

  

    msg = 'encryption'

    print("Original Message :", msg)

  

    q = random.randint(pow(10, 20), pow(10, 50))

    g = random.randint(2, q)

  

    key = gen_key(q)# Private key for receiver

    h = power(g, key, q)

    print("g used : ", g)

    print("g^a used : ", h)

  

    en_msg, p = encrypt(msg, q, h, g)

    dr_msg = decrypt(en_msg, p, key, q)

    dmsg = ''.join(dr_msg)

    print("Decrypted Message :", dmsg);

  

  

if __name__ == '__main__':

    main()

n this cryptosystem, original message M is masked by multiplying gak to it. To remove the mask, a clue is given in form of gk. Unless someone knows a, he will not be able to retrieve M. This is because of finding discrete log in an cyclic group is difficult and simplying knowing ga and gk is not good enough to compute gak.

** VALUES CAN BE INPUTTED IN THE ABOVE CODE FOR OPTIMIZATION.


Related Solutions

let p=11. find generator number for p incase of elgmal algorithm. alice selects integer number x=5....
let p=11. find generator number for p incase of elgmal algorithm. alice selects integer number x=5. calculate public and private key for Alice in elgmal algorithm. alice wants to send plaintext "AGE" to bob. assume that alice selects random k values s 6,4,7 respectively for encryption. what is the ciphertext?
use algorithm modular exponentiation to find 11^644 mod 645
use algorithm modular exponentiation to find 11^644 mod 645
Let X be a binomial random variable with n = 11 and p = 0.3. Find...
Let X be a binomial random variable with n = 11 and p = 0.3. Find the following values. (Round your answers to three decimal places.) (a)     P(X = 5) (b)     P(X ≥ 5) (c)     P(X > 5) (d)     P(X ≤ 5) (e)     μ = np μ = (f)    σ = npq σ =
If P713 is divisible by 11, find the value of the smallest natural number P?
If P713 is divisible by 11, find the value of the smallest natural number P?
Analyze the algorithm experimentally. a)Implement the algorithm b)Let p be the string length at which your...
Analyze the algorithm experimentally. a)Implement the algorithm b)Let p be the string length at which your program takes 2 seconds to run, collect running times for your algorithm using the following string lengths: p/4, 2p/4, 3p/4, p, 5p/4, 6p/4, 7p/4, 2p. c)Generate your strings by reading the attached file, only reading as many characters as you need. d)Plot your results (x-axis is string length, y-axis should be time) e)Draw conclusions based on your graph. You may also need to plot...
11. Use Euclid’s extended algorithm to find x and y for Gcd(241, 191) = 241 x...
11. Use Euclid’s extended algorithm to find x and y for Gcd(241, 191) = 241 x + 191 y Show all work.
Number Theory: Let p be an odd number. Recall that a primitive root, mod p, is...
Number Theory: Let p be an odd number. Recall that a primitive root, mod p, is an integer g such that gp-1 = 1 mod p, and no smaller power of g is congruent to 1 mod p. Some results in this chapter can be proved via the existence of a primitive root(Theorem 6.26) (c) Given a primitive root g, and an integer a such that a is not congruent to 0 mod p, prove that a is a square...
Let B={2,4,6} be the event that we roll an even | number. Find P(B) and type...
Let B={2,4,6} be the event that we roll an even | number. Find P(B) and type the fraction
A Mystery Algorithm Input: An integer n ≥ 1 Output: ?? Find P such that 2^p...
A Mystery Algorithm Input: An integer n ≥ 1 Output: ?? Find P such that 2^p is the largest power of two less than or equal to n. Create a 1-dimensional table with P +1 columns. The leftmost entry is the Pth column and the rightmost entry is the 0th column. Repeat until P < 0 If 2^p≤n then put 1 into column P set n := n - 2^p Else put 0 into column P End if Subtract 1...
(A universal random number generator.)Let X have a continuous, strictly increasing cdf F. Let Y =...
(A universal random number generator.)Let X have a continuous, strictly increasing cdf F. Let Y = F(X). Find the density of Y. This is called the probability integral transform. Now let U ∼ Uniform(0,1) and let X = F−1(U). Show that X ∼ F. Now write a program that takes Uniform (0,1) random variables and generates random variables from an Exponential (β) distribution
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT