/// <summary> /// using inside wallet for signing transaction /// </summary> /// <param name="PrivateKey">issuer privatekey path</param> public void GenerateSignture(string PrivateKey) { using (var rsa = new RsaSignatureProvider(PrivateKey)) { var data = (ID.ToString() + Issuer + Reciepient + Amount + TransactionVersion.ToString() + Sequence.ToString()); _signture = rsa.GenerateSignture(data); Signture = _signture.Value; } }
public void TestRsaSignature() { var rsasign1 = new RsaSignatureProvider(); var rsasign2 = new RsaSignatureProvider(rsasign1.PublicKey); AesFileEncryptionPrivider.Create("Xunit"); rsasign1.ExportPrivateKey("testkey.dat"); var rsasign3 = new RsaSignatureProvider("testkey.dat"); var rsasign4 = new RsaSignatureProvider(); var message = "Unit Testing With Xunit is cool!!"; var sb = new StringBuilder(message); for (int i = 0; i < 1000; i++) { sb.Append(i.ToString()); sb.Append(" : "); sb.Append(message); sb.AppendLine(); } var Message = sb.ToString(); var sign1 = rsasign1.GenerateSignture(message); var sign2 = rsasign1.GenerateSignture(Message); var sign3 = rsasign3.GenerateSignture(Message); var sign4 = rsasign4.GenerateSignture(Message); Assert.NotEqual(sign1, sign2); Assert.NotEqual(sign2, sign4); Assert.True(rsasign1.VerifySignature(message, sign1)); Assert.True(rsasign1.VerifySignature(Message, sign2)); Assert.False(rsasign1.VerifySignature(message, sign2)); Assert.True(rsasign1.VerifySignature(Message, sign2)); Assert.True(rsasign1.VerifySignature(Message, sign3)); Assert.True(rsasign3.VerifySignature(message, sign1)); Assert.False(rsasign4.VerifySignature(message, sign1)); rsasign1.Dispose(); rsasign2.Dispose(); rsasign3.Dispose(); rsasign4.Dispose(); }