When I use the merkle proof example of libsnark, I find that it takes more time to calculate the merkle tree than to calculate the proof. As shown in the log below, it takes 0.04s to calculate a SHA256. When the depth of the tree is 20, it takes at least 3 hours to exac SHA256, but only 14s to exac proof. I notice that it seems like to have generated a r1cs witness when exacing SHA256, but is it necessary to generate r1cd for the whole tree?
And maybe it's because I'm not good at C++, I can't find where the hash function pass the R1CS back.
23/23 Test #23: test_sha256_gadget ............................... Passed 0.04 sec