Skip to content

Add SHA-256 audit test vector for canonicalization protocol#17

Merged
GsCommand merged 1 commit into
mainfrom
claude/audit-commandlayer-protocol-7kpEB
May 14, 2026
Merged

Add SHA-256 audit test vector for canonicalization protocol#17
GsCommand merged 1 commit into
mainfrom
claude/audit-commandlayer-protocol-7kpEB

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Summary

This PR adds a mandatory audit test vector to the canonicalization module to support protocol-level verification. It includes SHA-256 digest validation tests and improves test vector documentation with concrete hash values.

Key Changes

  • Added audit protocol test vector to CANONICAL_TEST_VECTORS with a SHA-256 digest field for the canonical form of {"verb":"verify","family":"trust","version":"1.0.0"}
  • Implemented two new test cases in canonicalize.test.ts:
    • Direct SHA-256 validation against the known protocol digest
    • Cross-check that runtime-computed SHA-256 matches the exported test vector constant
  • Improved test vector readability by replacing Unicode escape sequences with actual Unicode characters (e.g., \u4e16\u754c世界)
  • Made ethers a peer dependency (optional) instead of a direct dependency to reduce bundle size for consumers who don't need it

Implementation Details

The audit test vector locks the canonicalization algorithm to a concrete byte-level output. The SHA-256 digest (3c3e2e6f63b02c1dc4d0dc0f6429bcef5fe27f11059c856218a52a4f43f90e44) serves as a protocol-level invariant—if canonicalization changes, this test will fail and signal that the protocol version must be bumped.

The test includes detailed comments explaining the critical path requirement and the purpose of the audit vector in the protocol verification flow.

https://claude.ai/code/session_016igMwkFir2FkLQCHL6a34z

Protocol audit fixes:

1. src/canonicalize.ts — Add mandatory audit test vector
   {"verb":"verify","family":"trust","version":"1.0.0"} with expected
   canonical form and its SHA-256 digest to CANONICAL_TEST_VECTORS.
   The audit protocol requires this known-vector to be computable and
   tested. The canonical form is {"family":"trust","verb":"verify","version":"1.0.0"}
   and its SHA-256 is 3c3e2e6f63b02c1dc4d0dc0f6429bcef5fe27f11059c856218a52a4f43f90e44.

2. test/canonicalize.test.ts — Add describe block that computes
   SHA-256(canonicalize(audit_vector)) and asserts it equals the known
   digest, enforcing determinism at the hash level.

3. package.json — Move `ethers` from dependencies to peerDependencies.
   ethers is not imported by any src/ file; consumers supply their own
   EnsProvider instance. Listing it as a production dependency forces
   an unnecessary install on all consumers and misrepresents the API
   contract. peerDependencies correctly documents that ethers >=6 is
   required from the consumer's environment.
@GsCommand GsCommand merged commit 3f8237c into main May 14, 2026
1 of 3 checks passed
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.

1 participant