Search code examples
c++sqrtntlfinite-field

square root of a finite field element in C++


Is there any implementation of a method to obtain the square root of an element from a finite field. Programmed in C++ I was using NTL but the do not provide a method to do that. Thanks in advance


Solution

  • So in fact NTL libraries provide a method called ZZ::SqrRootMod(...) with several overloads. The method actually fulfill the functionality I described. I would like to give you guys an example as well so for instance:

       ZZ response;
    
       response= SqrRootMod(conv<ZZ>(value), conv<ZZ>(prime));
    

    Were value could be of several numeric types as long as it can be cast to ZZ e.g.(ZZ_p,int)

    This came to my attention after I receive an email from Prf. Shoup to whom am I thank for.