Omnilock(lock)约束Omnilock (lock) Constraints

来源:nervosnetwork/omnilock / c/omni_lock.c + ckb_identity.h · mainnet 0x9b81…6f26 / testnet 0xf329…52cb,hash_type type(RFC 0042)Source: nervosnetwork/omnilock / c/omni_lock.c + ckb_identity.h · mainnet 0x9b81…6f26 / testnet 0xf329…52cb, hash_type type (RFC 0042)
Lock 脚本Lock script身份 / 钱包Identity / wallet主网Mainnet测试网Testnet开源Open sourceNervos 官方Nervos

A普通解锁(auth 签名)Normal unlock (auth signature)

Inputs 输入Inputs
input(同一 Omnilock group)input (same Omnilock group)Cell{ lock: { codeHash: OMNILOCK, args: auth(21B) ‖ omnilock flags 1B ‖ optional fields } }
witness[group 第 1 个]witness[group's first]WitnessArgs{ lock: OmniLockWitnessLock{ signature: Some(sig), omni_identity: None, preimage: None/Some } }WitnessArgs{ lock: OmniLockWitnessLock{ signature: Some(sig), omni_identity: None, preimage: None/Some } }
➜
Outputs 输出Outputs
outputs:任意outputs: anyCell{ lock: 任意, type: 任意 }Cell{ lock: any, type: any }
args 字节布局args byte layout
auth flag1B
auth content20B
omnilock flags1B
omni_root?32B
acp min?2B
since?8B
info_cell?32B
  • auth flag 1B 0 CKB / 1 ETH / 2 EOS / 3 Tron / 4 BTC / 5 Doge / 6 multisig / 0x12 ETH显示 / 0xFC owner lock / 0xFD exec / 0xFE dl0 CKB / 1 ETH / 2 EOS / 3 Tron / 4 BTC / 5 Doge / 6 multisig / 0x12 ETH-displaying / 0xFC owner lock / 0xFD exec / 0xFE dl 已知取值known value (CKB_INVALID_DATA)
  • auth content 20B pubkey hash / 地址 / multisig script hash / lock script hash[0..20]pubkey hash / address / multisig script hash / lock script hash[0..20] 与签名恢复结果一致matches the recovered signer (-31)
  • omnilock flags 1B bit0 管理员(omni_root) · bit1 ACP · bit2 time-lock · bit3 supplybit0 admin (omni_root) · bit1 ACP · bit2 time-lock · bit3 supply 决定后续字段selects the optional fields (87)
  • omni_root? 32B RC cell 的 type_id(bit0)RC cell type_id (bit0) — (87)
  • acp min? 2B CKB / UDT 最小转入(10^n)(bit1)min CKB / UDT payment as 10^n (bit1) — (87)
  • since? 8B time-lock(bit2)time-lock (bit2) — (87)
  • info_cell? 32B supply info cell type hash(bit3)supply info cell type hash (bit3) — (87)

限制Constraints

  • args:: 长度 = 22 + 所选可选字段,多一字节少一字节都不行length = 22 + chosen optional fields, exactly (87)
  • signature:: auth flag 0–5 / 0x12:恰 65 字节auth flag 0–5 / 0x12: exactly 65 bytes (71)
  • signature:: 恢复出的地址 = auth contentrecovered signer = auth content (-31)
  • auth flag 6:: multisig 规则同 secp multisigmultisig rules as in secp multisig (-41…-52)
  • auth flag 0xFC:: 某个 input 的 lock hash 前 20B = auth contentsome input lock hash[0..20] = auth content (70)
  • since(bit2):: 每个 group input 的 since flags 相同且 ≥ args.sinceeach group input since has same flags and ≥ args.since (-23 / -24)
  • supply(bit3):: info cell 供应量不超上限、不得 burn 等info cell supply ≤ max, no burn, etc. (90 / 91 / 92 / 93)

BACP 模式(bit1 且无签名)ACP mode (bit1, no signature)

Inputs 输入Inputs
inputCell{ lock: OMNILOCK(args flags bit1), capacity: C, data: udt amount? }
witnesssignature: Nonesignature: None
➜
Outputs 输出Outputs
同 lock 输出output with the same lockCell{ lock: same, capacity: ≥ C + 10^ckb_min, udt: ≥ + 10^udt_min }

限制Constraints

  • pairing:: 每个输入 lock 必须有唯一对应输出each input lock pairs with exactly one output (-44 / -45 / -46)
  • amount:: CKB 与 UDT 均不减少,且增加不少于最小值CKB and UDT don't decrease and grow by at least the minimum (-42)
  • type:: 最多 32 种 type hashat most 32 type hashes (-43)

C管理员模式(omni_identity)Administrator mode (omni_identity)

Inputs 输入Inputs
witnessOmniLockWitnessLock{ signature: Some, omni_identity: Some(Identity{identity 21B, proofs}) }
cell_depscell_depsRC cell(type_id = omni_root),含白名单 SMT rootRC cell (type_id = omni_root) with whitelist SMT root
➜
Outputs 输出Outputs
outputs任意;since / supply / ACP 均不生效any; since / supply / ACP don't apply

限制Constraints

  • args:: 必须带 omni_root(bit0)must have omni_root (bit0) (47)
  • omni_identity:: 必须带 proofsmust include proofs (47)
  • RC rules:: 至少一条,且为白名单at least one rule, whitelist (82 / 83)
  • proof:: 证明条数 = rule 数,identity 在白名单 SMT 中proof count = rule count, identity in whitelist SMT (81 / 59)
部署与来源Deployments & source 未核验unverified
源码source nervosnetwork/omnilock@280dd97a · c/omni_lock.c (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 no binary or checksum at the recorded commit matched the deployed data hash (reproducible build not attempted)
网络networkcode_hashcell_deptype_id args数据哈希data hash部署交易deploy tx
mainnet0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26 type0xc76edf4698…3472c842:0 code0x855508fe0f…e948236a0x768f306681…fd2d118d0xc76edf4698…3472c842 #12017064
testnet0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb type0xec18bf0d85…2f5d4602:0 code0x761f51fc9c…25a891440x6b29b6f103…8f8318fa0xec18bf0d85…2f5d4602 #12898141
链上数据核对于 on-chain data checked 2026-10-20
错误码:80 UNKNOWN_FLAGS · 81 PROOF_LENGTH_MISMATCHED · 82 NO_OMNIRULE · 83 NO_WHITE_LIST · 84 INVALID_IDENTITY_ID · 85 INVALID_OMNI_LOCK_ARGS · 86 ISO9796_2_VERIFY · 87 ARGS_FORMAT;70–75 identity 错误(70 LOCK_SCRIPT_HASH_NOT_FOUND, 71 WRONG_ARGS);40–63 来自 rce.hError codes: 80 UNKNOWN_FLAGS · 81 PROOF_LENGTH_MISMATCHED · 82 NO_OMNIRULE · 83 NO_WHITE_LIST · 84 INVALID_IDENTITY_ID · 85 INVALID_OMNI_LOCK_ARGS · 86 ISO9796_2_VERIFY · 87 ARGS_FORMAT; 70–75 identity errors (70 LOCK_SCRIPT_HASH_NOT_FOUND, 71 WRONG_ARGS); 40–63 from rce.h
签名消息与 secp256k1_blake160 相同(sighash_all),ETH/BTC 等再按各链格式包装Signing message is the same sighash_all as secp256k1_blake160, then wrapped per chain format for ETH/BTC/etc.
witness 缺失不会立即失败(owner lock 模式可不需要 witness)A missing witness doesn't fail immediately (owner-lock mode may need none)
GitHub · gpBlockchain/ckb-contract-flow-html