MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxBigInt_mont_exp_LR

Function fxBigInt_mont_exp_LR

modules/crypt/arith/xsBigIntEx.c:513–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511}
512
513txBigInt *fxBigInt_mont_exp_LR(txMachine *the, txBigInt *r, txBigInt *b, txBigInt *e, txBigInt *m)
514{
515 int i;
516 txBigInt *t;
517 txU4 u;
518 pool_t pool;
519
520 if (r == NULL)
521 r = fxBigInt_alloc(the, m->size);
522 pool_init(&pool);
523 u = mont_init(m);
524 t = pool_get(the, m->size, &pool);
525 mont_exp_init(the, t, m, &pool);
526 if (fxBigInt_ucomp(b, m) > 0)
527 b = fxBigInt_mod(the, pool_get(the, m->size, &pool), b, m);
528 b = mont_in(the, pool_get(the, m->size, &pool), b, m);
529 for (i = fxBigInt_bitsize(e); --i >= 0;) {
530 mont_square(the, t, t, m, u, &pool);
531 if (fxBigInt_isset(e, i))
532 mont_mul(the, t, t, b, m, u, &pool);
533 }
534 mont_out(the, r, t, m, u);
535 pool_dispose(the, &pool);
536 return r;
537}
538
539txBigInt *fxBigInt_mont_exp_SW(txMachine *the, txBigInt *r, txBigInt *b, txBigInt *e, txBigInt *m, int param)
540{

Callers 1

xs_mont2_exp_LRFunction · 0.85

Calls 14

fxBigInt_allocFunction · 0.85
pool_initFunction · 0.85
mont_initFunction · 0.85
pool_getFunction · 0.85
mont_exp_initFunction · 0.85
fxBigInt_ucompFunction · 0.85
fxBigInt_modFunction · 0.85
mont_inFunction · 0.85
fxBigInt_bitsizeFunction · 0.85
mont_squareFunction · 0.85
fxBigInt_issetFunction · 0.85
mont_mulFunction · 0.85

Tested by

no test coverage detected