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

22 lines
444 B

10 years ago
#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 = 0; a < p; a++) {
10 years ago
mpz_class x;
if (sq.get(x, a)) {
mpz_class y;
y = (x * x) % p;
CYBOZU_TEST_EQUAL(a, y);
}
}
}
}