secp256k1_blake160_multisig_all V2(lock)约束secp256k1_blake160_multisig_all V2 (lock) Constraints

code_hash 0x36c9…0d29,hash_type data1(ckb-sdk MultisigScript::V2 / ckb-devrel ccc) · ckb-system-scripts PR #99:改进可选 since 处理;witness 布局与旧版相同(下列约束按旧版源码整理)code_hash 0x36c9…0d29, hash_type data1 (ckb-sdk MultisigScript::V2 / ckb-devrel ccc) · ckb-system-scripts PR #99: improved optional-since handling; witness layout identical to legacy (constraints below follow the legacy source)
Lock 脚本Lock script系统 / 创世System身份 / 钱包Identity / wallet主网Mainnet测试网Testnet开源Open sourceNervos 官方Nervos

1 → N解锁花费 multisig cellUnlock & spend a multisig cell

Inputs 输入Inputs
input(同一 lock 的 script group,可多个)input (script group of the same lock; may be several)Cell{ capacity: …, lock: { codeHash: MULTISIG, args: blake160(multisig_script) 20B [+ since u64 LE 8B] }, since: 满足 args 中的 since(若有) }Cell{ capacity: …, lock: { codeHash: MULTISIG, args: blake160(multisig_script) 20B [+ since u64 LE 8B] }, since: satisfies the since in args (if any) }
witness[group 第 1 个 input 的位置]witness[at the group's first input index]WitnessArgs{ lock: multisig_script ‖ signature[0..M-1] } 长度必须 = 4 + 20·N + 65·MWitnessArgs{ lock: multisig_script ‖ signature[0..M-1] } length must = 4 + 20·N + 65·M
➜
Outputs 输出Outputs
outputs:任意 celloutputs: any cellsCell{ capacity: …, lock: 任意, type: 任意 }Cell{ capacity: …, lock: any, type: any }
witness.lock 字节布局(multisig_script ‖ signatures)witness.lock byte layout (multisig_script ‖ signatures)
S1B
R1B
M1B
N1B
pubkey_hash[0..N-1]20B × N20B × N
signature[0..M-1]65B × M
  • S 1B 保留字段(lock[0])reserved field (lock[0]) 必须为 0must be 0 (-41)
  • R 1B require_first_n(lock[1]):pubkey_hash[0..R-1] 必须全部签名require_first_n (lock[1]): pubkey_hash[0..R-1] must all sign R ≤ M ([object Object])
  • M 1B threshold(lock[2]):需要的签名个数threshold (lock[2]): number of required signatures 0 < M ≤ N (-43)
  • N 1B pubkeys_cnt(lock[3]):公钥总数pubkeys_cnt (lock[3]): total number of pubkeys N > 0 (-42)
  • pubkey_hash[0..N-1] 20B × N20B × N blake160(33 字节压缩公钥),顺序有意义(R 引用前 R 个)blake160(33-byte compressed pubkey); order matters (R refers to the first R) 每个签名恢复出的公钥哈希须匹配其中一个尚未使用的each signature's recovered pubkey hash must match a not-yet-used entry (-52)
  • signature[0..M-1] 65B × M 可恢复 secp256k1 签名:r‖s(64B) + recid(1B);签名时这部分置 0 参与消息哈希recoverable secp256k1 signature: r‖s (64B) + recid (1B); zero-filled when computing the signing message 可解析 / 可恢复公钥 / 可序列化parsable / pubkey recoverable / serializable (-14 / -11 / -15)
multisig_script = 前 4+20·N 字节(S|R|M|N|pubkey_hashes);lock 总长 ≠ 4+20·N+65·M → (-22);lock < 4 字节 → (-22)multisig_script = first 4+20·N bytes (S|R|M|N|pubkey_hashes); lock length ≠ 4+20·N+65·M → (-22); lock < 4 bytes → (-22)
lock.args 推导Deriving lock.args
blake160(multisig_script)20B
since(可选)since (optional)8B u64 LE
  • blake160(multisig_script) 20B blake2b-256(personal="ckb-default-hash")(multisig_script) 取前 20 字节first 20 bytes of blake2b-256(personal="ckb-default-hash")(multisig_script) 必须等于 args[0..20]must equal args[0..20] (-51)
  • since(可选)since (optional) 8B u64 LE 时间锁:本 group 所有 input 的 since flags 必须相同,值 ≥ 此值time lock: every input in the group must have identical since flags and a value ≥ this args 长度只能 20 或 28args length must be 20 or 28 ([object Object])
例:2-of-3,R=0(pubkey_hash 为示例值)Example: 2-of-3, R=0 (pubkey hashes are placeholders)
S=001B
R=001B
M=021B
N=031B
11…11 / 22…22 / 33…333 × 20B
    multisig_script0x00000203111111111111111111111111111111111111111122222222222222222222222222222222222222223333333333333333333333333333333333333333 (64B)
    args (20B)0xbf96e998f1616a35247a9ab89bfd3f485af397fe
    args + since (28B)0xbf96e998f1616a35247a9ab89bfd3f485af397fe6400000000010020 ← since=0x2000010000000064(绝对 epoch 100)LE0xbf96e998f1616a35247a9ab89bfd3f485af397fe6400000000010020 ← since=0x2000010000000064 (absolute epoch 100), LE
    witness.lock 长度witness.lock length4 + 20×3 + 65×2 = 194 字节(签名时后 130 字节为 0)4 + 20×3 + 65×2 = 194 bytes (last 130 bytes zeroed while signing)
    任意 2 个不同成员签名即可;若 R=1,则 pubkey_hash[0] 必须是签名者之一any 2 distinct members can sign; if R=1, pubkey_hash[0] must be one of the signers

    限制Constraints

    • args:: 长度为 20 或 28 字节length is 20 or 28 bytes (-1)
    • args 中的 sincesince in args:: 本 group 每个 input 的 since flags 必须与之完全相同every input in this group must have exactly the same since flags (-23)
    • input.since 值input.since value ≥ args 中的 since 值(epoch 按分数比较)≥ the since value in args (epochs compared as fractions) (-24)
    • witness:: WitnessArgs 合法且 lock 不为空valid WitnessArgs with non-empty lock (-2)
    • witness 大小witness size ≤ 32KB;lock ≥ 4 字节;且 lock 长度 = 4 + 20·N + 65·M≤ 32KB; lock ≥ 4 bytes; and lock length = 4 + 20·N + 65·M (-22)
    • blake160(multisig_script):: 等于 args 前 20 字节equals the first 20 bytes of args (-51)
    • 签名signatures:: M 个签名各自恢复出 N 个公钥中不同的一个;前 R 个公钥必须都签名the M signatures each recover a distinct one of the N pubkeys; the first R pubkeys must all sign (-52)
    • 签名格式signature format:: 无法解析 / 无法恢复公钥 / 无法序列化cannot parse / cannot recover pubkey / cannot serialize (-14 / -11 / -15)
    部署与来源Deployments & source 未核验unverified
    源码source nervosnetwork/ckb-system-scripts@72eb92fc · c/secp256k1_blake160_multisig_all.c · c/common.h (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
    mainnet0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29 data10x6888aa39ab…8efbf738:0 dep_group—0x36c971b8d4…dddb0d290x3e27a1a247…1e5fa282 #15936922
    testnet0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29 data10x2eefdeb21f…090b26d5:0 dep_group0x6766613320…7c910c2c0x36c971b8d4…dddb0d290x732857f7ce…18b68685 #16668158
    mainnet0xd1a9f877aed3f5e07cb9c52b61ab96d06f250ae6883cc7f0a2423db0976fc821 type0x0a13d8d9c8…abc455d8:0 code0x351ab02b4f…8df13da40x50c8623ef5…c39911450x0a13d8d9c8…abc455d8 #13948668
    testnet0x765b3ed6ae264b335d07e73ac332bf2c0f38f8d3340ed521cb447b4c42dd5f09 type0xe6774580c9…e3c1ad71:0 code0xbbde6d0d2a…3ed0bc130x50c8623ef5…c39911450xe6774580c9…e3c1ad71 #14236278
    链上数据核对于 on-chain data checked 2026-10-20
    签名消息 = blake2b(tx_hash ‖ len(w0) ‖ w0(签名部分置 0) ‖ 本 group 其余 witness 的 len‖内容 ‖ 超出 inputs 数量部分的 witness 的 len‖内容);len 为 u64 LEsigning message = blake2b(tx_hash ‖ len(w0) ‖ w0 (signatures zeroed) ‖ len‖content of the group's other witnesses ‖ len‖content of witnesses beyond the inputs count); len is u64 LE
    blake160 = blake2b-256(CKB personalization)取前 20 字节;其他错误码:-3 ERROR_SYSCALL,-21 ERROR_SCRIPT_TOO_LONGblake160 = first 20 bytes of blake2b-256 (CKB personalization); other error codes: -3 ERROR_SYSCALL, -21 ERROR_SCRIPT_TOO_LONG
    GitHub · gpBlockchain/ckb-contract-flow-html