I am new to ECDSA. I am verifying a hash's signature. I have a sample code. It is all ok to create a signature and verifying it:
....
//Signing
byte[] ecdsa_sig = ecdsa.SignHash(hash256);
str1 += "\n\nECDSA Signature (Hex)=" + BitConverter.ToString(ecdsa_sig).Replace("-", string.Empty);
str1 += "\nECDSA Signature (Base64)=" + System.Convert.ToBase64String(ecdsa_sig).Replace("-", string.Empty);
//On the receiver side
ECParameters ecparams_rec = new ECParameters();
ecparams_rec.Q = new ECPoint();
ecparams_rec.Q.X = System.Convert.FromBase64String("RfXXNxTu8xRb48jrJs9kjhQun3+PXqzowby8RwIVTkE=");
ecparams_rec.Q.Y = System.Convert.FromBase64String("YC77gvGyFYA+iJ/+Ak7lN8H4hY7tV7TUiY/rPTJOajk=");
ecparams_rec.Curve = ECCurve.NamedCurves.nistP256; //32 bytes private key
ECDsa ecdsa_rec = System.Security.Cryptography.ECDsa.Create(ecparams_rec);
string word_rec = "Hello Crypto World! ";
//Verifying
byte[] hash256_rec = System.Security.Cryptography.HashAlgorithm.Create(hashmethod).ComputeHash(System.Text.Encoding.UTF8.GetBytes(word_rec));
bool res = ecdsa_rec.VerifyHash(hash256_rec, ecdsa_sig);
if (res == true) str1 += "\n\nSignature verifies - OK";
else str1 += "\n\nSignature not verified!!!!!";
Console.WriteLine("{0}",str1);
I am using the Public Key (Q.X and Q.Y params) to verify the signature. What looks strange to me though is that it happens that I could change some of the final chars (before the last 'E' -> 'F') of the public keys and if I am lucky (very luckily) the signature is still verified. So my question is: how come that "altered" Public Keys can still verify the signature?