DID CKB 约束DID CKB Constraints

来源:web5fans/did-ckb / contracts/did-ckb-ts/src/entry.rs · mainnet 0x4a06…984a / testnet 0x5101…c7c5 (type)Source: web5fans/did-ckb / contracts/did-ckb-ts/src/entry.rs · mainnet 0x4a06…984a / testnet 0x5101…c7c5 (type)
Type 脚本Type script身份 / 钱包Identity / wallet主网Mainnet测试网Testnet开源Open source社区Community

A铸造Mint

Inputs 输入Inputs
inputs[0]:任意inputs[0]: anyCellInput{ since, previous_output }
➜
Outputs 输出Outputs
DID cellCell{ type: { codeHash: DID_CKB, args: did_id 20B ‖ … }, data: DidCkbData::V1 { document, local_id? } }
witnessWitnessArgs{ output_type: DidCkbWitness { local_id_authorization: { history, sig, rotation_key_indices } } }
args 字节布局args byte layout
did_id20B
  • did_id 20B type_id 前 20 字节first 20 bytes of type_id = blake2b(inputs[0] ‖ 首个 group 输出序号)[0..20]= blake2b(inputs[0] ‖ first group output index)[0..20] (26)
data 字节布局data byte layout
union_id4B
documentBytes
local_idStringOpt
  • union_id 4B 0 = DidCkbDataV10 = DidCkbDataV1 必须为 0must be 0 (51)
  • document Bytes DID 文档(CBOR)DID document (CBOR) 合法 CBORvalid CBOR (52)
  • local_id StringOpt 可选 did:plc 标识(UTF-8)optional did:plc id (UTF-8) 非空时需 PLC 授权needs PLC authorisation if set (31–46)

限制Constraints

  • type_id:: args ≥ 20 字节,group 输入/输出各 ≤ 1,args[0..20] 按 type_id 规则计算args ≥ 20 bytes, ≤ 1 group input/output each, args[0..20] by the type_id rule (26)
  • data:: molecule 合法且 document 为合法 CBORvalid molecule and document is valid CBOR (51 / 52)
  • local_id:: 为空则直接通过;否则 witness 中 PLC 操作历史必须有效,且最后签名覆盖 tx_hash(未检查)empty passes; otherwise the PLC operation history in the witness must be valid and the final signature must cover tx_hash (not checked) (31–46)

B更新Update

Inputs 输入Inputs
DID cellCell{ type: DID_CKB(args), data: V1 {doc, local_id} }
➜
Outputs 输出Outputs
DID cellCell{ type: same, data: V1 {doc', local_id} }

限制Constraints

  • data:: 输入输出 data 均合法、document 均为 CBORboth data valid, both documents CBOR (51 / 52)
  • local_id:: local_id 不得改变local_id must not change (53)
  • auth:: 由 lock 授权(type 不检查签名)authorised by the lock (the type checks no signature) (—)

C销毁Burn

Inputs 输入Inputs
DID cellCell{ type: DID_CKB }
➜
Outputs 输出Outputs
无该 type 输出no output with that type——

限制Constraints

  • —:: 无额外限制no further rule (—)
部署与来源Deployments & source 未核验unverified
源码source web5fans/did-ckb@f37c14af · contracts/did-ckb-ts/src (default-branch HEAD recorded at backfill 2026-10-21; spec/plugin were written from the default branch shortly before (exact read commit not recorded))
二进制核验binary check 未核验unverified hash appears in the repo only as a deployment record or doc, which does not prove the recorded commit builds this binary (reproducible build not attempted)
0x079bb8c1df…f3f682a9: listed in deployment/mainnet/migrations/2025-11-27-050508.json; listed in deployment/testnet/migrations/2025-11-28-022028.json
网络networkcode_hashcell_deptype_id args数据哈希data hash部署交易deploy tx
mainnet0x4a06164dc34dccade5afe3e847a97b6db743e79f5477fa3295acf02849c5984a type0xe2f74c56cd…9ae015bf:0 code0x55573ef6d7…75c2cb180x079bb8c1df…f3f682a90xe2f74c56cd…9ae015bf #17943462
testnet0x510150477b10d6ab551a509b71265f3164e9fd4137fcb5a4322f49f03092c7c5 type0x0e7a830e2d…fb3d6a6c:0 code0x3c27695173…9c141c350x079bb8c1df…f3f682a90x0e7a830e2d…fb3d6a6c #19280654
链上数据核对于 on-chain data checked 2026-10-20
错误码(error.rs):21–27 syscall(26 TypeIDError)· 31–46 ckb-did-plc-utils · 51 Molecule · 52 InvalidDocumentCbor · 53 MismatchedFromError codes (error.rs): 21–27 syscall (26 TypeIDError) · 31–46 ckb-did-plc-utils · 51 Molecule · 52 InvalidDocumentCbor · 53 MismatchedFrom
GitHub · gpBlockchain/ckb-contract-flow-html