王森涛
发布于 2026-08-03 / 0 阅读
0
0

去中心化身份与创作者信用:DID协议如何重塑数字声誉

去中心化身份与创作者信用:DID协议如何重塑数字声誉

2026年,去中心化身份(DID)协议正在"重塑"数字世界的"信用"体系。从"创作者"到"消费者",从"声誉"到"信用",DID协议"允许"用户"掌控"自己的"数字身份",而"不依赖"中心化的"平台"。这是"数字身份"的"去中心化"革命——从"平台拥有"到"用户拥有",从"中心化验证"到"去中心化信任"。

第一幕:DID的"身份"叙事

第一场:从"平台身份"到"自主身份"——"身份"的"演进"

数字身份的"演进":

  1. Web1(静态身份):用户名和密码——"简单"但"不安全"。
  2. Web2(平台身份):Google登录、Facebook登录——"方便"但"中心化"。
  3. Web3(自主身份):DID、VC(可验证凭证)——"去中心化"、"用户掌控"。

第二场:DID的"核心"架构

DID的"核心"组件:

  1. DID(去中心化标识符):一个"全球唯一"的"标识符"——"did:example:1234567890"。
  2. DID Document:一个"描述"DID的"文档"——"公钥"、"服务端点"、"验证方法"。
  3. Verifiable Credential(可验证凭证):一个"可验证"的"数字"声明——"学历"、"年龄"、"信用"。
  4. Verifiable Presentation:一个"可验证"的"展示"——"选择"展示"部分"信息。

第三场:从"DID"到"创作者信用"——"声誉"的"Token化"

创作者信用(Creator Credit)是DID的"垂直"应用:

  1. 内容创作:创作者"发布"内容——"博客"、"视频"、"音乐"、"NFT"。
  2. 声誉积累:创作者"积累"声誉——"点赞"、"评论"、"分享"、"收入"。
  3. 信用评分:DID"聚合"声誉数据——"生成"创作者"信用"评分。
  4. 信用应用:创作者"使用"信用——"借贷"、"众筹"、"合作"、"投资"。

DID identity

第二幕:DID的"技术"深度

第一场:从"DID"到"VC"——"可验证凭证"的"标准"

可验证凭证的"标准"(W3C Verifiable Credentials):

  1. 发行者(Issuer):"签发"凭证的"实体"——"学校"、"政府"、"公司"。
  2. 持有者(Holder):"持有"凭证的"用户"——"学生"、"公民"、"员工"。
  3. 验证者(Verifier):"验证"凭证的"实体"——"平台"、"服务"、"协议"。
  4. 凭证(Credential):一个"可验证"的"声明"——"毕业证书"、"驾照"、"信用报告"。

第二场:从"VC"到"VP"——"可验证展示"的"隐私"

可验证展示(Verifiable Presentation)的"隐私"特性:

  1. 选择性展示:用户"选择"展示"凭证"的"部分"信息——"只"展示"年龄"而不"展示"出生日期"。
  2. 零知识证明:用户"证明"凭证的"真实性"而"不揭示"凭证的"内容"。
  3. 撤销检测:验证者"检查"凭证是否"被撤销"——"链上"或"链下"。

第三场:从"DID"到"链上信誉"——"On-chain Reputation"的"数据"模型

