RSA and Wiener's attack I'm trying to do Wieners' attack for the case \
n = 41812289888807017163984918063150535143241733968369526096686035411100281058895684734892837916893307091448099221185297849468517662339430579635277837641016589091836673752854703947923396020640786536145707 
c = 5647541533380963346585224364224434677403723951263986948810198754525250531609090519481526140311081703727277595838311994257275863156449937037100899820505224056792266899834932182748239916430052642900127. 

I'm using SageMath and I computed the continued fraction of $n/c$ and the first 10 convergents ($p_n/q_n$). Now I'm trying to see if $a^{cq_i} \equiv a \pmod{n}$. It happens that Sage says that the exponent is too high and PARI online said the said. Can I make these computations an easier way?
There should be no limits to the exponent size if you're using power_mod.
&quot;Too big&quot; errors in a multiple-precision-capable library likely mean that you're trying to exponentiate-then-modulo; this creates huge numbers. If you use power_mod (cf. Python's pow), it keeps the number pruned within $\{0,\dots,n-1\}$ through the process so it never has to handle &quot;exponentially large&quot; numbers.