Nostr lock 约束Nostr lock Constraints
来源:nervosnetwork/nostr-binding / contracts/nostr-lock/src · mainnet 0x641a…4c68 / testnet 0x6ae5…91d5,hash_type type(ccc)Source: nervosnetwork/nostr-binding / contracts/nostr-lock/src · mainnet 0x641a…4c68 / testnet 0x6ae5…91d5, hash_type type (ccc)
ANostr 密钥签名解锁(pow_difficulty = 0)Unlock with a Nostr key (pow_difficulty = 0)
Inputs 输入Inputs
inputCell{
lock: { codeHash: NOSTR_LOCK,
args: 0x00 ‖ blake160(schnorr pubkey) 20B }
}
witness[group 0].lockNostr event JSON {
id, pubkey, created_at,
kind: 23334,
tags: [["ckb_sighash_all", hex(sighash_all)], …],
content: fixed notice,
sig
}
➜
Outputs 输出Outputs
outputs:任意outputs: anyCell{ lock: 任意 }Cell{ lock: any }
args 字节布局(21B)args byte layout (21B)
pow_difficulty1B
pubkey hash20B
- pow_difficulty 1B 0 = 用密钥解锁;>0 = 任何人用 PoW 解锁0 = key unlock; >0 = anyone unlocks with PoW — (15)
- pubkey hash 20B blake160(schnorr x-only 公钥)blake160(schnorr x-only pubkey) = blake160(event.pubkey)= blake160(event.pubkey) (26)
限制Constraints
- args:: 恰为 21 字节exactly 21 bytes (15)
- witness:: lock 存在lock present (27 / 2)
- event:: 合法 JSON 事件valid JSON event (21 / 20)
- tags:: 含 ["ckb_sighash_all", hex(sighash_all)];sighash_all 与 secp256k1_blake160 相同(witness.lock 置 0)contains ["ckb_sighash_all", hex(sighash_all)]; sighash_all as in secp256k1_blake160 (witness.lock zeroed) (11)
- id = sha256([0,pubkey,created_at,kind,tags,content])= sha256([0,pubkey,created_at,kind,tags,content]) (17)
- kind / content:: kind = 23334,content = 固定提示文本kind = 23334, content = fixed notice (12 / 13)
- sig:: schnorr 签名有效valid schnorr signature (18 / 19 / 16)
BPoW 解锁(pow_difficulty > 0)PoW unlock (pow_difficulty > 0)
Inputs 输入Inputs
inputCell{ lock: NOSTR_LOCK(difficulty ‖ 0×20) }
witnessevent.tags ∋ ["nonce", n, "difficulty"]
➜
Outputs 输出Outputs
outputs任意any
限制Constraints
- nonce:: 存在 3 元素的 nonce tag,且目标难度 = args[0]a 3-element nonce tag exists and target = args[0] (25 / 23)
- id:: 前导零位 ≥ difficultyleading zero bits ≥ difficulty (24)
- args:: args[1..21] 必须全 0args[1..21] must be all zero (22)
部署与来源Deployments & source 未核验unverified
源码source nervosnetwork/nostr-binding@eef134e0 · contracts/nostr-lock/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)
0x2effea19ff…15e59795: listed in deployment/mainnet/nostr-lock-script/migrations/2024-07-18-010412.json; listed in deployment/mainnet/nostr-lock-script/migrations/2026-01-14-051715.json; listed in deployment/testnet/nostr-lock-script/migrations/2024-07-03-014310.json
0x2effea19ff…15e59795: listed in deployment/mainnet/nostr-lock-script/migrations/2024-07-18-010412.json; listed in deployment/mainnet/nostr-lock-script/migrations/2026-01-14-051715.json; listed in deployment/testnet/nostr-lock-script/migrations/2024-07-03-014310.json
| 网络network | code_hash | cell_dep | type_id args | 数据哈希data hash | 部署交易deploy tx |
|---|---|---|---|---|---|
| mainnet | 0x641a89ad2f77721b803cd50d01351c1f308444072d5fa20088567196c0574c68 type | 0x99b116dd1e…11be7327:0 code | 0xfad8cb75eb…29e192f8 | 0x2effea19ff…15e59795 | 0x99b116dd1e…11be7327 #18373370 |
| testnet | 0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5 type | 0xa2a434dcdb…d7c01d68:0 code | 0x8dc56c6f35…2c50e0aa | 0x2effea19ff…15e59795 | 0xa2a434dcdb…d7c01d68 #13783286 |
链上数据核对于 on-chain data checked 2026-10-20
错误码:1–4 系统 · 10 Unknown · 11 SighashAllMismatched · 12 KindMismatched · 13 ContentMismatched · 14 GenerateSighashAll · 15 InvalidScriptArgs · 16 InvalidPublicKey · 17 InvalidEventId · 18 ValidationFail · 19 InvalidSignatureFormat · 20 UnknownKey · 21 Json · 22 PubkeyNotEmpty · 23 WrongTargetDifficulty · 24 PoWDifficulty · 25 NonceNotFound · 26 PubkeyNotFound · 27 WrongWitnessArgsError codes: 1–4 syscall · 10 Unknown · 11 SighashAllMismatched · 12 KindMismatched · 13 ContentMismatched · 14 GenerateSighashAll · 15 InvalidScriptArgs · 16 InvalidPublicKey · 17 InvalidEventId · 18 ValidationFail · 19 InvalidSignatureFormat · 20 UnknownKey · 21 Json · 22 PubkeyNotEmpty · 23 WrongTargetDifficulty · 24 PoWDifficulty · 25 NonceNotFound · 26 PubkeyNotFound · 27 WrongWitnessArgs
固定 content:"Signing a CKB transaction\n\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\n"Fixed content: "Signing a CKB transaction\n\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\n"
固定 content:"Signing a CKB transaction\n\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\n"Fixed content: "Signing a CKB transaction\n\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\n"