a portable and fast pairing-based cryptography library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
mcl/test/sq_test.cpp

21 lines
444 B

#include <mcl/gmp_util.hpp>
#include <cybozu/test.hpp>
#include <iostream>
CYBOZU_TEST_AUTO(sqrt)
{
const int tbl[] = { 3, 5, 7, 11, 13, 17, 19, 257, 997, 1031 };
mcl::SquareRoot sq;
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
const mpz_class p = tbl[i];
sq.set(p);
for (mpz_class a = 1; a < p; a++) {
mpz_class x;
if (sq.get(x, a)) {
mpz_class y;
y = (x * x) % p;
CYBOZU_TEST_EQUAL(a, y);
}
}
}
}