How/where are Merkle Proofs used in IPFS/IPLD?

I understand that once given a merkle root, a value and a path to that value, you can verify that that particular value exists within the merkle tree identified by it’s specific merkle root.

What I’m failing to see is how merkle trees/DAGs are used/created/stored in IPFS, e.g.:

If I choose the CID for a blob I’m storing (say, an Ethereum block), I can resolve the blob into memory and start traversing links. However, those links are in “resolver space” as opposed to “IPFS storage space”, that is, these links aren’t stored as links in the blob, but I can represent them as links and can traverse and pull blobs with linked CIDs from IPFS.

Likewise, if I store raw JSON (containing merkle-links) with the dag-cbor multicodec:

  • am I just encoding JSON as CBOR and storing a raw CBOR blob in IPFS?
  • Or are there merkle-links created within the blob when it’s encoded from the raw JSON? Does the graph builder library do something similar to this?
  • If so, how are these links used and stored (beyond traversing them with an IPLD resolver)?
  • Furthermore, if they are stored in a particular way (distinct from just a regular CBOR blob), are there proofs that are/can be constructed to prove a value exists within a dag-cbor object?

Hope some of that made sense!

For context: my goal is to use merkle proofs as a way of returning only some parts of an IPLD object while proving they exist within the IPLD DAG as identified by it’s CID. I suspect that IPFS allows this already or that this behaviour is a part of the IPLD spec, but can’t find any good information anywhere.

1 Like

Sorry for the late reply.

You’d want to store the block directly in IPLD and not in IPFS, then you’d be in the same “resolver space”.

I guess you talk about storing it in the DAG, i.e. IPLD. My answers take that a as basis.

Yes.

The links would already be within your original JSON.

As they are part of your original JSON they are just encoded as part of it.

I hope that sheds a bit of light into all this.