Skip to main content

Cross-Language Requirements

Cross-language conformance means independent implementations produce the same protocol-visible output from the same input. A one-byte difference in canonical output changes the resulting hash, signature digest, or Merkle root hash, so matching data models is not enough.

How Conformance Is Checked​

Every implementation runs the 15 required core suites, plus the suites of each claimed extension, and its outputs must match the expected vectors. pnpm run verify:cross-language also runs the TypeScript, Python, and Rust implementations on the same cases and compares every pair of results. Run Conformance Tests describes both commands and the interface for other implementations.

Common Divergences​

Standard JSON libraries do not produce ALX canonical bytes by default. Each row shows a value where Python's json.dumps defaults differ from the canonical output. The last row differs because ALX sorts keys by UTF-16 code units, and most languages sort strings by code point. The two orders disagree when one key contains a character above U+FFFF and another contains a character between U+E000 and U+FFFF.

ValueALX canonical bytesPython json.dumps default
1e-71e-71e-07
1.011.0
{"name": "café"}{"name":"café"}{"name": "caf\u00e9"}
{"a": 1, "b": [1, 2]}{"a":1,"b":[1,2]}{"a": 1, "b": [1, 2]}
Keys fi (U+FB01) and 😀 (U+1F600)😀 sorts firstWith sort_keys=True, fi sorts first

When to Run These Checks​

Run the vectors when porting ALX to another language, changing serialization code, upgrading cryptographic dependencies, or reviewing interoperability.

Ports must reproduce UTF-16 key sorting, JavaScript number rendering, the 128-level depth limit, and rejection of values outside the ALX value model.

Independent implementations must match:

  • UTF-8 output without Unicode normalization;
  • JavaScript UTF-16 code-unit object-key ordering;
  • the shortest round-trip decimal form of JavaScript JSON.stringify(), with integer-valued numbers written as integers;
  • rejection of undefined, including sparse array elements and object properties whose value is undefined; and
  • the 128-level depth limit and the other rejected types.