Lighthouse
  • 👋Introduction
  • Quick Start
  • How To
    • 🔑Create an API Key
    • 🔼Upload Data
      • 📁File
      • 🔤Text/JSON
      • 🔀Buffer
    • 🔒Upload Encrypted Data
      • 📁File
      • 🔤Text/JSON
      • 🔐Encryption Authentication
        • 📝Method 1: Signed Message
        • ⚕️Method 2: JWT
        • 📲Method 3: Passkey
    • Encryption Features
      • 👯Share File
      • ❌Revoke Access
      • 🔑Check Access Conditions
      • 🚪Token Gating
      • Chains Supported
      • 📃Access Control Conditions
      • 🔓Decrypt File
        • 🌐Browser Decrypt File
        • 💻NodeJS Decrypt File
      • 🚪Access control with zkTLS
      • 👬Account Delegation Tutorial
    • 📂List Files
    • 💁File Info
    • 💰Get Balance
    • 🔁Retrieve File
    • 💾Check for Filecoin Deals
    • 🔄IPNS - Handle Mutable Data
    • 📦Migrate Files
    • 📌Pin CID
    • 💸Pay per use
    • Resize Image
    • 💻Use CLI Tools
  • zkTLS
  • 🤝Account Delegation
  • 💾Filecoin First
    • Usage
    • 💰Pay Per Deal
  • Tutorials
    • 💸Pay to View Application
    • Use Python SDK
    • 📝Update Content with Lighthouse IPNS
    • 📹Add Video Player in UI
    • ✅Document Verification with PoDSI
    • 🎨Minting NFTs on EVM Chains
    • 🪙Minting NFTs on Solana
    • 👩‍💻Programmable Storage with Lighthouse SDK and Filecoin
    • 🔐Secure File Sharing
    • Upload Encrypted Files
    • 📄Token Gating and Custom Contract
    • 🔑Token Gating NFTs
    • 🏖️Pushing File Metadata Onchain
    • Use Radix Wallet on Lighthouse Filesdapp
  • Concepts
    • Glossary
    • IPFS CID Transition to v1
  • Support
    • 📞Contact
Powered by GitBook
On this page
  • Overview
  • Introduction to Lighthouse
  • Key Concepts
  • Step-by-Step Implementation
  • Conclusion

Was this helpful?

Edit on GitHub
  1. Tutorials

Document Verification with PoDSI

Seal It with PoDSI: Verifying Document Authenticity on Lighthouse SDK

PreviousAdd Video Player in UINextMinting NFTs on EVM Chains

Last updated 1 year ago

Was this helpful?

Overview

This comprehensive guide will walk you through the steps to implement a Document Verification System using the Lighthouse SDK. This application allows users to upload important documents, which are then timestamped and stored immutably on the Filecoin network for verification purposes.

Prerequisites

  • Basic understanding of JavaScript and Node.js

  • Node.js and NPM: If not already installed, you can download and install them from .

  • Lighthouse CLI: Installed globally on your machine. Install it via npm using the command:

    npm install -g @lighthouse-web3/sdk

  • API Key: Generate it using Lighthouse CLI or refer to the official for more methods.

Introduction to Lighthouse

Lighthouse is a perpetual file storage protocol designed to merge the robust storage capabilities of IPFS and Filecoin with the adaptability of various blockchain networks. By enabling users to pay a one-time fee for long-term storage, it presents a cost-effective alternative to the recurring expenses tied to conventional cloud storage, striving to deliver a secure and decentralized storage solution.

Key Concepts

IPFS (InterPlanetary File System)

IPFS is a protocol designed to make the web faster, safer, and more open by replacing the traditional, location-based address system with content-based addressing. This means files and content are addressed by what they contain, not where they are located, ensuring decentralization and security.

Filecoin

Filecoin is a decentralized storage network that turns cloud storage into an algorithmic market. It facilitates the trading of excess storage space, allowing users to rent their extra space out, creating a decentralized market for data storage and retrieval.

PoDSI (Proof of Data Segment Inclusion)

PoDSI is a proof mechanism that confirms a specific piece of data is included and stored within the Filecoin network. It acts as a certificate of authenticity, verifying the existence, integrity, and timestamp of stored files.

Step-by-Step Implementation

  1. Select any of the login method and perform verification steps

  1. Click on API Key on the left side panel on the dashboard.

  1. Insert name for your API

  1. Copy the API Key


Step 1: Upload a Document

Use the Lighthouse SDK to upload a document to the Filecoin network.

import lighthouse from "@lighthouse-web3/sdk";

async function uploadDocument() {
    const filePath = '/path/to/your/document.pdf';
    const apiKey = 'YOUR_API_KEY';

    const uploadResponse = await lighthouse.upload(filePath, apiKey);
    console.log('File Uploaded, CID:', uploadResponse.cid);
}

uploadDocument().catch(console.error);

Step 2: Retrieve PoDSI (Proof of Data Segment Inclusion)

PoDSI certifies the existence and integrity of the document on the Filecoin network at a specific time.

import axios from "axios";

async function getPoDSI(cid) {
    const response = await axios.get(`https://api.lighthouse.storage/api/lighthouse/get_proof?cid=${cid}`);
    console.log('PoDSI:', response.data);
}

const cid = 'Qm...';  // Replace with the actual CID of your file
getPoDSI(cid).catch(console.error);

Step 3: Verify the Document

Verify the document's authenticity using its PoDSI.

function verifyDocument(poDSI) {
    const { pieceCID, dealInfo } = poDSI;

    if (!pieceCID || !dealInfo || dealInfo.length === 0 || !dealInfo.every(deal => deal.dealId && deal.storageProvider)) {
        console.error('Verification Failed');
        return false;
    }

    console.log('Document Verified:', pieceCID);
    return true;
}

getPoDSI(cid).then(verifyDocument).catch(console.error);

Step 4: Download the Document (Optional)

Enable document retrieval using the document's CID.

async function downloadDocument(cid) {
    const response = await axios({
        method: 'GET',
        url: `https://gateway.lighthouse.storage/ipfs/${cid}`,
        responseType: 'stream',
    });

    // Implement logic to save the file stream to a local file
}

downloadDocument(cid).catch(console.error);

Conclusion

Well done! You've successfully implemented a system to verify document uploads using PoDSI and the Lighthouse SDK on the Filecoin network. This base setup can be tailored to accommodate specific needs or integrated with additional features. Dive deeper and continue enhancing your application's functionality!

Step 0: Getting your lighthouse API key :

Go on and Click on Login

✅
here
documentation
Files-Lighthouse-storage
https://files.lighthouse.storage/