    if (err == MP_OKAY)
    {
        mp_digit mp = 0;

        if (!mp_iszero(u1)) {
            /* compute u1*mG + u2*mQ = mG */
            err = wc_ecc_mulmod_ex(u1, mG, mG, curve->Af, curve->prime, 0,
                                                                     key->heap);
            if (err == MP_OKAY) {
                err = wc_ecc_mulmod_ex(u2, mQ, mQ, curve->Af, curve->prime, 0,
                                                                     key->heap);
            }

            /* find the montgomery mp */
            if (err == MP_OKAY)
                err = mp_montgomery_setup(curve->prime, &mp);

            /* add them */
            if (err == MP_OKAY)
                err = ecc_projective_add_point(mQ, mG, mG, curve->Af,
                                                              curve->prime, mp);
            if (err == MP_OKAY && mp_iszero(mG->z)) {
                /* When all zero then should have done an add */
                if (mp_iszero(mG->x) && mp_iszero(mG->y)) {
                    err = ecc_projective_dbl_point(mQ, mG, curve->Af,
                                                              curve->prime, mp);
                }
                /* When only Z zero then result is infinity */
                else {
                    err = mp_set(mG->x, 0);
                    if (err == MP_OKAY)
                        err = mp_set(mG->y, 0);
                    if (err == MP_OKAY)
                        err = mp_set(mG->z, 1);
                }
            }
        }
        else {
            /* compute 0*mG + u2*mQ = mG */
            err = wc_ecc_mulmod_ex(u2, mQ, mG, curve->Af, curve->prime, 0,
                                                                     key->heap);
            /* find the montgomery mp */
            if (err == MP_OKAY)
                err = mp_montgomery_setup(curve->prime, &mp);
        }

        /* reduce */
        if (err == MP_OKAY)
            err = ecc_map(mG, curve->prime, mp);
    }
    if (err == MP_OKAY)
    {
        mp_digit mp = 0;

        if (!mp_iszero(u1)) {
             
            err = wc_ecc_mulmod_ex(u1, mG, mG, curve->Af, curve->prime, 0,
                                                                     key->heap);
            if (err == MP_OKAY) {
                err = wc_ecc_mulmod_ex(u2, mQ, mQ, curve->Af, curve->prime, 0,
                                                                     key->heap);
            }

             
            if (err == MP_OKAY)
                err = mp_montgomery_setup(curve->prime, &mp);

             
            if (err == MP_OKAY)
                err = ecc_projective_add_point(mQ, mG, mG, curve->Af,
                                                              curve->prime, mp);
            if (err == MP_OKAY && mp_iszero(mG->z)) {
                 
                if (mp_iszero(mG->x) && mp_iszero(mG->y)) {
                    err = ecc_projective_dbl_point(mQ, mG, curve->Af,
                                                              curve->prime, mp);
                }
                 
                else {
                    err = mp_set(mG->x, 0);
                    if (err == MP_OKAY)
                        err = mp_set(mG->y, 0);
                    if (err == MP_OKAY)
                        err = mp_set(mG->z, 1);
                }
            }
        }
        else {
             
            err = wc_ecc_mulmod_ex(u2, mQ, mG, curve->Af, curve->prime, 0,
                                                                     key->heap);
             
            if (err == MP_OKAY)
                err = mp_montgomery_setup(curve->prime, &mp);
        }

         
        if (err == MP_OKAY)
            err = ecc_map(mG, curve->prime, mp);
    }