All lessons · CCC (TypeScript SDK) · Start here · Glossary
Sign each lock group with its own placeholder length and witness shapeWorkingSeen again
Seen again · Check: right · Checked 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.
Why it matters: 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.
Pattern
await transaction.prepareSighashAllWitness(script, witnessLockLength(kind), client);Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- officialcmg/ckb-keyway:
tests/general-signing-postgres.test.ts,tests/transaction-policy.test.ts
- Concepts
- Witnesses and signatures, Transaction building and fees
- Evidence
- Seen again: seen in two or more projects
- First seen
- 2026-10-23
- Last changed
- 2026-10-23
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (2)
- 2026-10-23 · officialcmg/ckb-keyway · more from this project
- 2026-10-14 · salmansarwarr/Tranfr · more from this project
More about CCC (TypeScript SDK)
- Reserve co-signer witness space before completeFeeBy in multi-signer CCC transactions
- completeFeeBy adds change instead of shrinking outputs, breaking output bound proofs
- Plain CKB transfer with a CCC signer
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
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.