微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🛂

零知识护照验证,隐私合规两不误

Self zkID verification · v1.0.0
专业技能 安全 A 级 作者 0xturboblitz 公开目录收录
1k 下载 0 安装 2.1k 收藏 13 浏览

简介

基于零知识证明的隐私优先身份验证协议,支持护照/身份证 NFC 扫描验证年龄、国籍等属性,无需暴露个人数据。

原始描述

Integrate Self (self.xyz) — a privacy-first identity protocol using zero-knowledge proofs to verify passports and ID cards. Use when the user mentions Self protocol, Self identity, self.xyz, passport verification, zero-knowledge identity verification, SelfAppBuilder, SelfBackendVerifier, SelfVerificationRoot, or wants to add privacy-preserving KYC, age verification, nationality checks, OFAC screening, or Sybil resistance using real-world identity documents. Covers frontend QR code integration, backend proof verification, and on-chain smart contract verification on Celo.

通过你的 Agent 添加

安装目录:self-xyz/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/self-zkid-verification/
Codex CLI~/.codex/skills/self-zkid-verification/
DeepSeek Harness~/.agents/skills/self-zkid-verification/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

Self Protocol 综合评估

核心用法

Self Protocol 是一个隐私优先的去中心化身份验证解决方案,允许用户通过零知识证明(ZKP)从护照或身份证 NFC 芯片中证明特定属性(如年龄 ≥18、国籍、人类证明),而无需暴露任何原始个人数据。

主要集成模式:

  • 链下验证(推荐):通过 SelfBackendVerifier 在服务器端验证证明,适合 Web 应用和 API
  • 链上验证:在 Celo 智能合约中继承 SelfVerificationRoot 进行验证,适合 DeFi、空投、代币门控等无需许可场景
  • 深度链接:移动优先流程,直接唤起 Self 应用而非扫码

技术栈:@selfxyz/qrcode(前端 QR 组件)+ @selfxyz/core(后端验证),要求版本 ≥ 1.1.0-beta.1。

显著优点

  1. 隐私保护核心:采用零知识证明,验证方仅获知「满足条件」的布尔结果,无法获取姓名、证件号、照片等原始数据
  2. 真实世界身份锚定:基于政府签发的 ICAO 9303 标准电子护照/身份证,Sybil 抵抗性强于纯链上方案
  3. 合规友好:支持 OFAC 筛查、年龄验证、国籍限制等监管常见需求,无需中心化 KYC 服务商
  4. 多链部署:Celo 主网 + 测试网合约已部署,生态整合成熟
  5. 开发者体验:提供 React 组件 SelfQRcodeWrapper 和完整的 TypeScript SDK,快速集成

潜在局限性与风险

  1. 硬件依赖:用户需持有带 NFC 芯片的护照/身份证及支持 NFC 的智能手机,覆盖面受限
  2. 配置严格性:前后端披露配置(disclosures)必须完全匹配,否则静默失败,调试难度高
  3. 网络限制:Self 应用需直接向开发者端点发送证明,要求公网可访问,本地开发需 ngrok 等工具
  4. 国家代码限制:排除列表最多 40 个国家,ISO 3 位代码易出错
  5. 版本碎片化:当前为 beta 版本(1.1.0-beta.1),API 可能变动

适合人群

  • DeFi 协议:需抗女巫攻击的空投、流动性挖矿资格验证
  • GameFi / SocialFi:年龄分级内容访问、一身份一账号限制
  • 合规 DApp:需满足 AML/OFAC 要求但拒绝中心化 KYC 的隐私敏感项目
  • DAO 治理:国籍/居住地限制投票资格的链上治理

常规风险

  • 智能合约风险:继承 SelfVerificationRoot 的合约需审计,自定义 customVerificationHook 可能引入漏洞
  • 配置错误风险:mockPassport 误用于主网或真实护照用于测试网会导致验证失败
  • 端点安全:验证端点需防重放攻击,建议结合 userId 和 nonce 机制
  • 依赖风险:协议依赖 Self 移动应用和中心化 Hub 合约,存在单点故障可能

安全建议

  • 生产环境严格禁用 mockPassport
  • 使用 DefaultConfigStore 确保前后端配置一致性
  • 链上验证时确保 scope 唯一性(Poseidon 哈希防止跨合约重放)
  • 监控 ScopeMismatch、InvalidIdentityCommitmentRoot 等常见错误日志

技能正文


name: self-xyz description: "Integrate Self (self.xyz) — a privacy-first identity protocol using zero-knowledge proofs to verify passports and ID cards. Use when the user mentions Self protocol, Self identity, self.xyz, passport verification, zero-knowledge identity verification, SelfAppBuilder, SelfBackendVerifier, SelfVerificationRoot, or wants to add privacy-preserving KYC, age verification, nationality checks, OFAC screening, or Sybil resistance using real-world identity documents. Covers frontend QR code integration, backend proof verification, and on-chain smart contract verification on Celo."