链上信誉的"数据"模型:

  1. 链上数据:用户的"交易"、"资产"、"互动"——"链上"的"行为"数据。
  2. 链下数据:用户的"社交"、"信用"、"教育"——"链下"的"身份"数据。
  3. 聚合模型:DID"聚合"链上和链下数据——"生成"统一的"信誉"评分。
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract CreatorDID is AccessControl, ReentrancyGuard {
    bytes32 public constant ISSUER_ROLE = keccak256("ISSUER_ROLE");
    bytes32 public constant VERIFIER_ROLE = keccak256("VERIFIER_ROLE");

    enum CredentialType {
        EDUCATION, EMPLOYMENT, SKILL, REPUTATION, FINANCIAL, CREATOR
    }

    enum CredentialStatus {
        ISSUED, ACTIVE, REVOKED, EXPIRED, SUSPENDED
    }

    struct DID {
        address owner;
        string didURI;
        bytes32 publicKeyHash;
        uint256 createdAt;
        uint256 lastUpdated;
        uint256 reputationScore;
        bool isActive;
    }

    struct VerifiableCredential {
        bytes32 credentialHash;
        address issuer;
        address holder;
        CredentialType credType;
        string schemaURI;
        uint256 issuedAt;
        uint256 expiresAt;
        CredentialStatus status;
        bytes proof;
    }

    struct ReputationRecord {
        address creator;
        uint256 totalContent;
        uint256 totalViews;
        uint256 totalEngagement;
        uint256 totalRevenue;
        uint256 credibilityScore;
        uint256 lastUpdated;
    }

    mapping(address => DID) public dids;
    mapping(bytes32 => VerifiableCredential) public credentials;
    mapping(address => ReputationRecord) public reputation;
    mapping(address => uint256) public credentialCount;

    uint256 public totalDIDs;
    uint256 public totalCredentials;

    event DIDCreated(address indexed owner, string didURI);
    event CredentialIssued(bytes32 indexed credentialHash, address indexed holder);
    event CredentialRevoked(bytes32 indexed credentialHash);
    event ReputationUpdated(address indexed creator, uint256 score);

    function createDID(string memory _didURI) external returns (address) {
        require(dids[msg.sender].owner == address(0), "DID already exists");
        totalDIDs++;

        dids[msg.sender] = DID({
            owner: msg.sender,
            didURI: _didURI,
            publicKeyHash: keccak256(abi.encodePacked(msg.sender)),
            createdAt: block.timestamp,
            lastUpdated: block.timestamp,
            reputationScore: 0,
            isActive: true
        });

        emit DIDCreated(msg.sender, _didURI);
        return msg.sender;
    }

    function issueCredential(
        address _holder,
        CredentialType _credType,
        string memory _schemaURI,
        uint256 _expiresAt,
        bytes calldata _proof
    ) external onlyRole(ISSUER_ROLE) returns (bytes32) {
        require(dids[_holder].isActive, "Holder DID not active");
        totalCredentials++;

        bytes32 credentialHash = keccak256(abi.encodePacked(
            msg.sender, _holder, _credType, block.timestamp
        ));

        credentials[credentialHash] = VerifiableCredential({
            credentialHash: credentialHash,
            issuer: msg.sender,
            holder: _holder,
            credType: _credType,
            schemaURI: _schemaURI,
            issuedAt: block.timestamp,
            expiresAt: _expiresAt,
            status: CredentialStatus.ACTIVE,
            proof: _proof
        });

        credentialCount[_holder]++;
        emit CredentialIssued(credentialHash, _holder);
        return credentialHash;
    }

    function revokeCredential(bytes32 _credentialHash) external onlyRole(ISSUER_ROLE) {
        VerifiableCredential storage cred = credentials[_credentialHash];
        require(cred.issuer == msg.sender, "Not the issuer");
        cred.status = CredentialStatus.REVOKED;
        emit CredentialRevoked(_credentialHash);
    }

    function updateReputation(
        address _creator,
        uint256 _totalContent,
        uint256 _totalViews,
        uint256 _totalEngagement,
        uint256 _totalRevenue
    ) external {
        ReputationRecord storage record = reputation[_creator];
        record.totalContent = _totalContent;
        record.totalViews = _totalViews;
        record.totalEngagement = _totalEngagement;
        record.totalRevenue = _totalRevenue;

        record.credibilityScore = calculateCredibility(_creator);
        record.lastUpdated = block.timestamp;

        emit ReputationUpdated(_creator, record.credibilityScore);
    }

    function calculateCredibility(address _creator) internal view returns (uint256) {
        ReputationRecord storage record = reputation[_creator];
        if (record.totalContent == 0) return 0;

        uint256 engagementRate = (record.totalEngagement * 10000) / record.totalViews;
        uint256 revenuePerContent = (record.totalRevenue * 10000) / record.totalContent;
        uint256 credentialBonus = credentialCount[_creator] * 100;

        return (engagementRate * 40 + revenuePerContent * 30 + credentialBonus * 30) / 100;
    }

    function verifyCredential(bytes32 _credentialHash) external view returns (bool) {
        VerifiableCredential storage cred = credentials[_credentialHash];
        return cred.status == CredentialStatus.ACTIVE && block.timestamp < cred.expiresAt;
    }
}

