Skip to content

Commit

Permalink
Fix seal length issue
Browse files Browse the repository at this point in the history
  • Loading branch information
XuJiandong committed Jan 29, 2024
1 parent 3a47156 commit 4a19a6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions c/cobuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ static int check_type_script_existing(mol2_cursor_t message) {

int ckb_parse_message(uint8_t *signing_message_hash, mol2_cursor_t *seal) {
int err = ERROR_GENERAL;
uint32_t prefix_length = 1 + MOL2_NUM_T_SIZE;
uint8_t prefix[1 + MOL2_NUM_T_SIZE] = {0};

err = ckb_check_others_in_group();
// tested by test_non_empty_witness
CHECK(err);
Expand All @@ -563,15 +566,13 @@ int ckb_parse_message(uint8_t *signing_message_hash, mol2_cursor_t *seal) {
print_cursor("seal", *seal);

// support more message calculation flows base on the first byte of seal
uint8_t message_calculation_flow = 0;
uint32_t flow_length = 1;
uint32_t len = mol2_read_at(seal, &message_calculation_flow, flow_length);
CHECK2(len == flow_length, ERROR_SEAL);
mol2_add_offset(seal, flow_length);
mol2_sub_size(seal, flow_length);
uint32_t len = mol2_read_at(seal, prefix, prefix_length);
CHECK2(len == prefix_length, ERROR_SEAL);
mol2_add_offset(seal, prefix_length);
mol2_sub_size(seal, prefix_length);
mol2_validate(seal);

if (message_calculation_flow == MessageCalculationFlowBlake2b) {
if (prefix[MOL2_NUM_T_SIZE] == MessageCalculationFlowBlake2b) {
err = ckb_generate_signing_message_hash(has_message, message,
signing_message_hash);
CHECK(err);
Expand Down
2 changes: 1 addition & 1 deletion c/omni_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ int parse_witness_lock(WitnessLockType *witness_lock, mol2_cursor_t *seal) {
mol2_cursor_t mol_lock_bytes = {0};

if (seal) {
mol_lock_bytes = convert_to_rawbytes(seal);
mol_lock_bytes = *seal;
witness_existing = true;
} else {
WitnessArgsType witness_args;
Expand Down

0 comments on commit 4a19a6a

Please sign in to comment.