I’ve looked into SSH.net but rsa pair documentation seems to not exist and it doesn’t have a server so it’s not great.

TCP sockets aren’t ideal for larger files (I assume) and doesn’t have an rsa pair swap implementation.
Can you guys recommend me a library that could work?

You’re going to run into an issue with NAT traversal while trying to set up a peer-to-peer service. I’d use TOR to get around that.

Have your application create a hidden service on the receiving end and bind a TcpListener to the exposed port.

On the transmitting end, create a connection to TOR via the SOCKS5 proxy exposed after starting the process. If this is a project for fun, you can use the fiddly bits exposed in System.Security.Cryptography to encrypt the file before transmission. I’d generate a random AES key and IV, encrypt the file using AES in CBC mode (because it’s the default, grumble grumble), encrypt the key using your peer’s RSA public key, prepend the encrypted key and IV to the message, create an HMAC of the result, sign the HMAC using your own RSA private key, and append the HMAC and signature to the rest of the message. You can then easily send it using a NetworkStream.

On the receiving end, you’d then strip off the MAC and signature, create your own MAC of the message, and compare the generated and received MACs with a constant time equality check. Assuming they match, verify the signature using the sender’s public key. Assuming the signature is valid, you’d then decrypt the encrypted AES key using the receiver’s private key and decrypt the message using the decrypted AES key.

Of course, assuming you want it to be provably secure and you’re not just trying to learn crypto, just skip all that and use TLS to handle the end-to-end encryption.

Would bittorrent not suffice?
I’m only trying to do this locally within a network sort of like how airdrop on macos works… But I’m hopefully gonna get it working cross platform using uno
C# devs
null reference exceptions

source