Is there any way in crypto++ to check if an EC contains a point with a given x-coordinate?
One solution would be solving the EC polynomial for given x. One side of the equation already done in code. I 'just' need to compute the root of it (over a finite field)
//clang++ -o ectest ectest.cpp -lcryptopp
#include "cryptopp/eccrypto.h"
#include "cryptopp/oids.h"
int main(int argc, char* argv[]) {
using namespace CryptoPP;
typedef DL_GroupParameters_EC<ECP> GroupParameters;
typedef DL_GroupParameters_EC<ECP>::Element Element;
GroupParameters group;
group.Initialize(ASN1::secp256k1());
//I want to check if the EC has a point with x-cooridnate x=13
Integer x = 13;
Integer ecmod = group.GetCurve().GetField().GetModulus();
ModularArithmetic ma = ModularArithmetic(ecmod);
//the following equation need to be solved:
//y^2 = x^3 + Ax + B \mod ecmod
Integer x3 = ma.Multiply(x,x);
x3 = ma.Multiply(x3,x);
Integer xa = ma.Multiply(group.GetCurve().GetA(),x);
Integer xb = group.GetCurve().GetB();
Integer sr = ma.Add(x3,xa);
sr = ma.Add(sr,xb);
//y^2 = sr
//how to compute the root out of sr?
//or is there any other way to check if the EC contains a point with x?
}