I am using the NTL library for a RSA cryptanalysis implementation. But I am running into some problems frequently regarding type mismatch/incompatibility.
Eg-
I need
RR
type value of n^((h-1.0)/(h*k-1.0)) where n is typeZZ
, and h and k are int. The overall exponent is float or double. I tried ^ , pow (works only forRR
base), power (works only for long exponent). I eventually made n,h,k all of type RR to use pow, but is that really the way to do it?How to do (p(x))^k where p(x) is some polynomial? I had to use mul function in a loop k times. Also how to initialize a polynomial? It seems it can take something like a python list from stdin, yet I can't set it like that within the program. So,
ZZX p; p = [1 2 3]
or
p = ZZX([1 2 3])
doesn't work. I had to use
SetCoeff
to set each coefficient individually.
These are just 2 instances I remember right now. I have encountered too many inconveniences.
Iirc, we can't even multiply ZZ and RR.
I searched this also for a while.
RR^long
is a mix of floatingpoint and integral number. I think the easiest way is to convert all values toRR
.k
-times with it self. Take a look at the fast exponentiation.To set a polynomial there is only the way to set it one coefficent after another. But you can write a function to set all coefficents in a polynomial from a vector.
NTL is a good high performance math library, but there are a lot of things that make working with this libary hard... Everyone I know has problems with the datatypes (as you mentioned, when you try to multiply
RR
andZZ
).