本文整理汇总了C++中PointGFp::get_affine_x方法的典型用法代码示例。如果您正苦于以下问题:C++ PointGFp::get_affine_x方法的具体用法?C++ PointGFp::get_affine_x怎么用?C++ PointGFp::get_affine_x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointGFp
的用法示例。
在下文中一共展示了PointGFp::get_affine_x方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
bool PointGFp::operator==(const PointGFp& other) const
{
if(m_curve != other.m_curve)
return false;
// If this is zero, only equal if other is also zero
if(is_zero())
return other.is_zero();
return (get_affine_x() == other.get_affine_x() &&
get_affine_y() == other.get_affine_y());
}
示例2: if
// encoding and decoding
secure_vector<uint8_t> EC2OSP(const PointGFp& point, uint8_t format)
{
if(point.is_zero())
return secure_vector<uint8_t>(1); // single 0 byte
const size_t p_bytes = point.get_curve().get_p().bytes();
BigInt x = point.get_affine_x();
BigInt y = point.get_affine_y();
secure_vector<uint8_t> bX = BigInt::encode_1363(x, p_bytes);
secure_vector<uint8_t> bY = BigInt::encode_1363(y, p_bytes);
if(format == PointGFp::UNCOMPRESSED)
{
secure_vector<uint8_t> result;
result.push_back(0x04);
result += bX;
result += bY;
return result;
}
else if(format == PointGFp::COMPRESSED)
{
secure_vector<uint8_t> result;
result.push_back(0x02 | static_cast<uint8_t>(y.get_bit(0)));
result += bX;
return result;
}
else if(format == PointGFp::HYBRID)
{
secure_vector<uint8_t> result;
result.push_back(0x06 | static_cast<uint8_t>(y.get_bit(0)));
result += bX;
result += bY;
return result;
}
else
throw Invalid_Argument("EC2OSP illegal point encoding");
}
示例3: verify
bool ECDSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
const byte sig[], size_t sig_len)
{
if(sig_len != order.bytes()*2)
return false;
BigInt e(msg, msg_len);
BigInt r(sig, sig_len / 2);
BigInt s(sig + sig_len / 2, sig_len / 2);
if(r <= 0 || r >= order || s <= 0 || s >= order)
return false;
BigInt w = inverse_mod(s, order);
PointGFp R = w * multi_exponentiate(base_point, e,
public_point, r);
if(R.is_zero())
return false;
return (R.get_affine_x() % order == r);
}