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
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.
- salmansarwarr/Tranfr:
sdk/tests/client.test.ts
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)
- 2026-10-14 · salmansarwarr/Tranfr · more from this project
More about CCC (TypeScript SDK)
- Headless EIP-6963 test wallet for driving the CCC connector in Playwright
- CCC custom client scripts must include AnyoneCanPay for SignerCkbPrivateKey
- Hand-rolled Script hash: hash_type byte mapping and molecule offsets, checked against CCC
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.