Skip to content

fix: encoding and decoding of NativeScript #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2025

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Jul 5, 2025

There were 2 problems here:

  1. The encoder would produce invalid CBOR in for the N-of-K variant of NativeScript which is encoded as an array of 3 elements, but marked as containing 2.

  2. The decoder doesn't consume all the bytes it should; thus succeeding to decode partial / incomplete (and thus invalid) CBOR sequences. Note that while fixed in this particular instance for NativeScript, the problem is recurring across pretty much all list-like decoders within Pallas and should probably be subject to a larger overhaul.

  There were 2 problems here:

  1. The encoder would produce invalid CBOR in for the N-of-K variant of NativeScript which is encoded as an array of 3 elements, but marked as containing 2.

  2. The decoder doesn't consume all the bytes it should; thus succeeding to decode partial / incomplete (and thus invalid) CBOR sequences. Note that while fixed in this particular instance for NativeScript, the problem is recurring across pretty much all list-like decoders within Pallas and should probably be subject to a larger overhaul.
e.encode_with(2, ctx)?;
e.encode_with(v, ctx)?;
}
NativeScript::ScriptNOfK(a, b) => {
e.array(3)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️

let next = d.datatype()?;
if next != minicbor::data::Type::Break {
return Err(minicbor::decode::Error::type_mismatch(next));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️

@scarmuega scarmuega merged commit d354b43 into txpipe:lts/v0 Jul 12, 2025
@github-project-automation github-project-automation bot moved this to ✅ Done in Development Jul 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants