0

I'm creating a tool that generates EC key pair. I'm new to the Elliptic Curve Algorithm. I started with this function:

public static void GenerateECPublicKey(byte[] p, byte[] g, byte[] a, byte[] b, byte[] x, byte[] y)
{
            byte[] cofactor = Utilities.HexStringToByteArray("0000");

            ECCurve curve = new ECCurve() {Prime = p, Order = g, A = a, B = b, G = new ECPoint() { X = x, Y = y },
                CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, Cofactor = cofactor};

            ECDsa ec = ECDsaCng.Create(ECCurve.NamedCurves.nistP256);
            ec.GenerateKey(curve);
}

The problem is I'm having an exception: "Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException: 'Unknown error (0xc0000001)'". Unfortunately I couldn't find any information about this exception and what is causing the issue. Am I missing some components on the ECCurve?

Thank you in advance for the one who can help.

jmt
  • 1
  • 1
  • Is P and M prime? See Wiki article : https://en.wikipedia.org/wiki/Elliptic-curve_cryptography – jdweng Aug 22 '23 at 12:09

0 Answers0