CBOR: bignum payloads bypass bounded_bytes chunking above 64 bytes
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend-api-design
Research direction
Start in packages/evolution/src/CBOR.ts at encodeUintSync, encodeNintSync, and the existing BoundedBytes and encodeBoundedBytesSync paths; review the CDDL notes in packages/evolution/src/Data.ts. Run the existing CBOR or datum-hash tests, then add regression coverage for the positive and negative over-64-byte cases. Done means those payloads use chunked strings while the 9-byte case remains definite and the expected hashes match.
Written by the indexing model from the issue text.
Description
Summary
Plutus Data integers whose magnitude exceeds 64 bytes (|value| >= 2^512) are encoded as a single
definite-length byte string under CBOR tag 2 or 3. The Conway CDDL, quoted in this repo at
Data.ts L165-167, defines a bignum payload as bounded_bytes = bytes .size (0..64), so a magnitude
of 65 bytes or more must be an indefinite-length byte string split into chunks of at most 64 bytes.
The SDK already applies that rule to Data byte-string leaves, so the same file chunks a 65-byte
bytearray and does not chunk a 65-byte bignum. The result is Plutus data that violates the grammar,
and a datum hash that differs from the one computed over the chunked form.
Affected
packages/evolution/src/CBOR.ts
- encodeUintSync (L985-991): passes
bigintToBytes(value)straight toencodeTagSync(2, ...)(L989-990) - encodeNintSync (L1028-1035): same for tag 3 (L1033-1034)
- contrast: the
BoundedBytesnode (L1231-1239) routes throughencodeBoundedBytesSync(L1109),
which chunks at 64 bytes and is applied unconditionally
packages/evolution/src/Data.ts
- CDDL for big_uint / big_nint / bounded_bytes documented at L165-167
Fix
Wrap the bignum magnitude in the existing BoundedBytes node so the chunking rule applies, mirroring
the fix PR #160 made for byte-string leaves:
return encodeTagSync(2, BoundedBytes.make(bigintToBytes(value)), options, fmt)
and the tag 3 analogue in encodeNintSync. Alternatively have encodeTagSync treat tag 2 and 3
payloads as bounded bytes. Note #395 edits the same two lines of encodeNintSync for the negative
bignum boundary, so the two changes will conflict.
Regression test
- given:
Data.int(2n ** 512n) - before fix: encodes to
c25841...(single 65-byte definite string);toDatumHashis9b2838f7... - after fix: encodes to
c25f5840...4100ff;toDatumHashis
939bb1f51ea88f86a070fefb5c1185d10b4d10a13e3b7db24aac02220c18adab - negative analogue:
Data.int(-(2n ** 520n))chunks under tag 3 rather than emittingc35841... - unchanged: a 9-byte bignum such as
2n ** 64nstays definite, so only the over-64-byte case moves
Must FAIL on main today and PASS after the fix.
Reference
Same defect class as #158, which covered Data byte-string leaves and was fixed in PR #160. The
integer path was never routed through BoundedBytes.
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 30
- Avg merge
- 13h
- Merged PRs (30d)
- 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IntersectMBO/evolution-sdk
-
dependencies good first issue
Difficulty 1/5 Under an hour Newbie friendliness 93/100
IntersectMBO/evolution-sdk#541 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
IntersectMBO/evolution-sdk#518 ·
-
enhancement external-review
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
IntersectMBO/evolution-sdk#456 · 1 comment ·
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
IntersectMBO/evolution-sdk#398 ·
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
IntersectMBO/evolution-sdk#396 ·
All issues in IntersectMBO/evolution-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·