CKB Pulse

全部经验 · CCC (TypeScript SDK) · 从这里开始 · 术语表

Sign each lock group with its own placeholder length and witness shape实践再次出现

再次出现 · 核对结果:正确 · 核对于 2026-11-19

When one key controls several lock groups in a CCC transaction, call transaction.prepareSighashAllWitness(script, len, client) for each group with the final witness lock length of that lock, then getSignHashInfo and sign that group's own digest. In KeyWay's case the length is 65 bytes for secp256k1 and 85 bytes for an Omnilock owner witness holding one 65-byte signature; write the bare signature for secp256k1 and wrap it in the OmniLockWitnessLock molecule for Omnilock. A custom lock with its own witness layout needs its own length the same way.

为什么重要: If a group's digest is computed over a placeholder of the wrong length, or one group's signature is reused for another lock, the witness the lock script hashes on chain differs from what was signed and verification fails.

代码模式

推荐
await transaction.prepareSighashAllWitness(script, witnessLockLength(kind), client);

摘自提交,已缩短。

同一提交中改动了测试

它与修复在一起,我们没有运行它。

概念
Witnesses and signatures, Transaction building and fees
证据
再次出现: 在两个或以上项目中出现
首次出现
2026-10-23
最近改动
2026-10-23
最近核对
2026-11-19
对照提交的核对结果
正确:这条经验出自该提交,并且在今天的代码中仍然成立

来源(2)

更多关于CCC (TypeScript SDK)

查看此主题的全部 33 条

你维护这条经验的来源项目吗?请确认或纠正

引用这条经验
LusoCryptoLabs, "Sign each lock group with its own placeholder length and witness shape", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/sign-each-lock-group-with-its-own-placeholder-length-and-wit, CC BY 4.0, last changed 2026-10-23.

取自公开提交,并对照每条经验的来源提交和项目当前代码做了核对。使用前请先读来源。 文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 想修改或撤下某条经验?请提交 issue。