第三幕:DID的"应用"场景

第一场:从"创作者"到"DID创作者"——"内容"的"身份"

DID在"内容创作"中的"应用":

  1. 内容签名:创作者使用"DID"签名"内容"——"验证"内容的"真实性"和"完整性"。
  2. 内容溯源:DID"追踪"内容的"来源"——"谁"创建了"什么"内容。
  3. 内容版权:DID"关联"内容的"版权"——"NFT"、"许可证"、"收入"分配。

第二场:从"DID"到"创作者DAO"——"去中心化"的"创作者"组织

创作者DAO(Creator DAO)是DID的"组织"应用:

  1. 成员身份:DID"标识"DAO的"成员"——"谁"可以"参与"治理。
  2. 声誉投票:DID"关联"成员的"声誉"——"投票"权重"基于"声誉。
  3. 信用借贷:DID"关联"成员的"信用"——"借贷"协议"信任"高信用的"创作者"。

第三场:从"DID"到"跨链DID"——"互操作"的"身份"

跨链DID(Cross-chain DID)的"挑战"和"方案":

  1. 挑战:不同"链"的"身份"系统"不兼容"——"Ethereum"、"Solana"、"Polygon"。
  2. 方案:使用"IBC"(跨链通信)或"LayerZero"实现"跨链"DID"互操作"。
  3. 标准:W3C DID标准"支持"跨链DID——"did:ethr"、"did:sol"、"did:polygon"。
import json
import hashlib
from typing import Dict, List, Optional, Any
from dataclasses import dataclass
from datetime import datetime
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.backends import default_backend

@dataclass
class DIDDocument:
    id: str
    public_key: Dict[str, Any]
    authentication: List[Dict]
    service: List[Dict]
    created: str
    updated: str

class CreatorDIDManager:
    def __init__(self):
        self.did_registry: Dict[str, DIDDocument] = {}
        self.credentials: Dict[str, Dict] = {}
        self.reputation: Dict[str, Dict] = {}
        self.private_key = rsa.generate_private_key(
            public_exponent=65537,
            key_size=2048,
            backend=default_backend()
        )
        self.public_key = self.private_key.public_key()

    def create_did(self, owner: str) -> DIDDocument:
        did_id = f"did:creator:{hashlib.sha256(owner.encode()).hexdigest()[:16]}"
        pub_key_bytes = self.public_key.public_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PublicFormat.SubjectPublicKeyInfo
        )

        doc = DIDDocument(
            id=did_id,
            public_key={
                'id': f"{did_id}#keys-1",
                'type': 'RsaVerificationKey2018',
                'controller': did_id,
                'publicKeyPem': pub_key_bytes.decode()
            },
            authentication=[{
                'id': f"{did_id}#keys-1",
                'type': 'RsaSignatureAuthentication2018',
                'publicKey': f"{did_id}#keys-1"
            }],
            service=[{
                'id': f"{did_id}#creator-service",
                'type': 'CreatorService',
                'serviceEndpoint': 'https://api.bcu.lat/creator'
            }],
            created=datetime.now().isoformat(),
            updated=datetime.now().isoformat()
        )

        self.did_registry[did_id] = doc
        self.reputation[owner] = {
            'did': did_id,
            'score': 0,
            'content_count': 0,
            'total_views': 0,
            'total_revenue': 0,
            'last_updated': datetime.now().isoformat()
        }
        return doc

    def issue_verifiable_credential(self, holder_did: str, cred_type: str, claims: Dict) -> Dict:
        credential = {
            '@context': ['https://www.w3.org/2018/credentials/v1'],
            'type': ['VerifiableCredential', cred_type],
            'issuer': self.did_registry.get(holder_did, {}).id,
            'issuanceDate': datetime.now().isoformat(),
            'credentialSubject': {
                'id': holder_did,
                **claims
            },
            'proof': {
                'type': 'RsaSignature2018',
                'created': datetime.now().isoformat(),
                'proofPurpose': 'assertionMethod',
                'verificationMethod': f"{holder_did}#keys-1"
            }
        }

        cred_hash = hashlib.sha256(json.dumps(credential, sort_keys=True).encode()).hexdigest()
        self.credentials[cred_hash] = credential
        return credential

    def calculate_reputation_score(self, creator: str) -> Dict:
        rep = self.reputation.get(creator, {})
        if not rep or rep['content_count'] == 0:
            return {'score': 0, 'factors': {}}

        engagement_rate = rep.get('total_views', 0) / rep['content_count'] if rep['content_count'] > 0 else 0
        revenue_per_content = rep.get('total_revenue', 0) / rep['content_count'] if rep['content_count'] > 0 else 0

        score = (
            min(engagement_rate * 10, 40) +
            min(revenue_per_content * 5, 30) +
            min(rep['content_count'] * 2, 30)
        )

        return {
            'score': min(score, 100),
            'factors': {
                'engagement_rate': engagement_rate,
                'revenue_per_content': revenue_per_content,
                'content_count': rep['content_count']
            }
        }

    def update_creator_stats(self, creator: str, views: int = 0, revenue: int = 0):
        if creator not in self.reputation:
            return
        rep = self.reputation[creator]
        rep['content_count'] += 1
        rep['total_views'] += views
        rep['total_revenue'] += revenue
        rep['last_updated'] = datetime.now().isoformat()
        rep['score'] = self.calculate_reputation_score(creator)['score']

    def verify_credential(self, credential_hash: str) -> bool:
        return credential_hash in self.credentials

    def get_did_document(self, did_id: str) -> Optional[DIDDocument]:
        return self.did_registry.get(did_id)

