waku-org / js-rln

Browser library providing the cryptographic functions for Waku RLN Relay https://rfc.vac.dev/spec/17/
Apache License 2.0
5 stars 1 forks source link

Persist Merkle tree, valid roots and last sync block #67

Open fryorcraken opened 1 year ago

fryorcraken commented 1 year ago

Summary

Merkle tree, valid roots and last sync blocks are necessary to generate and validate proof. This information is retrieved from the blockchain.

Accessing the blockchain represent several challenges:

Proposed solution

Cache the information locally (local storage?). The information is publicly available on the blockchain and does not need to be protected.

Note

fryorcraken commented 1 year ago

@richard-ramos @rymnc except if sled-db magically store information in the local storage, and even so, it is most likely more efficient to pass on our persistence by storing data in json format in the browser's local storage.

rymnc commented 1 year ago

@richard-ramos @rymnc except if sled-db magically store information in the local storage, and even so, it is most likely more efficient to pass on our persistence by storing data in json format in the browser's local storage.

not too sure about where the sled db will be stored in wasm land, but what we can do is add 2 fns to the rln-wasm api, import and export, which accepts a json blob and returns one respectively. This way, on initialisation of the rln object, you can "import" the json blob into the new sled db instance, and before shutting down, "export" it to localStorage?