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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.