← 返回
数据分析 中文

Self zkID verification

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, b
集成 Self (self.xyz) — 采用零知识证明的隐私优先身份协议,用于护照和身份证验证。适用于提及 Self 协议、Self 身份、self.xyz、护照验证、零知识身份验证、SelfAppBuilder、SelfBackendVerifier、SelfVerificationRoot,或需要隐私保护的 KYC、年龄、国籍检查、OFAC 筛查、Sybil 抗性。覆盖前端二维码集成、后端证明验证以及 Celo 链上智能合约验证。
0xturboblitz
数据分析 clawhub v1.0.0 1 版本 99891.8 Key: 无需
★ 0
Stars
📥 923
下载
💾 41
安装
1
版本
#latest

概述

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

PatternWhen to UseendpointendpointType
-------------------------------------------------
Off-chain (backend)Web apps, APIs, most casesYour API URL"https" or "https-staging"
On-chain (contract)DeFi, token gating, airdropsContract address (lowercase)"celo" or "celo-staging"
Deep linkingMobile-first flowsYour 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.
  1. Contract addresses must be lowercase — Non-checksum format in frontend endpoint. Use .toLowerCase().
  1. Country codes are ISO 3-letter — e.g., "USA", "IRN", "PRK". Max 40 countries in exclusion lists.
  1. 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.
  1. Version requirement@selfxyz/core >= 1.1.0-beta.1.
  1. Attestation IDs1 = Passport, 2 = Biometric ID Card. Must explicitly allow via allowedIds map.
  1. Scope uniqueness — On-chain, scope is Poseidon-hashed with contract address, preventing cross-contract proof replay.
  1. Endpoint must be publicly accessible — Self app sends proof directly to your endpoint. Use ngrok for local development.
  1. 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)

NetworkAddress
------------------
Mainnet Hub V20xe57F4773bd9c9d8b6Cd70431117d353298B9f5BF
Sepolia Hub V20x16ECBA51e18a4a7e61fdC417f0d47AFEeDfbed74
Sepolia Staging Hub V20x68c931C9a534D37aa78094877F46fE46a49F1A51

References

Load these for deeper integration details:

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

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 05:47 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 199 📥 65,268
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,886
data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 166 📥 60,271