Sign Bytes with Ed25519 Curve in .Net Without External Dependencies

233 Views Asked by At

I want to initialize a new System.Security.Cryptography.ECDsa using the ed25519 curve in .Net 7 without external dependencies. I am loading a dev-only private key from bytes, and want to sign hashes using it.

Something like:

var ecdsa = ECDsa.Create(new ECParameters
{
    Curve = ECCurve.CreateFromParams(ed25519 params...),
    D = privateKeyBytes,
});

My main trouble is with ECCurve: https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.eccurve?view=net-7.0. I'm not sure how to create OIDs, or how OID relates to ECCurves. I looked online and couldn't find any examples. I don't want to import BouncyCastle or other dependencies. I don't care about efficiency.

I know ECCurve in .net 7.0 does support some named curves, but it does not support ed25519.

How can I initialize a new System.Security.Cryptography.ECDsa using the ed25519 curve in .Net 7 without external dependencies?

0

There are 0 best solutions below