All lessons · Rust scripts and ckb-std · Start here · Glossary
Type Script group membership and group witness index derived from the full script hashWorkingFrom one fix
From one fix · Check: right · Checked 2026-11-19
When locating a Type Script group off chain, match input and output cells by the blake2b hash of the complete Script (code_hash, hash_type, args), never by code hash alone. By convention (RFC 22 for lock groups), a group's witness sits at the transaction index of its first input, or of its first output if the group has no inputs. CKB does not enforce this: the script picks which witness it reads, and which WitnessArgs field (input_type or output_type) holds the data is the protocol's own choice.
Why it matters: If cells are matched by code hash alone, cells whose Type Scripts differ only in args or hash_type land in the group, so the off chain tool computes the wrong group members, cardinality and witness index compared with what the CKB VM executes.
Pattern
output.type_script.as_ref().is_some_and(|script| hash(script.bytes) == selected_hash)Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- CellScript-Labs/CellScript:
tests/frozen_interface.rs,tests/policy_artifact_checker.rs
- Concepts
- Witnesses and signatures, Transaction building and fees
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-10-09
- Last changed
- 2026-10-09
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (1)
- 2026-10-09 · CellScript-Labs/CellScript · more from this project
More about Rust scripts and ckb-std
- Place a script's raw witness at the index of the input it validates
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
- Check that a derived successor type args match the spent cell's type args
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Type Script group membership and group witness index derived from the full script hash", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/type-script-group-membership-and-group-witness-index-derived, CC BY 4.0, last changed 2026-10-09.