Repository navigation
Receipt comment: canonical JSON is the JS profile, not Python json.dumps - #19
Merged
Merged
Conversation
Our docs said the signed bytes are "the same as Python's json.dumps(sort_keys=True,
separators=(",", ":"), ensure_ascii=True)". That only holds for ASCII keys and
integers: Python writes 1.0 and 1e-06 where JSON.stringify writes 1 and
0.000001, and sorts U+E000 before U+10000 (code points) where the signer sorts
by UTF-16 code units. Paid answers carry decimals (prices, liquidity), so a
Python verifier following the old text could reject a genuine receipt. TAT
Risk surfaced this while pinning the profile for their signed evidence.
The normative profile is named js-json-stringify-sorted-utf16-ascii-v1: keys
by UTF-16 code units, compact, every code unit from U+007F up as lowercase
\uXXXX, numbers as JSON.stringify writes them, UTF-8 bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsD5haPKxeWjYmErHzvU48
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.
What
The comment in
src/receipt.tsclaimed byte equality with Pythonjson.dumps. That's only true for ASCII keys and integers. The comment now names the profile (js-json-stringify-sorted-utf16-ascii-v1) and points to the Python equivalent in presign-guard (examples/canonical.py).It's a comment-only change: no behaviour change and no release needed. Goes together with Fizzl13/presign-guard#49.
Tests
41/41 pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TsD5haPKxeWjYmErHzvU48
Generated by Claude Code