27 fp A_times_one_third, A_squared, C_squared;
28 fp t, r, s, u, aux, tmp, y;
29 fp s0, s1, s2, s0_squared, v;
34 fp_mul(A_times_one_third, ONE_THIRD, input_A.
x);
41 fp_add(t, C_squared, C_squared);
47 fp_mul(r, A_squared, input_A.
x);
55 fp_add(s, A_times_one_third, A_times_one_third);
67 fp_add(y, C_squared, C_squared);
96 fp_mul(tmp, v, s0_squared);
110 uint64_t test_s1 = fp_isequal(tmp, t);
111 uint64_t test_s2 = fp_isequal(aux, s);
114 fp_sub(t, s1, s0_squared);
117 fp_sub(r, s1, s0_squared);
120 fp_add(s, s2, s0_squared);
122 fp_sub(u, s0_squared, s2);
126 fp_cmov(&output[0], (
const fp*)t, test_s1);
127 fp_cmov(&output[1], (
const fp*)r, test_s1);
128 fp_cmov(&output[0], (
const fp*)s, test_s2);
129 fp_cmov(&output[1], (
const fp*)u, test_s2);
132 fp_mul(output[2], s0, input_A.
z);
133 fp_mul(aux, s0, A_times_one_third);
134 fp_sub(output[0], output[0], aux);
135 fp_sub(output[1], output[1], aux);
140 fp_mul(v, input_A.
z, output[0]);
141 fp_mul(t, output[2], input_A.
x);
143 fp_mul(aux, s, output[2]);
151 fp_cswap(output[0], output[1], test_sqr);
155 fp r_squared, s_squared, r_cubed;
156 fp aux, alpha_cubed, alpha, rd;
161 fp_sqr(r_squared, input_t[0]);
163 fp_sqr(s_squared, input_t[1]);
165 fp_mul(r_cubed, r_squared, input_t[0]);
167 fp_mul(output_A[1], s_squared, input_t[1]);
169 fp_mul(aux, s_squared, input_t[0]);
172 fp_sub(alpha_cubed, r_squared, s_squared);
173 fp_mul(alpha_cubed, alpha_cubed, input_t[0]);
179 fp_mul(rd, input_t[0], alpha);
180 fp_add(rd, rd, r_squared);
184 fp_add(r_squared, rd, rd);
185 fp_add(rd, rd, r_squared);
189 fp_mul(r_squared, s_squared, alpha);
190 fp_sub(output_A[0], rd, r_squared);