Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modular exponentiation with a secret exponent is a frequently used operation in

ID: 3683190 • Letter: M

Question

Modular exponentiation with a secret exponent is a frequently used operation in public-key cryptography. Suppose we have fixed a (large) prime number p and a generator g ? {2,...,p?1} of a multiplicative subgroup of GF(p)*. The order of g is typically a large prime number (which divides p?1). Write a program, or pseudo code, for a function that obtains as input three non-negative integers: p and g as just described and a non-negative exponent x. The function must return gx mod p. Your function must be able to handle x-values as large as 22000, and (having in mind timing attacks) the number of multiplications that are performed by your function must not depend on x.

Explanation / Answer

#include<stdio.h>

int main()

{

intn;

intnumber =-1;

unsignedfactorial =1;

do

{

printf("Enter a positive integer: ");

scanf("%d", &number );

}

while( number <0);

n = number;

while( n >=0)

{

if( n ==0)

{

factorial *=1;

}

else

{

factorial *= n;

}

printf("%d! is %u ", number, factorial );

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote