CKB Pulse

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

Prefer
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.

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)

More about CCC (TypeScript SDK)

All 33 in this topic

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.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.