How can one calculate a message hash?
You take the text input, whether it is some signed message text or a raw transaction, and then pass it through SHA256(SHA256(input)), and save the result as
e.
For ECDSA done on the secp256k1 curve, such as all kinds of bitcoin signatures, we are done at this point and we can set
h = e our message hash.
However for some other different curves, you have to take the leftmost n bits of
e after the double SHA256 hash. Where n can be found from the group order of the curve. So for example, secp256k1's group order is about 2^256 so it's n would be 256.
Keep in mind that the leftmost n bits equals the entire length of
e if log2(curve's group order) == bit length of hash function used. When we are using both double SHA256 and secp256k1 curve in ECDSA like we are now, we know the double SHA256 always outputs 256 bits so these two values are equal and the entirety of
e is used as the message hash.
The above paragraph implies that you are able to use a different hash function other than double SHA256
provided that its number of bits of output is greater than log2(curve's group order), because smaller-length hash functions are not allowed to be used with larger curve orders.