public static bool CheckSignature(Input inp) { List <string> stringList = inp.ScriptSign.Split(' ').ToList(); string signature = stringList[0]; string receiverPublicKey = stringList[1]; string stringToVerify = inp.PrevTransactionHash + " " + inp.OutputIndex.ToString(); ECDsaSignature verifier = ECDsaSignature.FromKeys(receiverPublicKey); return(verifier.VerifyData(Encoding.Default.GetBytes(stringToVerify), Encoding.Default.GetBytes(signature))); }
private void button_validate_Click(object sender, EventArgs e) { if (textBox_Verifier_PublicKey.Text == string.Empty || textBox_Verifier_Message.Text == string.Empty || textBox_verifier_signature.Text == string.Empty) { MessageBox.Show("Please check input parameters"); return; } ///DATA SIGNATURE VERIFICATION-SERVER SIDE Parameters needed: Public Key, The Signature, The Message string publicKey = textBox_Verifier_PublicKey.Text; string message = textBox_Verifier_Message.Text; byte[] byteMessage = Encoding.Default.GetBytes(message); byte[] byteSignature = signature; ECDsaSignature verifier = ECDsaSignature.FromKeys(publicKey); //creating a verifier object bool result = verifier.VerifyData(byteMessage, byteSignature); //result if the signature was created by true public key MessageBox.Show(result?"the signature is valid":"signature is invalid"); }