| 906 | } |
| 907 | |
| 908 | void fxBigInt_ec_norm(xsMachine *the, txECPoint *r, txECPoint *a, txECParam *ec) |
| 909 | { |
| 910 | txBigInt *inv, *inv2, *inv3; |
| 911 | pool_t pool; |
| 912 | |
| 913 | if (r->z == NULL) |
| 914 | r->z = fxBigInt_alloc(the, ec->m->size); |
| 915 | if (r->y == NULL) |
| 916 | r->y = fxBigInt_alloc(the, ec->m->size); |
| 917 | if (r->x == NULL) |
| 918 | r->x = fxBigInt_alloc(the, ec->m->size); |
| 919 | |
| 920 | if (fxBigInt_iszero(a->z) || fxBigInt_ucomp(a->z, ec->one) == 0) { |
| 921 | fxBigInt_copy(r->x, a->x); |
| 922 | fxBigInt_copy(r->y, a->y); |
| 923 | fxBigInt_copy(r->z, a->z); |
| 924 | return; |
| 925 | } |
| 926 | |
| 927 | pool_init(&pool); |
| 928 | inv = pool_get(the, ec->m->size, &pool); |
| 929 | inv2 = pool_get(the, ec->m->size, &pool); |
| 930 | inv3 = pool_get(the, ec->m->size, &pool); |
| 931 | inv = mont_out(the, inv, a->z, ec->m, ec->u); |
| 932 | inv = fxBigInt_mod_mulinv(the, inv, inv, ec->m); |
| 933 | inv = mont_in(the, inv, inv, ec->m); |
| 934 | inv2 = fxBigInt_mont_square(the, inv2, inv, ec->m, ec->u, &pool); |
| 935 | inv3 = fxBigInt_mont_mul(the, inv3, inv2, inv, ec->m, ec->u, &pool); |
| 936 | |
| 937 | fxBigInt_mont_mul(the, r->x, a->x, inv2, ec->m, ec->u, &pool); |
| 938 | fxBigInt_mont_mul(the, r->y, a->y, inv3, ec->m, ec->u, &pool); |
| 939 | fxBigInt_copy(r->z, ec->one); |
| 940 | pool_dispose(the, &pool); |
| 941 | } |
no test coverage detected