3593{
3594#ifdef DEBUG_COUNT
3595 puts("DEBUG_COUNT mode on!!!");
3596#endif
3597#ifdef BN_SUPPORT_SNARK
3598 const bool scipr = true;
3599#else
3600 const bool scipr = false;
3601#endif
3602 if (scipr != definedBN_SUPPORT_SNARK) {
3603 fprintf(stderr, "use -DBN_SUPPORT_SNARK for all sources\n");
3604 exit(1);
3605 }
3606 static bool init =
false;
3610 mie::local::errExit("not support p for Fp::setModulo");
3611 }
3613
3614
3615 {
3617 ZN::setModulo(
Vuint(1) << (
sizeof(
Unit) * 8));
3619 t = -t;
3620 t.inverse();
3621 pp_mont = t[0];
3623 p_add1_div4_ = (
p + 1) / 4;
3624 }
3625
3626
3627 montgomeryR_ = (
Vuint(1) << 256) %
p;
3628 {
3631 Z t(montgomeryR_);
3633 }
3635 one_[0] = 1;
3636
3638 try {
3639
3640 const int PageSize = 4096;
3641 const size_t codeSize = PageSize * 9;
3642 const size_t dataSize = PageSize * 1;
3643
3644 static std::vector<Xbyak::uint8>
buf;
3645 buf.resize(codeSize + dataSize + PageSize);
3649
3650
3651 if ((
size_t)codeAddr & 0xffffffff00000000ULL || (
size_t)
s_data & 0xffffffff00000000ULL) {
3652
3653 }
3654
3655
3660
3661 for (
size_t i = 0; i <
pTblSize; i++) {
3663 }
3664
3665
3666
3667
3668
3670 for (
size_t h = 1; h <
pNtblSize; ++h) {
3671 Fp::Dbl::pNTbl_[h].setDirect(pN >> h);
3672 }
3674
3675
3676 static PairingCode code(codeSize, codeAddr);
3677 code.init(p_, mode, useMulx);
3678 {
3680 for (int i = 0; i < 512; i++) {
3681 invTbl_[511 - i] = t;
3682 t += t;
3683 }
3684 }
3685 return;
3686 } catch (std::exception& e) {
3687 fprintf(stderr, "setModulo ERR:%s\n", e.what());
3688 }
3689 ::exit(1);
3690}
static uint8 * getAlignedAddress(uint8 *addr, size_t alignedSize=16)
static bool protect(const void *addr, size_t size, bool canExec)
static void setModulo(const V &m)
VuintT< local::FixedBuffer< mie::Unit, MIE_ZM_VUINT_BIT_LEN > > Vuint
static MIE_FORCE_INLINE void setDirect(Dbl &out, const mie::Vuint &in)