using PCC.App.Security; using System.Security.Cryptography; namespace PCC.App.Tpm; public interface IPeerInfoProvider { public ICollection PeerInfo { get; } } public interface ILocalPeerInfo { //RSA PublicKey { get; } RSA PrivateKey { get; } string PeerId { get; } string Address { get; } int Port { get; } ICollection TrustedRemotePeers { get; } } public class LocalPeerInfo(byte[] publicKey, byte[] privateKey, string address, int port, ICollection remotePeers) : ILocalPeerInfo { //public RSA PublicKey { get; } = RsaUtility.FromPKCS1PublicKey(publicKey); public RSA PrivateKey { get; } = RsaUtility.FromPKCS1PublicKey(privateKey); public string PeerId { get; } = Convert.ToHexString(SHA256.HashData(publicKey)); public string Address { get; } = address; public int Port { get; } = port; public ICollection TrustedRemotePeers { get; } = remotePeers; } public interface IRemotePeerInfo { RSA PublicKey { get; } string PeerId { get; } string Host { get; } int Port { get; } } public class RemotePeerInfo(byte[] publicKey, string host, int port) : IRemotePeerInfo { public RSA PublicKey { get; } = RsaUtility.FromPKCS1PublicKey(publicKey); public string PeerId { get; } = Convert.ToHexString(SHA256.HashData(publicKey)); public string Host { get; } = host; public int Port { get; } = port; }