I've seen an application recently that used the Diffie Hellman algorithm. It is not a Ephemeral Diffie-Hellman implementation, but rather a Diffie Hellman one. After the secret keys have been calculated, the client then sends a SHA-512 hash of the key to the server when the server asks for it. The only reason I can think of is, the server computes a SHA-512 hash of its secret key and requests the clients hash to detect MITM attacks. Is this wise? safe? What other reason would the application need to do this for?
By sending a SHA-512 hash of it, you don't expose more useful information about the key, than the attacker had from the Diffie-Hellman messages. However, it is completely insecure to rely on that hash. The man in the middle could give every side its needed hash, and still could intercept the traffic. For Diffie-Hellman to provide any security, either the messages must be signed with a public key cryptosystem, or the negotiated key. Note that when a signature gets transmitted, no more information leaks about the signed content than a hash.