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/sample/large.cpp

36 lines
957 B

9 years ago
/*
large prime sample for 64-bit arch
make CFLAGS_USER="-DMCL_MAX_OP_BIT_SIZE=768"
*/
#include <mcl/fp.hpp>
#include <cybozu/benchmark.hpp>
9 years ago
typedef mcl::FpT<> Fp;
void test(mcl::fp::Mode mode)
9 years ago
{
printf("test %s\n", mcl::fp::ModeToStr(mode));
9 years ago
std::string pStr = "776259046150354467574489744231251277628443008558348305569526019013025476343188443165439204414323238975243865348565536603085790022057407195722143637520590569602227488010424952775132642815799222412631499596858234375446423426908029627";
Fp::init(pStr, mode);
9 years ago
mpz_class p(pStr);
Fp x = 123456;
Fp::pow(x, x, p);
std::cout << x << std::endl;
CYBOZU_BENCH("mul", Fp::mul, x, x, x);
}
int main()
try
{
test(mcl::fp::FP_GMP);
test(mcl::fp::FP_GMP_MONT);
#ifdef MCL_USE_LLVM
test(mcl::fp::FP_LLVM);
test(mcl::fp::FP_LLVM_MONT);
#endif
9 years ago
} catch (std::exception& e) {
printf("err %s\n", e.what());
puts("make clean");
puts("make CFLAGS_USER=\"-DMCL_MAX_OP_BIT_SIZE=768\"");
return 1;
}