CKB Pulse
Lições

O que a CKB aprendeu

Começa aqui · Glossário · Testa-te · Feed

As lições estão escritas em inglês, por isso pesquise em inglês.

“Data encoding (molecule, hex, bigints)”

44 lições encontradas. Todas as lições

Página 4 de 4

CKB blake160 is the first 20 bytes of the 32 byte ckbhashBásicoDe uma correção

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 · Fontes (1) · 2026-10-09

Matching a Script code_hash to its code Cell by hash_typePráticoVista outra vez

To check that a Script points at a given deployed code Cell, compare its code_hash with ckb blake2b256 of the Cell's output data when hash_type is data, data1 or data2 (0, 2, 4), and with the hash of that Cell's Type Script when hash_type is type (1). A type selection needs the code Cell to actually carry a Type Script, and other hash_type values are rejected.

#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-10-09

Verifying Neuron style signed messages against a secp256k1_blake160 lockPráticoDe uma correção

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) · Fontes (2) · 2026-10-08

Parse raw CKB blocks with from_compatible_slice to accept BlockV1 extensionPráticoDe uma correção

Serialized CKB blocks may be BlockV1, which appends a consensus extension field after the Block molecule fields, so a strict packed::BlockReader::from_slice can reject them. This commit parses block bytes with ckb-gen-types 1.1.1 packed::BlockReader::from_compatible_slice, which accepts the extra field while still exposing header() and transactions().

#Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-10-07

Partial load of a cell's type Script header to match code_hash and hash_typeAvançadoDe uma correção

In a ckb-std script you can load a cell's type script into a fixed 49 byte buffer with syscalls::load_cell_by_field(..., CellField::Type), then compare code_hash at bytes 16..48 and hash_type at byte 48 of the molecule Script table, without allocating for args. A short buffer returns Err(SysError::LengthNotEnough) yet still fills the buffer, so treat that error like Ok, and treat ItemMissing as a cell with no type script.

#Data encoding (molecule, hex, bigints) #Cell deps and script lookup · Fontes (1) · 2026-10-07

Use JsonRpcTransformers.transactionFrom to serialize CCC transactions for CKB/Fiber RPCPráticoReproduzida

Serializing a ccc.Transaction with ccc.stringify keeps cached input fields (cellOutput, outputData) that a native RPC such as Fiber submitSignedFundingTx does not expect. JsonRpcTransformers.transactionFrom from @ckb-ccc/core/advanced emits snake_case hex with inputs containing only previous_output and since, while keeping the tx hash and witnesses unchanged, as the commit's tests check.

#Data encoding (molecule, hex, bigints) #Transaction building and fees · Fontes (1) · 2026-09-28

Treat an absent WitnessArgs.lock as a load failure in ckb-std lock scriptsPráticoDe uma correção

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) · Fontes (1) · 2026-09-25

Emit shannon u64 values as strings in cross-language test vectorsPráticoDe uma correção

When generating JSON test vectors in Rust for JavaScript decoders of CKB cell data, emit u64 fields (such as shannon amounts) as strings, because JSON numbers are IEEE-754 doubles and values above 2^53 would be silently rounded. Use distinct, non-zero field values so a decoder reading the wrong offset gives a visibly wrong result.

#Testing and devnet #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-09-18

Página 4 de 4

Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. JSON · Queres que uma lição seja mudada ou retirada? Abre um issue.