How to prove a directory or an image file using node SDK
perdona opened this issue · 9 comments
I'm trying to use the node SDK to prove a directory or an image file, but I can't seem to find any example of how to achieve this.
After you run the above commands, there will also be a Graphviz Dot Graph (mydir.proofable.dot
) of your proof generated in your current working directory. You can use a viewer such as this to view it:
@guiguan Thanks a lot for the rapid response! Will test this asap and post feedback here!
Thanks again!
Works perfectly, guys! Thanks a lot!
Guys, I'm trying to implement a document verification using proofable node sdk.
Is there a way to implement an incremental way of hashing a directory, meaning that root and previous proofs are immutable?
@perdona yes, the proof (trie) itself is immutable, e.g. whenever you modify an existing trie with setTrieKeyValues
, a new trie with a new root will be returned, which is built incrementally on top of your old trie. Only modified nodes of the old trie are cloned, other nodes will be shared across the old and new tries. You can still access the old trie with the old root.
For a directory, you can build an initial trie with few key-values, then use setTrieKeyValues
s to push more key-values in as a way to build the trie incrementally.
@guiguan Right! So to modify an existing trie, I should use the .proofable
exported previously? And which method should I use to proof again new pushed keyvalues? (I'm sorry about posting a lot here)
@perdona yes, for now:
- import your existing trie (
.proofable
) withimportTrie
- add/update/delete key values with
setTrieKeyValues
, which will give you the new root - create a proof for the new trie with the new root using
createTrieProof
- you can use
subscribeTrieProof
to wait for the new proof to be confirmed. Here is an example - export the new trie which contains everything with
exportTrie
After you import the existing trie, you can also use APIs like createkeyvaluesproof
to create a proof for a subset of the key-values, and later on, you can use verifyKeyValuesProof
to verify them independently.
We are also working on a cloud trie, where we store the trie in Proofable cloud for you and you don't have to keep importing and exporting proofs from time to time.