Difference between using Schnorr Protocol and just compare hash function to prove knowing something? I am studying the Schnorr Protocol, and I just come up a case.
For example, I am a Prover and have a secret $x$. By using the Schnorr Protocol, I create $h=g^x \bmod p$ and save $h$ to a public place.
When a Verifier needs to prove to the Prover,

Prover sends a commitment to verifier $c = g^r \bmod p$ where $r$ is a random value
Verifier sends a challenge to prover $t$ is a random value
prover sends a response to verifier $s = r + t\,x$
verifier accepts iff  $g^s \bmod p= c\,h^t\bmod p$

What is the difference if I store a hashed value for example $h = \operatorname{sha512}(x)$ to a public place, and if prover want to prove he know secret $x$, he just need to send $h'$ to verifier and verifier compare if $h = h'$ stand.
I know that a dishonest prover can send the hash to the verifier directly to fool the verifier. Apart from this, is there any difference? It seems that using a hash can still prove the prover knows secret $x$.
The question does not correctly describe the Schnorr protocol. Here it is (with restriction to a multiplicative subgroup of $\Bbb Z_p^*$, because that's in the question).

It is chosen a large prime $q$ (e.g. $&gt;\approx 2^{512}$) and a larger prime $p$ (e.g. $&gt;\approx 2^{8192}$) with $p=2\,a\,q+1$ for some integer $a\ge1$ (with $p$ not of a special form facilitating SNFS), and an integer $g$ of order $q$, that is with $g^q\bmod p=1$ and $g\bmod p\ne1$ (one such $g$ is $4^a\bmod p$). Parameters $p$, $q$, $g$ are public.

A random secret $x\in[0,q)$ is known to a Prover, who publishes $h=g^x\bmod p$. The above choice of parameters $p$, $q$, $g$ is such that the Discrete Logarithm Problem of finding $x$ given $h$ is believed hard.

The protocol's goal is that a verifier gets rightly convinced that a party knowing $x$ with $h=g^x\bmod p$ participates in the protocol, without revealing $x$ to the prover or to adversaries, including active (in particular, adversaries are able to impersonate the prover w.r.t. the verifier, and vice versa). Towards this:


Prover draws a random value $r\in[0,q)$ and sends commitment $c=g^r\bmod p$
Verifier draws a random value $t\in[0,q)$ and sends that challenge to prover.
Prover computes and sends response $s=r+t\,x\bmod q$
Verifier is content that prover knows $x$ iff $g^s\bmod p=c\,h^t\bmod p$


That equality normally holds because $s=r+t\,x\bmod q$ implies that $\exists k,\ s+k\,q=r+t\,x$ therefore $g^s\equiv g^{r+t\,x-k\,q}\equiv g^r\,g^{t\,x}\,g^{-k\,q}\equiv c\,(g^x)^t\,(g^q)^{-k}\equiv c\,h^t\,1^{-k}\equiv c\,h^t\pmod p$.

It can be shown that breaking this protocol is equivalent to solving the DLP.




  What is the difference if I store a hashed value for example $h=\operatorname{SHA-512}(x)$ to a public place, and if prover wants to prove he knows secret $x$, he just need to send $h'$ to verifier and verifier compare if $h=h'$ stands.


The proposed protocol fails to prove to the verifier that another party knowing $x$ participates in the protocol. Argument: since $h$ is in a public place, an adversary not knowing $x$ can get $h$, send that as $h'$ like the prover knowing $x$ is supposed to do, and thus pass the verifier's test. 

If prover and verifier both know $x$, a solution is possible using $\operatorname{SHA-512}$ in a challenge-response protocol: verifier draws and sends random $t$, prover computes and sends $s=\operatorname{SHA-512}(t\mathbin\|x)$, verifier checks $s=\operatorname{SHA-512}(t\mathbin\|x)$.

The advantage of Schnorr's protocol is to achieve the same goal without requiring the verifier to know $x$. In particular, in the MAC-based protocol, the verifier must keep $x$ secret, which is hard even for an honest verifier, and is not necessary with Schnorr's protocol.