Skip to content
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

fix: Handle serialization and deserialization of bigint/bytestring when length > 64 #398

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

satran004
Copy link
Member

@satran004 satran004 commented May 22, 2024

Issues:

  1. PlutusData.deserialize() doesn't handle BigInteger properly when it is encoded as a ByteString. Instead, it decodes BigInteger as BytesPlutusData.

BigInteger can also be represented as bytes.

big_int = int / big_uint / big_nint
big_uint = #6.2(bounded_bytes)
big_nint = #6.3(bounded_bytes)
  1. All bytestring must be chunked up to 64 bytes (Wrong Data <=> CBOR encoding/decoding #399)

Fix

  • Read Tag of the ByteString to identify if it's a positive and negative number
  • Custom encoder for chunked bytestring

Example (Datum):

d8798b581c217a7bf7a6494a0165ae2cb77aabeadb865d33d5be5f9f57b9b0e8f6581c276ba8bb7fe700d0d21b7da11edeb650729efe0b1595af0e643e31844b4e656f6e50756e6b3033311a3b9aca005563687447785a454339663038514d504b6970773073d87980d87980c2410040c241005820dee0b6f2b41b1a75244ec7b83c77c45d5cda5ad4ff3a4964340bb6089d5256e5

@satran004
Copy link
Member Author

Fyi, @nau

Removed encodeAsByteString()

@satran004 satran004 requested a review from Sotatek-HuyLe3a May 22, 2024 13:33
@satran004
Copy link
Member Author

To fix: #399

@satran004 satran004 changed the title fix: Handle serialization and deserialization of bigint as ByteString fix: Handle serialization and deserialization of bigint/bytestring when length > 64 Aug 1, 2024
@satran004 satran004 merged commit d338b9b into master Aug 1, 2024
4 checks passed
@satran004 satran004 deleted the fix/bigint_as_bytestring branch August 1, 2024 12:38
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.

2 participants