Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

CBOR: bignum payloads bypass bounded_bytes chunking above 64 bytes

已关闭 适合新手
#530 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
86/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

从 packages/evolution/src/CBOR.ts 中的 encodeUintSync、encodeNintSync 以及现有的 BoundedBytes 和 encodeBoundedBytesSync 路径开始;检查 packages/evolution/src/Data.ts 中的 CDDL 注释。运行现有的 CBOR 或 datum-hash 测试,然后为超过 64 字节的正数和负数情况添加回归覆盖。完成的标准是这些 payload 使用 chunked strings,同时 9 字节的情况仍为 definite,并且预期的哈希值匹配。

由索引模型根据 Issue 内容生成。

描述

bug external-review

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 to encodeTagSync(2, ...) (L989-990)
  • encodeNintSync (L1028-1035): same for tag 3 (L1033-1034)
  • contrast: the BoundedBytes node (L1231-1239) routes through encodeBoundedBytesSync (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); toDatumHash is 9b2838f7...
  • after fix: encodes to c25f5840...4100ff; toDatumHash is
    939bb1f51ea88f86a070fefb5c1185d10b4d10a13e3b7db24aac02220c18adab
  • negative analogue: Data.int(-(2n ** 520n)) chunks under tag 3 rather than emitting c35841...
  • unchanged: a 9-byte bignum such as 2n ** 64n stays 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.

主要语言
TypeScript
星标
22
派生
35
平均合并
19 小时 9 分钟
30 天内合并 PR
65

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IntersectMBO/evolution-sdk 的其他 Issue

查看 IntersectMBO/evolution-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。