I’ve got two questions:

  1. I’m doing the following:

    Data :  uuid + int + nonce 
    Signature:  ECDSA(sha256(Data) )

    To verify the signature:

    decrypt(Signature) == sha256(data) 

    So if the data, hash function, and public key are known, why is there a need to hash?

  2. If the same Data with a different nonce is sent over and over, can someone figure out my private key?

1 Answer 1


First of all I do not know your implementation, but it seems that you have some basic misunderstandings.

Signature: ECDSA(sha256(Data) )

ECDSA is typically implemented in a way that you do not explicitly hash the data prior to passing it to the signing algorithm (but as this might be your own implementation and signing may still work correctly).

decrypt(Signature) == sha256(data)

In ECDSA signature verification you do not decrypt anything nor compare the hash value of the message with some signature value, but the hash value of the message is used implicitly in the verification relation. So I do not see any chance that your verification will work.

I think you actually read a bad source about RSA signatures which uses the wrong and misleading term "decrypt with public key". This is sometimes used because in RSA the enryption and decryption function is commutative and thus RSA encryption and RSA signature schemes use the same operations in different order. So you sometimes read instead of signing the term "encrypt with private key" and instead of verifying "decrypt with public key", but you should not use this terminology, as this does not apply to other signature schemes such as ECDSA. Furthermore, due to this way of signing in RSA in the verification you compare the value obtained by performing the public key operation on the signature with the hash value, but also this does not hold for other signature schemes such as ECDSA.

To your next question:

So if the data, hash function, and public key are known, why is there a need to hash?

If you do not hash the data before signing you cannot have one consistent signature algorithm, because you could only sign messages up to a certain size and if the size of the message gets too large you would need to hash. But that is not a good practice for signature schemes. More importantly, there are signature schemes which can easily be forged when the data is not hashed, such as RSA, see my answer here. In order to have security independent of the size of the signed message, we typically use this hash-then-sign paradigm, i.e., hash the plain message before performing signing operations on it, and thus the signature algorithm works for any size of the message and we do not really have to care about the message size.

So to your final question

If the same Data with a different nonce is sent over and over, can someone figure out my private key?

If you use a secure digital signature scheme (for instance ECDSA - which internally hashes the message) and a correct implementation thereof, then you are safe.

Finally, your last question in context of ECDSA, i.e., would your private key be safe in ECDSA when not using a hash function?

All ELGamal type signatures (ECDSA is one of those) are existential forgable if no hash function is used. Although this does not reveal your private key, it allows everyone to compute valid signatures for messages which you have not signed. Although the adversary has no choice over the message for which the forged signature is computed, don't do that and use the standard ECDSA with hashing.

  • 1
    $\begingroup$ Hmm, while this corrects some mistakes in the question, it doesn't really answer the underlying question: Would ECDSA be safe for small messages if we omitted the hashing step? $\endgroup$ Commented Mar 30, 2014 at 12:39
  • $\begingroup$ @Paŭlo Ebermann added a sentence in this. $\endgroup$
    – DrLecter
    Commented Mar 30, 2014 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.