manager = CreatorDIDManager()
did = manager.create_did('0xCreator123')
print(f"Created DID: {did.id}")
manager.update_creator_stats('0xCreator123', views=10000, revenue=500)
score = manager.calculate_reputation_score('0xCreator123')
print(f"Reputation score: {score['score']}")

Creator credit

第四幕:DID的"挑战"与"未来"

第一场:从"隐私"到"主权"——"DID"的"隐私"挑战

DID的"隐私"挑战:

  1. 数据泄露:DID"聚合"用户的数据——"中心化"的"存储"有"泄露"风险。
  2. 身份关联:DID"关联"用户的"链上"和"链下"身份——"隐私"保护"更难"。
  3. 监管合规:DID"需要"满足"法规"要求——"KYC"、"AML"、"GDPR"。

第二场:从"DID"到"SSI"——"自我主权身份"的"未来"

自我主权身份(SSI)的"未来"方向:

  1. 完全去中心化:用户"完全"掌控"身份"数据——"没有"中心化的"发行者"。
  2. 零知识验证:使用ZK-SNARK"验证"身份"属性"——"不揭示"任何"额外"信息。
  3. 跨链互操作:DID"跨链"验证——"Ethereum"、"Solana"、"Polkadot"。

第三场:从"创作者"到"创作者经济"——"DID"的"经济"影响

DID对"创作者经济"的"影响":

  1. 创作者信用:DID"聚合"创作者的"声誉"和"信用"——"降低"合作"风险"。
  2. 创作者借贷:DID"关联"创作者的"收入"——"协议"可以"借贷"给"创作者"。
  3. 创作者DAO:DID"标识"创作者DAO的"成员"——"投票"、"治理"、"收入"分配。
const { ethers } = require('ethers');
const { DID, VerifiableCredential, Resolver } = require('did-resolver');
const { getResolver } = require('ethr-did-resolver');

class CreatorDIDClient {
  constructor(providerUrl, registryAddress) {
    this.provider = new ethers.providers.JsonRpcProvider(providerUrl);
    this.registryAddress = registryAddress;
    this.didRegistry = {};
    this.credentialRegistry = {};
    this.reputationScores = new Map();
  }

  async createDID(owner) {
    const didId = `did:ethr:${owner}`;
    const didDocument = {
      '@context': 'https://www.w3.org/ns/did/v1',
      id: didId,
      verificationMethod: [{
        id: `${didId}#controller`,
        type: 'EcdsaSecp256k1RecoveryMethod2020',
        controller: didId,
        blockchainAccountId: `${owner}@eip155:1`
      }],
      authentication: [`${didId}#controller`],
      assertionMethod: [`${didId}#controller`],
      service: [{
        id: `${didId}#creator`,
        type: 'CreatorService',
        serviceEndpoint: 'https://bcu.lat/creator'
      }]
    };

    this.didRegistry[didId] = didDocument;
    return didDocument;
  }

