Implement Encoding for Int serde support#1286
Open
tob-joe wants to merge 2 commits into
Open
Conversation
Int has serde Serialize and Deserialize impls behind the serde feature, but both impls require Int<LIMBS>: Encoding. Since Int did not implement Encoding, the serde impls were not usable for fixed-width signed integer aliases. Implement Encoding by delegating to the wrapped Uint representation, which preserves the existing two's-complement byte layout. Add a serde trait coverage matrix for the crate's explicit serde impl surfaces, and exercise I256 deserialization through serdect without adding a concrete serializer dependency. Co-authored-by: GPT 5.5 <gpt-5.5@openai.com>
Apply rustfmt to the new serde integration test. Co-authored-by: GPT 5.5 <gpt-5.5@openai.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1286 +/- ##
==========================================
+ Coverage 91.01% 91.10% +0.09%
==========================================
Files 189 189
Lines 22160 22172 +12
==========================================
+ Hits 20169 20200 +31
+ Misses 1991 1972 -19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement
EncodingforInt<LIMBS>.Intalready hasSerializeandDeserializeimpls behind theserdefeature, but those impls requireInt<LIMBS>: Encoding. SinceIntdid not implementEncoding, the serde impls were not reachable for signed fixed-width integer aliases likeI256.This implements
EncodingforInt<LIMBS>by delegating to the wrappedUint<LIMBS>representation. That preserves the existing two's-complement byte layout used by signed integers.The tests add a dedicated serde trait coverage matrix for the crate's explicit serde impl surfaces, including representative fixed-width unsigned and signed integers, invariant wrappers, arithmetic wrappers, boxed integers under
alloc, andConstMontyForm. The tests also exerciseI256deserialization throughserdectwithout adding a concrete serializer dev-dependency.This work was completed by Trail of Bits as part of the Patch The Planet project in collaboration with OpenAI. The vulnerability was identified primarily by the Codex coding agent, and manually reviewed before submission.