IPFS Primer
ipfs.ioIPFS Docs
  • Introduction
  • Tutorial: Install and Initialize IPFS
    • Lesson: Download and Install IPFS
    • Lesson: Initialize your IPFS Repository
  • Tutorial: Files on IPFS
    • Lesson: Add Content to IPFS and Retrieve It
    • Lesson: Wrap Filenames and Directory Info around Content
    • Lesson: Pinning - Tell IPFS to Keep a File
  • Tutorial: Going Online - Joining the Distributed Web
    • Lesson: Connect your node to the IPFS network
    • Lesson: Find Peers on the Network
    • Lesson: Retrieve content from a Peer
  • Tutorial: Interacting with the Classical (HTTP) Web
    • Lesson: Use an HTTP browser to retrieve files from local IPFS gateway
    • Lesson: Get content through the public ipfs.io gateway
    • Lesson: Access IPFS content through any IPFS gateway
  • Tutorial: The Myriad ways to Access and Distribute IPFS Content
    • The Power of Content-addressing
    • Retrieving content from a peer
    • Review these lessons from the Tutorial on Interacting with the Classical (HTTP) Web
      • Review: Using an HTTP browser to retrieve files from local IPFS gateway
      • Review: Using the public IPFS gateways at ipfs.io
      • Review: Access IPFS content through any IPFS gateway
    • Lesson: Access IPFS content through Tor gateways (experimental)
    • Lesson: Run IPFS over Tor transport (experimental)
    • Lesson: Access IPFS content through a browser extension
    • Lesson: Sneakernets - moving the data on USB Drives and other Hardware
  • Tutorial: Making Changes on the Permanent Web
    • Lesson: Create a Simple Webpage and Add It to IPFS
    • Lesson: View Your Webpage with IPFS and Publish to IPNS
    • Lesson: Modify Your Webpage and Republish to IPNS
    • Lesson: Generate and Use a New IPNS Name Keypair
  • Tutorial: Merkle Trees and the IPFS DAG
    • Lesson: Turn a File into a Tree of Hashes
    • Lesson: The Cryptographic Hash
    • Lesson: Build a Tree of Data in IPFS Using Cryptographic Hashes to Link the Pieces (a Merkle DAG)
    • Lesson: Explore the types of software that use hash trees to track data (to come)
  • Tutorial: Dynamic Content on IPFS
    • Disclaimer: Dynamic content on IPFS is a Work in Progress (to come)
    • Lesson: Add data to the DAG (locally) (to come)
    • Lesson: Tell peers about your Changes (to come)
    • Lesson: Use hashes to get someone's changes from IPFS (to come)
    • Lesson: Use a pub/sub strategy to pass around messages about changes (to come)
    • Lesson: Resolve conflicts with a merge strategy (CRDTs) (to come)
  • Privacy and Access Controls on the Distributed Web (to come)
    • Reader Privacy & Writer Privacy (to come)
    • Private Networks (to come)
    • Encrypting Content (to come)
    • More dynamic encryption: capabilities-based encryption (to come)
    • Comparing with the classic HTTP web (feudal security, etc) (to come)
  • Keeping Data Alive: Durable Data on the Permanent Web (to come)
    • IPFS Cluster (to come)
    • Filecoin (to come)
  • Distributed Computation (to come)
Powered by GitBook
On this page
  • Lesson: Creating a Merkle Tree from Scratch
  • Goals
  • Explanation: Blocks vs Objects
  • Steps
  • Step 1
  • Step 2

Was this helpful?

Export as PDF
  1. Tutorial: Merkle Trees and the IPFS DAG

Lesson: Build a Tree of Data in IPFS Using Cryptographic Hashes to Link the Pieces (a Merkle DAG)

PreviousLesson: The Cryptographic HashNextLesson: Explore the types of software that use hash trees to track data (to come)

Last updated 5 years ago

Was this helpful?

Lesson: Creating a Merkle Tree from Scratch

Work in Progress This is the content from vaguely re-framed to fit the Lesson framework.

Goals

  • Build a tree of data in IPFS using cryptographic hashes to link the pieces (a Merkle DAG)

Explanation: Blocks vs Objects

In ipfs, a block refers to a single unit of data, identified by its key (hash). a block can be any sort of data, and does not necessarily have any sort of format associated with it. an object, on the other hand, refers to a block that follows the merkledag protobuf data format. it can be parsed and manipulated via the ipfs object command. any given hash may represent an object or a block.

Steps

Step 1

Creating your own blocks is easy! simply put your data in a file and run ipfs block put <yourfile> on it, or you can pipe your filedata into ipfs block put, like so:

Step 2

$ echo "This is some data" | ipfs block put
QmfQ5QAjvg4GtA3wg3adpnDJug8ktA1BxurVqBD8rtgVjM
$ ipfs block get QmfQ5QAjvg4GtA3wg3adpnDJug8ktA1BxurVqBD8rtgVjM
This is some data

Note: When making your own block data, you wont be able to read the data with ipfs cat, this is because you are inputting raw data without the unixfs data format. To read raw blocks use ipfs block get as shown in the example.

this existing Lesson