public static bool Verify(ReadOnlyMemory <byte> publicKey, ReadOnlyMemory <byte> signature, ReadOnlySequence <byte> sequence) { using var ecdsa = ECDsa.Create(); ecdsa.ImportSubjectPublicKeyInfo(publicKey.Span, out var _); return(ecdsa.VerifyHash(Sha2_256.ComputeHash(sequence).AsSpan(), signature.Span)); }
public static byte[] Sign(ReadOnlyMemory <byte> privateKey, ReadOnlySequence <byte> sequence) { using var ecdsa = ECDsa.Create(); ecdsa.ImportPkcs8PrivateKey(privateKey.Span, out var _); return(ecdsa.SignHash(Sha2_256.ComputeHash(sequence))); }