'Generate ED25519 keys for ssh connection with Bouncy Castle c#

I have to generate che keys in ED25519 for SSH connection. I'm able to create the public and the private keys but not the key for ssh. Is there anyone who can help me? Below my C# code.

Thanks

IAsymmetricCipherKeyPairGenerator gen;
KeyGenerationParameters param;
gen = new Ed25519KeyPairGenerator();
param = new Ed25519KeyGenerationParameters(new SecureRandom());
gen.Init(param);
var keyPair = gen.GenerateKeyPair();

TextWriter textWriter = new StringWriter();
PemWriter pemWriter = new PemWriter(textWriter);
pemWriter.WriteObject(keyPair.Private);
pemWriter.Writer.Flush();
                 
var privateKeyParam = keyPair.Private;

textWriter = new StringWriter();
pemWriter = new PemWriter(textWriter);
pemWriter.WriteObject(keyPair.Public);
pemWriter.Writer.Flush();

result.PrivateKey = textWriter.ToString();
result.PublicKey = textWriter.ToString();




Solution 1:[1]

The similar answer is posted here: https://stackoverflow.com/a/60354942/7799305

Maybe try using this library SshKeyGenerator

Heres the GitHub repo: https://github.com/ShawInnes/SshKeyGenerator

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrija Peric