Exposition of polynomials, RR and ZZ in NTL library

I use the NTL library to implement RSA cryptanalysis. But I often run into some problems regarding type mismatch / incompatibility.

For instance -

  • I need an RR value of type n ^ ((h-1.0) / (h * k-1.0)), where n is type ZZ , and h and k are int. The total metric is float or double. I tried ^, pow (works only for RR base), power (works only for long exponent). In the end, I did n, h, k for all RR types to use pow, but is there really a way to do this?

  • How to make (p (x)) ^ k, where p (x) is some polynomial? I had to use the mul function in a loop k times. Also how to initialize a polynomial? It looks like it can take something like a python list from stdin, but I can not install it like in the program. So,

     ZZX p; p = [1 2 3] 

    or

     p = ZZX([1 2 3]) 

    does not work. I had to use SetCoeff to set each coefficient individually.

These are just two instances that I remember right now. I encountered too many inconveniences. Iirc, we can’t even multiply ZZ and RR.

+4
source share
1 answer

I have been looking for this for some time.

  • No pity. There is no built-in way for this. Only RR^long is a combination of a floating-point number and an integer. I think the easiest way is to convert all values ​​to RR .
  • Here I also do not see a built-in method for calculating the power of a polynomial. But there is a faster way to do this than to multiply it by k -times with it. Take a look at quick exposure .
    To establish a polynomial, there is only one way to set it for one coefficient after another. But you can write a function to set all the coefficients in a polynomial from a vector.

NTL is a good math library with high performance, but there are many things that make it difficult to work with this library ... Everyone I know has problems with data types (as you mentioned when you try to multiply RR and ZZ ).

+1
source

Source: https://habr.com/ru/post/1439560/


All Articles