Skip to content

Support indefinite length bytestring#1

Draft
qnikst wants to merge 1 commit intomasterfrom
infinite-bignum
Draft

Support indefinite length bytestring#1
qnikst wants to merge 1 commit intomasterfrom
infinite-bignum

Conversation

@qnikst
Copy link
Copy Markdown
Member

@qnikst qnikst commented Nov 10, 2025

We support indefinite length bytestring in the Read module.

@qnikst qnikst marked this pull request as draft November 10, 2025 09:39
@qnikst qnikst requested a review from Copilot November 10, 2025 09:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for CBOR big integers represented as indefinite-length byte strings, according to the CBOR specification. The implementation handles both positive (tag 2) and negative (tag 3) big integers when they use indefinite-length encoding (0x5f byte header).

  • Adds new data constructors BigUIntNeedBytes and BigNIntNeedBytes to handle indefinite-length byte string representation of big integers
  • Implements detection and processing of indefinite-length byte strings in big integer decoding paths (both fast and slow paths)
  • Rejects indefinite-length encoding in canonical mode as it is non-canonical

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@qnikst qnikst force-pushed the infinite-bignum branch 2 times, most recently from ab98109 to 4c1a0a3 Compare November 11, 2025 10:35
Copy link
Copy Markdown

@nc6 nc6 left a comment

Choose a reason for hiding this comment

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

Some name fixes and documentation can be tidied, but all looks good otherwise from my POV

We support indefinite length bytestring in the Read module.

In order to do it we add two extra variants for bigint deseralization,
both puts us to the slow-path to start consumption of the chunks.

This serialization is considered non-canonical thus canonical read
rejects is. While specification is silent about it, the cbor.me
implementation always converts bigit into a fixed size byte blob.

Fixes well-typed#263.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants