I generated a key by running following command:
openssl ecparam -genkey -name secp256k1 -out private.key
Worth mentioning that I had to use secp256k1
curve.
Here is private.key:
-----BEGIN EC PARAMETERS-----
BgUrgQQACg==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIMaqRFP3zkco2B2xZaIDQ0/JGcgOqzLPcTTJPqvpu+UooAcGBSuBBAAK
oUQDQgAEp0mktO9BMlsVw9lG8EIxr9wZizBHSlUv3VIbf3sTBmCxE4myJvZcgF8b
qDp0T/o9TqnsBw15LU3wdnqV4tJp6w==
-----END EC PRIVATE KEY-----
Then I tried to sign some random plain-text message:
var privateKey = CngKey.Import(privateKeyBytes, CngKeyBlobFormat.EccPrivateBlob);
var signer = new ECDsaCng(privateKey);
var signed = signer.SignData(messageBytes, HashAlgorithmName.SHA256);
But encountered a problem when called CngKey.Import: Windows Cryptography Next Generation (CNG) is not supported on this platform.
(MacOS)
Is there any way to accomplish it cross-platform?