CKB Pulse

All lessons · CCC (TypeScript SDK) · Start here · Glossary

Re-zero the witness lock before recomputing the sign message with getSignHashInfoWorkingReproduced

Reproduced · Check: partly right · Checked 2026-11-19

CCC's Transaction.getSignHashInfo hashes whatever is currently in the witness, so after a signature is filled in it no longer gives the signed message. To verify a signature (for example with ccc.recoverMessageSecp256k1), clone the tx and reset witness 0's lock to the zero placeholder of the same length that was used at signing time.

Why it matters: If you recompute the sign hash on the signed transaction, the hash covers the signature itself, so recovery returns the wrong public key and a valid signature looks invalid.

Pattern

Prefer
verifyTx.setWitnessArgs(0, { lock: ccc.hexFrom(new Uint8Array(WITNESS_LOCK_LEN)) });

Taken from the commit, shortened.

A test changed in the same commit

It sits next to the fix. We did not run it.

Reproduced by a test

A public test runs what this lesson says on @ckb-ccc/core 1.23.1, with no node. Anyone can run it.

tests/ccc/rezero-witness-before-verifying.test.mjs

Concepts
Witnesses and signatures, Testing and devnet
Evidence
Reproduced: reproduced by a public test
First seen
2026-10-14
Last changed
2026-10-14
Last checked
2026-11-19
Check against the commit
partly right: a true core, with a part that is loose or too wide

Sources (1)

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, "Re-zero the witness lock before recomputing the sign message with getSignHashInfo", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/re-zero-the-witness-lock-before-recomputing-the-sign-message, CC BY 4.0, last changed 2026-10-14.

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.