Self Protocol Integration

Self lets users prove identity attributes (age, nationality, humanity) from passports/ID cards using zero-knowledge proofs — no personal data exposed. Users scan their document's NFC chip in the Self mobile app and share a zk proof with your app.

Quick Start (Next.js Off-Chain)

1. Install

npm install @selfxyz/qrcode @selfxyz/core

2. Frontend — QR Code Component

"use client";
import { SelfQRcodeWrapper, SelfAppBuilder } from "@selfxyz/qrcode";

export default function VerifyIdentity({ userId }: { userId: string }) {
  const selfApp = new SelfAppBuilder({
    appName: "My App",
    scope: "my-app-scope",
    endpoint: "https://yourapp.com/api/verify",
    endpointType: "https",
    userId,
    userIdType: "hex",
    disclosures: {
      minimumAge: 18,
    },
  }).build();

  return (
    <SelfQRcodeWrapper
      selfApp={selfApp}
      onSuccess={() => console.log("Verified")}
      type="websocket"
      darkMode={false}
    />
  );
}

3. Backend — Verification Endpoint

// app/api/verify/route.ts
import { SelfBackendVerifier, DefaultConfigStore } from "@selfxyz/core";

export async function POST(req: Request) {
  const { proof, publicSignals } = await req.json();

  const verifier = new SelfBackendVerifier(
    "my-app-scope",                    // must match frontend scope
    "https://yourapp.com/api/verify",  // must match frontend endpoint
    true,                              // true = accept mock passports (dev only)
    null,                              // allowedIds (null = all)
    new DefaultConfigStore({           // must match frontend disclosures
      minimumAge: 18,
    })
  );

  const result = await verifier.verify(proof, publicSignals);

  return Response.json({
    verified: result.isValid,
    nationality: result.credentialSubject?.nationality,
  });
}

Integration Patterns

Pattern When to Use endpoint endpointType
Off-chain (backend) Web apps, APIs, most cases Your API URL "https" or "https-staging"
On-chain (contract) DeFi, token gating, airdrops Contract address (lowercase) "celo" or "celo-staging"
Deep linking Mobile-first flows Your API URL "https"
  • Off-chain: Fastest to implement. Proof sent to your backend, verified server-side.
  • On-chain: Proof verified by Celo smart contract. Inherit SelfVerificationRoot. Use for trustless/permissionless scenarios.
  • Deep linking: For mobile users — opens Self app directly instead of QR scan. See references/frontend.md.

Critical Gotchas

  1. Config matching is mandatory — Frontend disclosures must EXACTLY match backend/contract verification config. Mismatched age thresholds, country lists, or OFAC settings cause silent failures.

  2. Contract addresses must be lowercase — Non-checksum format in frontend endpoint. Use .toLowerCase().

  3. Country codes are ISO 3-letter — e.g., "USA", "IRN", "PRK". Max 40 countries in exclusion lists.

  4. Mock passports = testnet only — Set mockPassport: true in backend / use "celo-staging" endpoint type. Real passports require mainnet. To create a mock passport: open Self app, tap the Passport button 5 times. Mock testing requires OFAC disabled.

  5. Version requirement — @selfxyz/core >= 1.1.0-beta.1.

  6. Attestation IDs — 1 = Passport, 2 = Biometric ID Card. Must explicitly allow via allowedIds map.

  7. Scope uniqueness — On-chain, scope is Poseidon-hashed with contract address, preventing cross-contract proof replay.

  8. Endpoint must be publicly accessible — Self app sends proof directly to your endpoint. Use ngrok for local development.

  9. Common errors: ScopeMismatch = scope/address mismatch or non-lowercase address. Invalid 'to' Address = wrong endpointType (celo vs https). InvalidIdentityCommitmentRoot = real passport on testnet (use mainnet). Invalid Config ID = mock passport on mainnet (use testnet).

Deployed Contracts (Celo)

Network Address
Mainnet Hub V2 0xe57F4773bd9c9d8b6Cd70431117d353298B9f5BF
Sepolia Hub V2 0x16ECBA51e18a4a7e61fdC417f0d47AFEeDfbed74
Sepolia Staging Hub V2 0x68c931C9a534D37aa78094877F46fE46a49F1A51

References

Load these for deeper integration details:

  • references/frontend.md — SelfAppBuilder full config, SelfQRcodeWrapper props, deep linking with getUniversalLink, disclosure options
  • references/backend.md — SelfBackendVerifier constructor details, DefaultConfigStore vs InMemoryConfigStore, verification result schema, dynamic configs
  • references/contracts.md — SelfVerificationRoot inheritance pattern, Hub V2 interaction, setVerificationConfigV2, customVerificationHook, getConfigId, userDefinedData patterns

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

zero-knowledgeidentitypassportkycprivacycelosybil-resistancecompliancenfczkp

同类 Skill