CKB Pulse

All lessons · Rust scripts and ckb-std · Start here · Glossary

Use raw_data(), not as_slice(), when parsing a packed::Bytes witnessWorkingChecked by the owner

Checked by the owner · Check: right · Checked 2026-11-19

A transaction witness in ckb_types is a molecule packed::Bytes, so as_slice() returns the 4 byte length header followed by the content, while raw_data() returns only the content (here a serialized WitnessArgs). A check that compares a witness to the secp256k1 sighash placeholder WitnessArgs (lock of 65 zero bytes) must use witness.raw_data() (or unpack()), otherwise it is silently never true. Fiber's funding witness merge never recognized placeholders until it switched to raw_data(), so a peer's placeholder could be kept in place of a real signature.

Why it matters: A placeholder check run over as_slice() includes the 4 byte molecule length header, so it never matches; Fiber's funding witness merge therefore failed to swap its own placeholder for the peer's real signature, which the new test asserts.

Pattern

Prefer
is_secp_sighash_placeholder_witness(&witness.raw_data())

Taken from the commit, shortened.

A test changed in the same commit

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

Concepts
Data encoding (molecule, hex, bigints), Witnesses and signatures
Evidence
Checked by the owner: checked by the owner of the project it came from, who is also the publisher of these lessons
First seen
2026-10-29
Last changed
2026-10-29
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 Rust scripts and ckb-std

All 35 in this topic

Checked by @LusoCryptoLabs (owner of the project), 2026-11-19.

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Use raw_data(), not as_slice(), when parsing a packed::Bytes witness", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/use-raw-data-not-as-slice-when-parsing-a-packed-bytes-witnes, CC BY 4.0, last changed 2026-10-29.

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.