private void BasicSigTest() { Ed448PrivateKeyParameters privateKey = new Ed448PrivateKeyParameters( Hex.DecodeStrict( "6c82a562cb808d10d632be89c8513ebf" + "6c929f34ddfa8c9f63c9960ef6e348a3" + "528c8a3fcc2f044e39a3fc5b94492f8f" + "032e7549a20098f95b"), 0); Ed448PublicKeyParameters publicKey = new Ed448PublicKeyParameters( Hex.DecodeStrict("5fd7449b59b461fd2ce787ec616ad46a" + "1da1342485a70e1f8a0ea75d80e96778" + "edf124769b46c7061bd6783df1e50f6c" + "d1fa1abeafe8256180"), 0); byte[] sig = Hex.DecodeStrict("533a37f6bbe457251f023c0d88f976ae" + "2dfb504a843e34d2074fd823d41a591f" + "2b233f034f628281f2fd7a22ddd47d78" + "28c59bd0a21bfd3980ff0d2028d4b18a" + "9df63e006c5d1c2d345b925d8dc00b41" + "04852db99ac5c7cdda8530a113a0f4db" + "b61149f05a7363268c71d95808ff2e65" + "2600"); ISigner signer = new Ed448Signer(new byte[0]); signer.Init(true, privateKey); IsTrue(AreEqual(sig, signer.GenerateSignature())); signer.Init(false, publicKey); IsTrue(signer.VerifySignature(sig)); }
/// <summary> /// Verifies a signature to be authentic /// </summary> /// <param name="originalSignature">The signature which is be verified</param> /// <param name="publicKey">the public key used for the verification</param> /// <param name="data">the data which is signed</param> /// <returns>true if signature is authentic, false if not</returns> public bool Verify(byte[] originalSignature, byte[] publicKey, byte[] data) { Ed448PublicKeyParameters pubKey = null; try { pubKey = (Ed448PublicKeyParameters)CreateAsymmetricKeyParameterFromPublicKeyInfo(publicKey); } catch (InvalidCastException exception) { string message = "Public Key Import Failed!\n" + $"{exception.Message}.\n" + "The contents of the source do not represent a valid Ed448 key parameter\n" + "Verify that the key is not corrupted.\n" + "- or - Verify that the correct key is selected."; throw new CryptoException(message, exception); } var signer = new Ed448Signer(ByteConvert.StringToAsciiBytes("context")); signer.Init(false, pubKey); signer.BlockUpdate(data, 0, data.Length); return(signer.VerifySignature(originalSignature)); }