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

Function fxBigInt_ec_mul2

modules/crypt/arith/xsBigIntEx.c:872–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870}
871
872void fxBigInt_ec_mul2(txMachine *the, txECPoint *r, txECPoint *a1, txBigInt *k1, txECPoint *a2, txBigInt *k2, txECParam *ec)
873{
874 int i, j;
875 txECPoint *G[4], g3;
876 int k1size, k2size;
877 pool_t pool;
878#define isset_k1(i) (i < k1size ? fxBigInt_isset(k1, i): 0)
879#define isset_k2(i) (i < k2size ? fxBigInt_isset(k2, i): 0)
880
881 if (r->z == NULL)
882 r->z = fxBigInt_alloc(the, ec->m->size);
883 if (r->y == NULL)
884 r->y = fxBigInt_alloc(the, ec->m->size);
885 if (r->x == NULL)
886 r->x = fxBigInt_alloc(the, ec->m->size);
887 fxBigInt_copy(r->z, &gxBigIntZero);
888
889 pool_init(&pool);
890 G[1] = a1;
891 G[2] = a2;
892 g3.x = pool_get(the, ec->m->size, &pool);
893 g3.y = pool_get(the, ec->m->size, &pool);
894 g3.z = pool_get(the, ec->m->size, &pool);
895 ec_add(the, &g3, a1, a2, ec, &pool);
896 G[3] = &g3;
897 k1size = fxBigInt_bitsize(k1);
898 k2size = fxBigInt_bitsize(k2);
899 for (i = MAX(k1size, k2size); --i >= 0;) {
900 ec_double(the, r, r, ec, &pool);
901 j = isset_k1(i) | (isset_k2(i) << 1);
902 if (j != 0)
903 ec_add(the, r, r, G[j], ec, &pool);
904 }
905 pool_dispose(the, &pool);
906}
907
908void fxBigInt_ec_norm(xsMachine *the, txECPoint *r, txECPoint *a, txECParam *ec)
909{

Callers 1

xs_ec2_mul2Function · 0.85

Calls 8

fxBigInt_allocFunction · 0.85
fxBigInt_copyFunction · 0.85
pool_initFunction · 0.85
pool_getFunction · 0.85
ec_addFunction · 0.85
fxBigInt_bitsizeFunction · 0.85
ec_doubleFunction · 0.85
pool_disposeFunction · 0.85

Tested by

no test coverage detected