public static Key KeyExchange(KeyTypes keyType, Key privateKey, Key publicKey) { if (keyType == KeyTypes.Ed25519) { return(Ed25519Key.KeyExchangeInternal(privateKey as Ed25519Key, publicKey as Ed25519Key)); } throw new ArgumentException(string.Format("Key type not implemented {0}", keyType)); }
public SigningTool(string ed25519KeyPath) { if (!File.Exists(ed25519KeyPath)) { throw new ArgumentException("ed25519 Private Key file does not exist", nameof(ed25519KeyPath)); } var key = Ed25519Key.FromFile(ed25519KeyPath); _privateKey = Key.Import(_algorithm, key.ToBytes(), KeyBlobFormat.PkixPrivateKey); }
public static Ed25519Key FromFile(this Ed25519Key key, string path) { if (!File.Exists(path)) { throw new ArgumentException("Key file path is invalid", nameof(path)); } var json = File.ReadAllText(path); if (string.IsNullOrEmpty(json)) { throw new ArgumentException("Provided file contains no data", nameof(path)); } return(JsonSerializer.Deserialize <Ed25519Key>(json)); }
internal static Ed25519Key KeyExchangeInternal(Ed25519Key privateKey, Ed25519Key publicKey) { if (privateKey == null || !privateKey.IsPrivate) { throw new ArgumentException("Invalid Private Key", nameof(privateKey)); } if (publicKey == null) { throw new ArgumentException("Invalid Public Key", nameof(privateKey)); } var sharedKeyData = new byte[32]; Ed25519.KeyExchange(new ArraySegment <byte>(sharedKeyData), publicKey.RawData, privateKey.RawData); return(new Ed25519Key(sharedKeyData)); }
public Verifier(Ed25519Key publicKey) { _signatureTool = new SignatureTool(publicKey); }