Skip to content

Latest commit

 

History

History
216 lines (177 loc) · 6.3 KB

File metadata and controls

216 lines (177 loc) · 6.3 KB

N42 Public Chain Social Interface Technical Documentation

1. Overview

The N42 public chain provides a decentralized, efficient, and secure social protocol that supports social identity authentication, friend management, messaging, content sharing, and decentralized governance.
Powered by Decentralized Identity (DID), Zero-Knowledge Proofs (ZKP), and Smart Contracts, N42 enables a permissionless decentralized social network where users retain full control over their data, ensuring high privacy protection and strong interoperability.


2. Core Architecture

The N42 social system consists of the following key components:

  • Decentralized Identity (DID): A unique blockchain-based identity protocol that ensures user-controlled data sovereignty.
  • Social Graph: A smart contract-based relationship storage system supporting friends, followers, and groups.
  • Decentralized Messaging (P2P Messaging): End-to-end encrypted communications for text, images, videos, and on-chain transactions.
  • Content Sharing: Blockchain/IPFS-based content publication and management.
  • Reputation & Incentive Mechanism: On-chain reputation tracking to reward high-quality content creators.
  • DAO-Based Governance: Community-driven voting for content moderation, social governance, and decision-making.

3. Social API Design

3.1 API Endpoints

N42 provides REST and WebSocket-based social APIs for DApp integration.

Endpoint Method Description
/api/v1/social/did/create POST Create a Decentralized Identity (DID)
/api/v1/social/profile/update POST Update user social profile
/api/v1/social/friends/add POST Add a friend
/api/v1/social/friends/list GET Retrieve the friend list
/api/v1/social/messages/send POST Send a social message
/api/v1/social/messages/fetch GET Fetch messages
/api/v1/social/content/post POST Publish content
/api/v1/social/content/feed GET Retrieve content feed
/api/v1/social/reputation/query GET Query user reputation score
/api/v1/social/dao/vote POST Participate in community governance voting

4. API Details

4.1 Create a Decentralized Identity (DID)

Request Example

POST /api/v1/social/did/create
Content-Type: application/json

{
  "public_key": "0xA1B2C3D4E5F6...",
  "metadata": {
    "username": "Alice",
    "bio": "Web3 enthusiast",
    "avatar": "https://ipfs.io/ipfs/Qm..."
  }
}

Response Example

{
  "did": "did:n42:0x123456789ABCDEF...",
  "status": "created",
  "timestamp": 1710582937
}

4.2 Update User Social Profile

Request Example

POST /api/v1/social/profile/update
Content-Type: application/json

{
  "did": "did:n42:0x123456789ABCDEF...",
  "bio": "Decentralization advocate",
  "avatar": "https://ipfs.io/ipfs/Qm...",
  "website": "https://alice.me"
}

Response Example

{
  "status": "updated",
  "timestamp": 1710583001
}

4.3 Add a Friend

Request Example

POST /api/v1/social/friends/add
Content-Type: application/json

{
  "did": "did:n42:0x123456789ABCDEF...",
  "friend_did": "did:n42:0xF6E5D4C3B2A1...",
  "signature": "MEUCIQD...q9yz+Xf=="
}

Response Example

{
  "status": "pending",
  "friendship_id": "0xABCDE12345",
  "timestamp": 1710583056
}

4.4 Retrieve Friend List

Request Example

GET /api/v1/social/friends/list?did=did:n42:0x123456789ABCDEF...

Response Example

{
  "friends": [
    {
      "did": "did:n42:0xF6E5D4C3B2A1...",
      "username": "Bob",
      "status": "confirmed"
    }
  ]
}

4.5 Send a Social Message

Request Example

POST /api/v1/social/messages/send
Content-Type: application/json

{
  "sender_did": "did:n42:0x123456789ABCDEF...",
  "recipient_did": "did:n42:0xF6E5D4C3B2A1...",
  "message": "Hello, welcome to Web3!",
  "timestamp": 1710583100,
  "signature": "MEUCIQD...q9yz+Xf=="
}

Response Example

{
  "message_id": "0xMSG123456789",
  "status": "sent"
}

4.6 Fetch Messages

Request Example

GET /api/v1/social/messages/fetch?did=did:n42:0x123456789ABCDEF...

Response Example

{
  "messages": [
    {
      "sender_did": "did:n42:0xF6E5D4C3B2A1...",
      "content": "Hello, welcome to Web3!",
      "timestamp": 1710583100
    }
  ]
}

5. Security Design

5.1 End-to-End Encryption

  • Public-Private Key Encryption: Messages use ECDH key exchange + AES encryption to ensure privacy.
  • Decentralized Storage: Content is stored on IPFS or Arweave to prevent data loss.

5.2 Spam Protection

  • Staking Mechanism: Users must stake N42 tokens to send messages, discouraging spam.
  • Social Reputation System: Low-reputation users' messages may be automatically filtered.

5.3 Access Control

  • OAuth2 Authentication: All API requests require an Authorization token.
  • Whitelist Management: Restrict API access to trusted users.

6. Best Practices

6.1 Efficient Social Graph Management

  • Use Decentralized Social Graphs to reduce on-chain storage costs.
  • Leverage Off-Chain Indexing (zk-Rollup) for faster queries.

6.2 Prevent Social Network Abuse

  • Reputation Scores to limit malicious actors.
  • DAO Governance for community-driven moderation.

7. Future Enhancements

  • Decentralized AI-Powered Recommendations: Improve content discovery based on on-chain reputation and social interactions.
  • Smart Contract-Based DAO Governance: Enable community-driven content moderation and algorithm adjustments.

8. Conclusion

The N42 social interface provides a complete decentralized social networking solution, supporting identity authentication, friend management, messaging, content publishing, and social governance.
By integrating smart contracts, DID, and zero-knowledge proofs, N42 empowers users to socialize freely without intermediaries, ensuring data sovereignty and privacy protection in the Web3 era.