test(crypto): cross-SDK canonical JSON + signature parity#6
Merged
Conversation
Adds `canonical_stringify()` as a public helper on CryptoUtils so both SDKs can produce byte-identical canonical JSON for the same input. The existing `_stringify_deterministic` is kept as a thin alias for backward compatibility. Adds tests/test_canonical.py with: - Shared test vectors (byte-identical to TS SDK) - Cross-SDK fixture verification: reads canonical-sig.json produced by the TS SDK and confirms the signature verifies in Python - Signature parity check: Python signs with the same seed and must produce byte-identical signature bytes to TS (proves canonical drift would surface immediately) This closes the signature mismatch between TS and Python SDKs.
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.
Context
Paired with bsp-sdk-typescript#12. The TS SDK was using
JSON.stringify(sortedObj)while Python usesjson.dumps(..., separators=(",", ":"))— risk of silent signature drift between SDKs.Changes
CryptoUtils.canonical_stringify()as a public helper (mirror of the TS SDK'scanonicalStringify). Keep_stringify_deterministicas an alias for backward compatibility.tests/test_canonical.py:bsp-sdk-typescript/tests/canonical-stringify.test.ts.canonical-sig.json) and verifies the signature in Python.Test plan
pytest tests/— 70 tests pass locally (including all new canonical tests and cross-SDK fixture verification)Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com