C# ecdsa signature - Which key specification can i choose?

这一生的挚爱 提交于 2019-12-04 17:28:30

I've found something about my first question:

Which is the equivalent curve name in C# mentioned above?

The microsoft libraries support only P-256, P-384 and P-521 "NIST-recommended elliptic curve ID", that is the equivalent named curve, rispectively, secp256r1, secp384r1, secp521r1 of "SEC 2 recommended elliptic curve domain parameters" that are the equivalent of prime256v1, but not 384 and 521 in ANSI X9.62 ECDSA prime curve ID. Bouncy castle libraries for C#, support more other curves like the secp224k1 that i was interested.

For the second question

Could somebody make me an example about how, in C#, i can generate a keyPair like the above java code?

i've found an old example here It says that the keys supported are only 3: 192 bit, 239 bit and 256 bit, but i think is referred to some old version of the library

this code can demonstrate it

ECKeyPairGenerator gen = new ECKeyPairGenerator("ECDSA");
        SecureRandom secureRandom = new SecureRandom();
        Org.BouncyCastle.Asn1.X9.X9ECParameters ecp = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp224k1");
        ECDomainParameters ecSpec = new ECDomainParameters(ecp.Curve, ecp.G, ecp.N, ecp.H, ecp.GetSeed());
        ECKeyGenerationParameters ecgp = new ECKeyGenerationParameters(ecSpec, secureRandom);
        gen.Init(ecgp);
        AsymmetricCipherKeyPair eckp = gen.GenerateKeyPair();

If somebody wants try to make it better, i think that this thread could be very precious for all. Im only a beginner with C# and this code isn't mine. :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!