Docs/Protocol Labs Ecosystem Integration
Documentation

Protocol Labs Ecosystem Integration

Bio-DID-Seq leverages the cutting-edge decentralized infrastructure from Protocol Labs to provide a robust, scalable, and future-proof platform for research data management.

Overview

Protocol Labs has built the foundational infrastructure for the decentralized web. Bio-DID-Seq integrates multiple Protocol Labs projects:

TechnologyPurpose in Bio-DID-Seq
IPFSContent-addressed storage for research data
FilecoinLong-term verifiable storage with cryptographic proofs
libp2pPeer-to-peer networking for decentralized communication
IPLDInteroperable data model for linked data structures
UCANUser-controlled authorization for capability-based security
StorachaHot storage layer for fast retrieval
Saturn CDNGlobal content delivery network for IPFS
FVMSmart contracts for programmable storage deals
drandDistributed randomness for cryptographic operations

IPFS Integration

Content-Addressed Storage

Every piece of research data is stored using content addressing:

typescript
interface IPFSContent {
  cid: string;           // Content Identifier (cryptographic hash)
  size: number;          // File size in bytes
  links: IPFSLink[];     // DAG links to other content
  metadata: {
    did: string;         // Associated DID
    timestamp: number;   // Upload timestamp
    version: number;     // Content version
  };
}

async function uploadResearchData(file: Blob, token: string) {
  const body = new FormData();
  body.append('file', file);

  const res = await fetch('https://api.ekayana.com/api/upload', {
    method: 'POST',
    headers: { Authorization: `Bearer ${token}` },
    body,
  });

  const result = await res.json();

  return {
    cid: result.cid,
    gatewayUrl: `https://gateway.ekayana.com/ipfs/${result.cid}`,
  };
}

Uploads are pinned as part of the write, so no separate pin step is required.

Filecoin Integration

Verifiable Long-Term Storage

Filecoin provides cryptographic proofs that your research data is being stored correctly:

typescript
interface FilecoinDeal {
  dealId: string;
  cid: string;
  provider: string;
  startEpoch: number;
  endEpoch: number;
  verified: boolean;
  proofType: 'PoRep' | 'PoSt';
}

async function createStorageDeal(cid: string, duration: number) {
  const deal = await filecoinClient.createDeal({
    cid,
    duration: duration,
    replication: 3,
    verified: true,
    fastRetrieval: true
  });
  
  return deal;
}

Filecoin Virtual Machine (FVM)

Bio-DID-Seq leverages FVM for programmable storage and data DAOs, enabling decentralized governance for research data funding and access control.

libp2p Networking

Peer-to-Peer Communication

libp2p provides the networking layer for Bio-DID-Seq's decentralized architecture:

typescript
import { createLibp2p } from 'libp2p';
import { noise } from '@chainsafe/libp2p-noise';
import { kadDHT } from '@libp2p/kad-dht';
import { gossipsub } from '@chainsafe/libp2p-gossipsub';

const node = await createLibp2p({
  transports: [tcp(), webSockets()],
  connectionEncryption: [noise()],
  services: {
    dht: kadDHT({ clientMode: false }),
    pubsub: gossipsub({ allowPublishToZeroTopicPeers: true })
  }
});

// Subscribe to research data updates
await node.services.pubsub.subscribe('bio-did-seq/updates');

IPLD Data Model

Linked Data Structures

IPLD provides the data model for Bio-DID-Seq's knowledge graphs:

typescript
interface ResearchPaperDAG {
  '@context': string[];
  did: string;
  title: string;
  authors: CID[];        // Links to author DIDs
  content: CID;          // Link to full content
  references: CID[];     // Links to referenced papers
  knowledgeGraph: CID;   // Link to extracted knowledge
}

Storacha (web3.storage) Integration

Hot Storage Layer

Storacha provides the hot storage layer for fast data retrieval:

typescript
import { create } from '@web3-storage/w3up-client';

const client = await create();

async function uploadToStoracha(file: File, metadata: ResearchMetadata) {
  const space = await client.createSpace('research-project');
  await client.setCurrentSpace(space.did());
  
  const cid = await client.uploadFile(file);
  
  return {
    dataCid: cid.toString(),
    space: space.did()
  };
}

Saturn CDN

Global Content Delivery

Saturn provides a Web3 CDN for fast, verifiable content delivery:

typescript
async function retrieveViaSaturn(cid: string) {
  const response = await fetch(`https://strn.pl/ipfs/${cid}`);
  const data = await response.arrayBuffer();
  
  // Verify content hash matches CID
  const verified = await verifyCID(cid, new Uint8Array(data));
  
  return { data, verified };
}

drand Integration

Distributed Randomness

drand provides unbiased, verifiable randomness for cryptographic operations:

typescript
import { HttpChainClient, fetchBeacon } from 'drand-client';

async function getVerifiableRandomness() {
  const chain = new HttpChainClient('https://api.drand.sh');
  const beacon = await fetchBeacon(chain);
  
  return {
    round: beacon.round,
    randomness: beacon.randomness,
    signature: beacon.signature
  };
}

// Use for fair reviewer selection
async function selectReviewers(candidates: string[], numReviewers: number) {
  const beacon = await getVerifiableRandomness();
  const shuffled = deterministicShuffle(candidates, beacon.randomness);
  return shuffled.slice(0, numReviewers);
}

Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐
│                    Bio-DID-Seq Platform                         │
├─────────────────────────────────────────────────────────────────┤
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐         │
│  │ BioAgents│  │ Knowledge│  │   DID    │  │   UCAN   │         │
│  │  (AI/ML) │  │   Graph  │  │Management│  │   Auth   │         │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └────┬─────┘         │
│       └─────────────┴─────────────┴─────────────┘               │
│                          │                                      │
│  ┌───────────────────────┴────────────────────────────────────┐ │
│  │                Protocol Labs Stack                         │ │
│  │  ┌─────┐ ┌────────┐ ┌──────┐ ┌────┐ ┌────┐ ┌──────┐ ┌─────┐│ │
│  │  │IPFS │ │Filecoin│ │libp2p│ │IPLD│ │UCAN│ │Saturn│ │drand││ │
│  │  └─────┘ └────────┘ └──────┘ └────┘ └────┘ └──────┘ └─────┘│ │
│  └────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘

Resources