0

I'm trying to do a function in PARI that computes a^(c*q_t) mod n; where c and n are such big numbers, and q_t is the denominator of a convergent of n/c. This is for RSA purposes. I'd just like to improve this function, so that computer would do it by itself, I mean it would find the q_t by itself and discover also the a itself. So, it would need two more parameters. I have no idea how to do this. This is my function:

expmod(a,e,m)={
  local(x,y,s,d); x=a; y=1; s=e;
  while(s,d=s%2;s=(s-d)/2;
  if(d,y=(y*x)%m); x=(x*x)%m);
  return(y)}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Anonymous
  • 49
  • 1
  • 9
  • Please, improve your question. Your code has input parameters `a`, `e`, and `m` while your text defines another variables `c`, `q_t`, and `n`. I guess you want to implement RSA encoder/decoder in PARI/GP. Is it right? – Piotr Semenov May 24 '21 at 18:46
  • Yes, it is that! @PiotrSemenov – Anonymous May 24 '21 at 20:07

1 Answers1

0

PARI has a built in type Mod(a,m) that keeps track of the modulus through exponents.

lift(Mod(a,m)^e)
Andrew
  • 873
  • 4
  • 10