Skip to content

Demonstrating how to do verified retrieval in the browser by fetching a CAR file from an IPFS HTTP gateway

Notifications You must be signed in to change notification settings

lidel/verified-ipfs-retrieval

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verified IPFS retrieval in the browser

Demonstrating how to do verified (aka trustless) retrieval in the browser by fetching a CAR file from an IPFS HTTP gateway.

Note that verified and trustless are used in this context synonymously.

Why?

When fetching a CID from a gateway, you are typically trusting the gateway to return you the correct response.

To eliminate the need to trust gateways, you can ask for a CAR response which allows you to verify that the input CID you request matches the CID of the response.

What's a CAR file?

The CAR file format (Content Addressable aRchives) is binary serialisation of content addressed data (like UnixFS files and IPLD blocks). Typically these are stored in a file with the .car extension

CAR files are useful for several reasons:

  • Allow moving content addressed data using any transport, e.g. HTTP in the case of trustless gateways
  • Ensure that the CID is the consistent for the same input data. If you may remember, when files are added to IPFS, choosing different paramters will yield a different CID.

car file

How it works

Using trustless gateways, a CAR file for the CID is requested with the Fetch API.

The response stream is piped into a CarReader, which traverses the DAG and constructs the file from the binary chucks. While the DAG is constructed, the blocks are verified by calculating a hash for each block and comparing it against the block.

View the code specific to verified retrieval

About

Demonstrating how to do verified retrieval in the browser by fetching a CAR file from an IPFS HTTP gateway

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 63.3%
  • CSS 29.0%
  • JavaScript 7.3%
  • Shell 0.4%