How rafidhaque/blockchain-and-middleman-ipfs-based-solution-for-repository-hosting works
Project Type and Purpose
• This is a decentralized full-stack application (“dApp”) for secure, encrypted source-code hosting.
• It uses a browser‐based client, an Ethereum smart contract (VersionControl.sol), IPFS for storage, and a Node.js “middleman” server for optimistic key-share retrieval.
File Structure
• Top level:
• Client dApp files: index.html, style.css, app.js, libs/ (crypto-js, ethers.js, ipfs-http-client.js, secrets.js)
• Benchmark script (benchmark.ps1)
• Graphs folder (likely contains figures or data for the manuscript)
• Smart contract code (VersionControl.sol referenced in README but not shown in file tree)
• middleman-server/: Node.js/Express code (server.js, package.json) deployed serverlessly.
• Configuration: .gitignore, .gitattributes.
Key Insights from the README
• Three main components:
a) Client-side dApp (all crypto, SSS, AES-256 done in the browser)
b) Smart contract on Ethereum Sepolia
c) Middleman server for optimistic retrieval
• Data flows: encryption → IPFS upload → key splitting → one share on‐chain + remaining shares via middleman.
a. Client dApp
• Browser UI (index.html + style.css)
• JavaScript modules: app.js orchestrates operations, libs/crypto-js for AES, libs/secrets.js for Shamir’s Secret Sharing, libs/ethers.js for blockchain calls, libs/ipfs-http-client.js for IPFS interactions.
b. Ethereum Blockchain
• VersionControl.sol contract (on Sepolia testnet)
• Ethereum node or Infura/Alchemy endpoint
c. IPFS Network
• Public IPFS gateway or custom node for storing encrypted repo snapshots
d. Middleman Server
• Node.js/Express “fast path” cache (server.js) deployed as serverless (e.g., Vercel)
Relationships and Interactions
1) User triggers “push” in dApp →
• Encrypts code (AES-256) → splits key into N shares (SSS).
• Uploads encrypted repo to IPFS → receives CID.
• Sends one key‐share + metadata to blockchain via ethers.js → transaction pending.
• Sends remaining key‐shares to middleman server via REST API.
2) Collaborator “pull” in dApp →
• Tries optimistic retrieval: GET share from middleman → if available, reconstruct key early.
• Otherwise, waits for on‐chain event confirming share → fetches from blockchain logs.
• Fetches encrypted content from IPFS → decrypts in browser.
Architectural Patterns & Principles
• Decentralized storage & ledger
• Client-side end-to-end encryption
• Shamir’s Secret Sharing to minimize trust
• Optimistic‐first fallback to on‐chain for high performance
• Serverless middleware as cache (microservice pattern)
Essential Elements
• Clear, self-explanatory labels for every node.
• External dependencies (Ethereum node provider, public IPFS).