# How would I be able to check if a given number is a solinas prime? Using sage, how would I be able to check whether a given number is a general mersenne prime, or if possible any other special primes?

In particular, looking to check for special primes p such that modulo p is easy to calculate

edit retag close merge delete

• what is a "special prime"?
• what do you mean by "modulo p is easy to calculate"?

Sort by » oldest newest most voted

The "Solinas prime" wikipedia page says a Solinas prime is a prime of the form f(2^m) where f is a polynomial of low degree, and gives a few examples.

Hint: observe the structure of bits of each of these primes:

sage: l = [
....:         2^192 - 2^64 - 1,
....:         2^224 - 2^96 + 1,
....:         2^256 - 2^224 + 2^192 + 2^96 - 1,
....:         2^384 - 2^128 - 2^96 + 2^32 - 1,
....:         2^448 - 2^224 - 1
....:     ]
sage: for p in l:
....:     print(p.bits())


Then define a function to detect m and the polynomial from the bit structure.

more