private void GlobalInit() { if (null == bigint_ctx) { bigint_ctx = BI_CTX.bi_initialize(); } }
/* @brief Start a new bigint context. * @return A bigint context. */ internal static BI_CTX bi_initialize() { /* calloc() sets everything to zero */ BI_CTX ctx = new BI_CTX(); /* the radix */ ctx.bi_radix = ctx.Allocate(2); ctx.bi_radix.comps[0] = 0; ctx.bi_radix.comps[1] = 1; ctx.bi_radix.bi_permanent(); return(ctx); }
internal BigInteger mod_pow(BigInteger modulus, BigInteger exponent) { BI_CTX tmp_ctx = BI_CTX.bi_initialize(); tmp_ctx.bi_set_mod(tmp_ctx.bi_clone(modulus._impl), BIGINT_M_OFFSET); bigint tmp_biR = tmp_ctx.bi_mod_power(tmp_ctx.bi_clone(_impl), tmp_ctx.bi_clone(exponent._impl)); bigint biR = bigint_ctx.bi_clone(tmp_biR); tmp_ctx.bi_free(tmp_biR); tmp_ctx.bi_free_mod(BIGINT_M_OFFSET); tmp_ctx.bi_terminate(); return(new BigInteger(biR)); }