Todas as lições · CCC (TypeScript SDK) · Começa aqui · Glossário
Re-zero the witness lock before recomputing the sign message with getSignHashInfoPráticoReproduzida
Reproduzida · Verificação: em parte certa · Verificada em 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.
Porque importa: 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.
Padrão
verifyTx.setWitnessArgs(0, { lock: ccc.hexFrom(new Uint8Array(WITNESS_LOCK_LEN)) });Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- salmansarwarr/Tranfr:
sdk/tests/client.test.ts
Reproduzida por um teste
Um teste público corre o que esta lição diz em @ckb-ccc/core 1.23.1, sem nó. Qualquer pessoa o pode correr.
tests/ccc/rezero-witness-before-verifying.test.mjs
- Conceitos
- Witnesses and signatures, Testing and devnet
- Evidência
- Reproduzida: reproduzida por um teste público
- Vista pela primeira vez
- 2026-10-14
- Última mudança
- 2026-10-14
- Última verificação
- 2026-11-19
- Verificação contra o commit
- em parte certa: um núcleo verdadeiro, com uma parte solta ou demasiado larga
Fontes (1)
- 2026-10-14 · salmansarwarr/Tranfr · mais deste projeto
Mais sobre 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
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
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.