const vx2 = ge_frombytes_negate_vartime_vx2
const check = ge_frombytes_negate_vartime_check
+ // Decode bytes to y-coordinate
fe_frombytes(h.Y, s)
fe_1(h.Z)
- // u = y²-1
- // v = dy²+1
+ // u = y²
fe_sq(u, h.Y)
+ // v = dy²
fe_mul_d(v, u)
+ // u = y²-1
u[0] -= 1
+ // v = dy²+1
v[0] += 1
// v2 = v²
// p = vx²+u
fe_add(check, vx2, u)
if (fe_iszero(check, t_fe_0, t_u8x32) == 0) {
+ // Reject invalid point
return -1
}
+ // x = x√-1
fe_mul_sqrtm1(h.X, h.X)
}
+ // x = |x|
if (fe_isnegative(h.X, t_fe_0) == (s[31] >> 7)) {
fe_neg(h.X, h.X)
}
+ // Create point projection
fe_mul(h.T, h.X, h.Y)
return 0
fe_frombytes(h.Y, s)
fe_1(h.Z)
- // u = y²-1
- // v = dy²+1
+ // u = y²
fe_sq(u, h.Y)
+ // v = dy²
fe_mul_d(v, u)
+ // u = y²-1
u[0] -= 1
+ // v = dy²+1
v[0] += 1
- // x = u(uv)⁽𐞥⁻⁵⁾⸍⁸
+ // x = uv
fe_mul(h.X, u, v)
+ // x = (uv)⁽𐞥⁻⁵⁾⸍⁸
fe_pow22523(h.X, h.X, t_fe_0, t_fe_1, t_fe_2)
+ // x = u(uv)⁽𐞥⁻⁵⁾⸍⁸
fe_mul(h.X, u, h.X)
// vx2 = x²
fe_sq(vx2, h.X)
-
// vx2 = vx², x_sqrtm1 = x√-1
fe_mul_pair_sqrtm1(vx2, vx2, v, x_sqrtm1, h.X)
has_p_root = fe_iszero(p_root_check, t_fe_0, t_u8x32)
has_m_root = fe_iszero(m_root_check, t_fe_0, t_u8x32)
+ // x = x√-1 if vx² = -u, else x
fe_cmov(h.X, x_sqrtm1, 1 - has_m_root)
+ // negx = -x
fe_neg(negx, h.X)
+ // x = |x|
fe_cmov(h.X, negx, fe_isnegative(h.X, t_fe_0) ^ (s[31] >> 7))
+
+ // Create point projection
fe_mul(h.T, h.X, h.Y)
return i32(has_m_root | has_p_root) - 1