  async issueCredential(holderDid, credType, claims) {
    const credential = {
      '@context': [
        'https://www.w3.org/2018/credentials/v1',
        'https://www.w3.org/2018/credentials/examples/v1'
      ],
      type: ['VerifiableCredential', 'CreatorCredential'],
      issuer: this.didRegistry[holderDid]?.id || holderDid,
      issuanceDate: new Date().toISOString(),
      credentialSubject: {
        id: holderDid,
        type: credType,
        ...claims
      },
      proof: {
        type: 'EcdsaSecp256k1Signature2019',
        created: new Date().toISOString(),
        proofPurpose: 'assertionMethod',
        verificationMethod: `${holderDid}#controller`
      }
    };

    const credHash = ethers.utils.keccak256(
      ethers.utils.toUtf8Bytes(JSON.stringify(credential))
    );
    this.credentialRegistry[credHash] = credential;
    return { credential, credHash };
  }

  async calculateReputation(creatorAddress) {
    const score = this.reputationScores.get(creatorAddress) || {
      total: 0,
      contentCount: 0,
      totalViews: 0,
      totalRevenue: 0,
      credibilityScore: 0
    };

    if (score.contentCount === 0) return { score: 0, level: 'newcomer' };

    const engagementRate = score.totalViews / score.contentCount;
    const revenuePerContent = score.totalRevenue / score.contentCount;

    score.credibilityScore = Math.min(
      Math.floor(engagementRate * 10 + revenuePerContent * 5 + score.contentCount * 2),
      100
    );

    let level = 'newcomer';
    if (score.credibilityScore > 80) level = 'trusted';
    else if (score.credibilityScore > 60) level = 'established';
    else if (score.credibilityScore > 40) level = 'growing';
    else if (score.credibilityScore > 20) level = 'emerging';

    return { score: score.credibilityScore, level };
  }

  async updateCreatorStats(creator, stats) {
    const current = this.reputationScores.get(creator) || {
      total: 0,
      contentCount: 0,
      totalViews: 0,
      totalRevenue: 0,
      credibilityScore: 0
    };

    current.contentCount += stats.contentCount || 1;
    current.totalViews += stats.views || 0;
    current.totalRevenue += stats.revenue || 0;
    current.total += stats.total || 0;

    const result = await this.calculateReputation(creator);
    current.credibilityScore = result.score;

    this.reputationScores.set(creator, current);
    return current;
  }

  async verifyCredential(credentialHash) {
    return credentialHash in this.credentialRegistry;
  }

  async getDIDDocument(didId) {
    return this.didRegistry[didId] || null;
  }

  async createCreatorDAO(daoName, members) {
    const dao = {
      name: daoName,
      members: members.map(m => ({
        did: m.did,
        role: m.role,
        reputation: this.reputationScores.get(m.address)?.credibilityScore || 0,
        joinDate: new Date().toISOString()
      })),
      createdAt: new Date().toISOString()
    };
    return dao;
  }
}

const client = new CreatorDIDClient('https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY', '0xRegistry');
client.createDID('0xCreator123').then(doc => console.log('DID:', doc.id));

DID future

终场:从"身份"到"信用"——"DID"的"创作者"革命

去中心化身份(DID)正在"重塑"数字世界的"信用"体系。从"创作者"到"消费者",从"声誉"到"信用",DID协议"允许"用户"掌控"自己的"数字身份",而"不依赖"中心化的"平台"。

这是"数字身份"的"去中心化"革命——从"平台拥有"到"用户拥有",从"中心化验证"到"去中心化信任"。DID正在"重新定义"我们"信任"的"方式"——不是"信任"平台,而是"信任"密码学。

在这个万物皆可Token化的时代,技术的迭代往往比镜头切换更快。作为北京城市学院2021级广播电视编导的毕业生,我始终在影像与区块链的交汇处寻找共鸣。感谢阅读,我是王森涛,让我们在视听与去中心化的世界里,继续探索。


评论