Skip to content

feat(canon): canonicalization core (VOKF-1 / S1) - #1

Merged
aggre merged 1 commit into
mainfrom
s1/canon
Jun 15, 2026
Merged

feat(canon): canonicalization core (VOKF-1 / S1)#1
aggre merged 1 commit into
mainfrom
s1/canon

Conversation

@yumemayu

Copy link
Copy Markdown
Member

S1 — @verifiable-okf/canon (VOKF-1)

The shared, version-pinned canonicalization core (SPEC §5/§6). Signer and verifier will both depend on this; any divergence breaks every signature, so it is tested hardest.

Implements

  • §5 canonical body: UTF-8 validation (reject invalid), CRLF/CR→LF, per-line trailing space/tab strip, exactly one trailing LF → content_hash = sha256: + lowercase hex.
  • frontmatter split: byte-boundary at the closing --- (§5 step 1); YAML→JSON data model (core schema → RFC 3339 timestamps stay strings).
  • §6 JCS: RFC 8785 via canonicalize.
  • §6 signing payload: JCS(frontmatter*) ‖ 0x0A ‖ canonical_body, removing only provenance.signature.value.
  • canonicalizeConcept() convenience + re-exports.

DoD(VOKF-1)

  • RFC 8785 ベクタ通過(key順・数値・エスケープ)
  • 同一入力→バイト一致(CRLF↔LF・末尾空白・frontmatterキー順入替で同一 content_hash & signing payload)
  • 不正UTF-8 を reject
  • versioned package(@verifiable-okf/canon@0.1.0)として signer/verifier が依存可能
  • pnpm build / pnpm test green(28 tests)

S2(signer+schema+DID)。本PRマージ後に着手します。

🤖 Generated with Claude Code

The shared, version-pinned canonicalization library consumed identically
by signer and verifier. Any divergence here breaks every signature, so
this package is tested hardest.

- body.ts: canonical body (§5) — UTF-8 validation, CRLF/CR→LF, per-line
  trailing whitespace strip, exactly one trailing LF; content_hash.
- frontmatter.ts: byte-boundary split at the closing `---` (§5 step 1)
  and YAML→JSON-data-model parse (core schema keeps timestamps as RFC
  3339 strings; Date defensively coerced).
- jcs.ts: RFC 8785 canonicalization (via `canonicalize`, re-typed).
- payload.ts: signing payload = JCS(frontmatter*) || 0x0A || canonical
  body, removing only provenance.signature.value.
- index.ts: canonicalizeConcept() convenience + re-exports.

Tests (28): RFC 8785 key-order/number/escape vectors; §5 body cases;
invalid-UTF-8 rejection; CRLF/trailing-ws hash-identical; key-reorder →
identical JCS & signing payload; signature.value does not affect payload.
build + test green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aggre
aggre merged commit b9e34c4 into main Jun 15, 2026
1 check passed
@aggre
aggre deleted the s1/canon branch June 15, 2026 21:50
@yumemayu yumemayu mentioned this pull request Jun 15, 2026
6 tasks
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.

2 participants