API Reference

Comprehensive API documentation for Ensanoth's identity, storage, and peer-to-peer communication modules.

Overview

Core Concepts

Ensanoth's API provides self-sovereign identity management, blockchain-based storage, and encrypted peer-to-peer communication through WebRTC/IPFS.

npm install @ensaonoth/core

Key Components

Identity API

Create, verify, and manage decentralized identifiers (DIDs) across Ethereum, Polygon, and IPFS.

// Create identity
ensanoth.identity.create(network='ethereum');

// Verify claims
ensanoth.identity.verify(did, claimType);

Storage API

Store encrypted files using SHA-3 hashing and erasure coding across IPFS and blockchain storage.

// Store file
ensanoth.storage.upload('file.txt', { encryption: true });

// Retrieve data
ensanoth.storage.get(hash);

Peer API

Establish encrypted peer-to-peer connections using WebRTC with fallback to IPFS relays.

// Connect to peer
ensanoth.peer.connect('FRIEND_DID');

// Send message
ensanoth.peer.send('FRIEND_DID', { message: 'Hello' });

API Endpoints

IDENTITY

POST /api/identity/create

Request Body
{
  "network": "ethereum",
  "type": "Ed25519VerificationKey2018"
}
Response
{
  "did": "did:ethr:0x1234...",
  "publicKey": "AaBbCcDd...",
  "createdAt": "2025-09-23T12:00:00Z"
}

STORAGE

GET /api/storage/retrieve/{hash}

Path Parameters
{
  "hash": "bafyrytaj27f5qz54x..."
}
Response
{
  "content": "base64EncodedData",
  "metadata": {
    "author": "did:ethr:0x4567...",
    "size": "4096",
    "createdAt": "2025-09-23T12:00:00Z"
  }
}

PEER COMMUNICATION

POST /api/peer/send

Request Body
{
  "to": "did:ethr:007890...",
  "content": "Hello from Alice",
  "encrypt": true
}
Response
{
  "status": "delivered",
  "timestamp": "2025-09-23T12:05:00Z",
  "networkUsed": "WebRTC"
}