BigInt PointGFp::get_affine_y() const { if(is_zero()) throw Illegal_Transformation("Cannot convert zero point to affine"); BigInt z3 = curve_mult(m_coord_z, curve_sqr(m_coord_z)); z3 = inverse_mod(z3, m_curve.get_p()); m_curve.to_rep(z3, m_monty_ws); return curve_mult(z3, m_coord_y); }
BigInt PointGFp::get_affine_x() const { if(is_zero()) throw Illegal_Transformation("Cannot convert zero point to affine"); BigInt z2 = curve_sqr(m_coord_z); m_curve.from_rep(z2, m_monty_ws); z2 = inverse_mod(z2, m_curve.get_p()); return curve_mult(z2, m_coord_x); }
BigInt PointGFp::get_affine_y() const { if(is_zero()) throw Illegal_Transformation("Cannot convert zero point to affine"); secure_vector<word> monty_ws; BigInt z3 = m_curve.mul_to_tmp(m_coord_z, m_curve.sqr_to_tmp(m_coord_z, monty_ws), monty_ws); z3 = inverse_mod(z3, m_curve.get_p()); m_curve.to_rep(z3, monty_ws); return m_curve.mul_to_tmp(z3, m_coord_y, monty_ws); }
BigInt PointGFp::get_affine_y() const { if(is_zero()) throw Illegal_Transformation("Cannot convert zero point to affine"); const BigInt& r2 = curve.get_r2(); BigInt z3 = monty_mult(coord_z, monty_sqr(coord_z)); z3 = inverse_mod(z3, curve.get_p()); z3 = monty_mult(z3, r2); return monty_mult(coord_y, z3); }