Usage with Proofs
"Talk is cheap, show me the code."
The proof verification is done within the smart-contract side, so as a developer we will mostly be looking at the proof generation that happens on the client side. HollowDB Prover makes proving stuff dead-simple, just call a prove
function and that is all.
Letβs digest this code step by step:
First, we read our Arweave wallet from file, to be used for our transactions. You could also provide the wallet as a JSON object within the code too (but you should be careful not to expose your wallet & accidentally commit them to your repo).
Then, we create the HollowDB SDK object. For this, we provide our wallet, we specify the cache type to be LMDB, and we provide the contract transaction id along with a Warp instance. Basically, we are βconnectingβ to our contract on the Mainnet.
We now create our Prover object, which is a wrapper around a few SnarkJS functions to generate a proof. We have to provide a path to our WASM circuit and a prover key to create this object. You can obtain them from our repository, and host them on your side. For example, if you are writing a web application, you could host them under the
public
folder.We need to compute the key, which is the hash of our preimage. You could generate a dummy proof and read the key from itβs output, but that is not really efficient. Instead, HollowDB exports a
computeKey
function for this purpose.Then, we generate our proof by simply calling
prove
with the required arguments, that are the inputs we have shown in the above diagram.Finally, we call
sdk.update
to update the value at our key, using our zero-knowledge proof!
Last updated