CKB Pulse
经验

CKB 学到了什么

从这里开始 · 术语表 · 自测 · 订阅

经验用英文撰写,请用英文搜索。

“Witnesses and signatures”

找到 48 条经验。 全部经验

第 4 页,共 4 页

Creation witness for an output type script goes in WitnessArgs.output_type实践来自一次修复

A type script that checks a newly created output can read its proof from WitnessArgs.output_type, but the script decides which witness to read: tactus-o1's state proof script loads absolute witness 0 (Source::Input, index 0), not a witness matched to the output index. If that witness is also the first witness of the secp lock group, put the proof in its output_type field next to the 65 byte lock placeholder, and it is covered by the lock signature because the sighash keeps the other WitnessArgs fields and zeroes only the lock.

#Witnesses and signatures · 来源(1) · 2026-10-10

Molecule table encoding of absent optional fields实践来自一次修复

A molecule table or dynvec (Script, CellOutput, WitnessArgs) is serialized as a u32 total size, then one u32 offset per field, then the fields. There is no separate count; readers derive it from the first offset. An absent Opt field takes zero bytes, so its offset equals the next offset, or the total size if it is last. A hand-rolled encoder that inserts a u32 count after the total size, as this commit's dyn_collection does, produces malformed molecule.

#Data encoding (molecule, hex, bigints) #Witnesses and signatures · 来源(1) · 2026-10-09

CKB blake160 is the first 20 bytes of the 32 byte ckbhash基础来自一次修复

CKB blake160, used for lock args and pubkey hashes, is the first 20 bytes of the 32 byte blake2b digest personalized with "ckb-default-hash". A blake2b hasher configured with a 20 byte output length gives a different value, because the digest length is part of blake2b's parameter block. Always hash to 32 bytes and then truncate.

#Data encoding (molecule, hex, bigints) #Witnesses and signatures · 来源(1) · 2026-10-09

Type Script group membership and group witness index derived from the full script hash实践来自一次修复

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.

#Witnesses and signatures #Transaction building and fees · 来源(1) · 2026-10-09

EVM owners may hold Omnilock lock args with auth flag 0x12, not only 0x01实践来自一次修复

When mapping an Ethereum address to the CKB lock scripts it controls, match Omnilock args 0x12 || addr20 || 0x00 (Ethereum displaying, used by CCC's EVM signer for new addresses) as well as 0x01 || addr20 || 0x00 and PW Lock args = addr20. Otherwise deposits held by CCC created EVM addresses are not recognised. The commit notes this is still pending confirmation in a wallet proof of concept.

#Witnesses and signatures #Login and authorization · 来源(1) · 2026-10-08

Verifying Neuron style signed messages against a secp256k1_blake160 lock实践来自一次修复

To verify a Neuron "Sign Message" signature, hash with CKB Blake2b over UTF-8("Nervos Message:" followed by the text), recover the compressed public key from the 65 byte r||s||v signature (v is 0 or 1, not 27/28), and accept the owner only if the lock has the exact code_hash and hash_type of the secp256k1_blake160 template and its args equal blake160 of the recovered key (comparing args alone is not enough). Neuron signs low-s; if you choose to also accept high-s, normalise s to n minus s and flip v before recovery, because some verify helpers (CCC's) reject high-s.

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-10-08

Reserve co-signer witness space before completeFeeBy in multi-signer CCC transactions实践已复现

When a CCC transaction has inputs locked by several secp256k1 signers but the fee is paid by one, call tx.prepareSighashAllWitness(coSignerLock, 65, client) for each co-signer before tx.completeFeeBy(payer, feeRate). Otherwise the fee is estimated without their signature witnesses and may come out short. Each co-signer must own at least one input to have a script group to sign.

#Transaction building and fees #Witnesses and signatures · 来源(1) · 2026-10-06

Porting the sighash_all signing message into a Rust lock script实践来自一次修复

To reproduce secp256k1_blake160_sighash_all's message in a ckb-std lock, hash with ckb blake2b: tx hash, then the first GroupInput witness parsed as WitnessArgs with its lock field zero filled (same length) and u64 LE length prefixed, then the other GroupInput witnesses, then every Source::Input witness at index >= the total input count (each length prefixed). The commit counts inputs by probing load_input_since until IndexOutOfBound.

#Witnesses and signatures · 来源(1) · 2026-09-29

ckb-cli needs --skip-check to sign and send transactions with custom locks实践来自一次修复

ckb-cli refuses transactions whose inputs or outputs use a lock it cannot classify (for example a custom type script based lock with 1 byte of args). `tx sign-inputs` then signs nothing, reporting `invalid lock script ... args.length` and leaving the signatures map and witness empty, and `tx send` refuses the file. Pass `--skip-check` to both sign-inputs and send; otherwise send fails with -2 ERROR_ENCODING because the secp lock reads an empty witness. Since this disables ckb-cli's own checks, run your own verifier on the signed file between sign-inputs and send.

Joined with toastmanAu/daowow@6f4cb48641.

#Witnesses and signatures #Transaction building and fees · 来源(2) · 2026-09-26

Place a script's raw witness at the index of the input it validates实践来自一次修复

When a type script reads its proof with load_witness(index, Source::Input) for its own input, the builder must put that raw witness at exactly that input's index. This commit puts the ledger cell at input 0 so its proof is witness 0, and pads the remaining witnesses with "0x" so witnesses.length equals inputs.length and a later funding/signing step appends rather than displaces it.

#Witnesses and signatures #Transaction building and fees · 来源(1) · 2026-09-25

Treat an absent WitnessArgs.lock as a load failure in ckb-std lock scripts实践来自一次修复

With ckb-std, `load_witness_args(0, Source::GroupInput)` can succeed while `WitnessArgs.lock` is an empty BytesOpt, so call `lock().to_opt()` and return an error on None before reading `raw_data()`. The commit's ckb-testtool tests check both a missing witness and a WitnessArgs with no lock field, and both fail with the load witness error.

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-09-25

ckb-cli tx init overwrites an existing tx file with an empty skeleton实践来自一次修复

`ckb-cli tx init --tx-file` creates a new empty transaction file and exits 0, so running it on a prepared transaction silently destroys that transaction. For a prebuilt transaction, write ckb-cli's tx-file wrapper ({transaction, multisig_configs, signatures}) yourself and go straight to `tx info` and `tx sign-inputs`.

#Transaction building and fees #Witnesses and signatures · 来源(1) · 2026-09-23

第 4 页,共 4 页

文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。