import {createHash} from 'node:crypto' /** Exact writer-profile v1 canonical bytes. Pure value codec; no trust/authority. */ export function canonical(value:unknown):string { return JSON.stringify(value,(_key,item:unknown)=>item&&typeof item==='object'&&!Array.isArray(item) ?Object.fromEntries(Object.entries(item).sort(([a],[b])=>ab?1:0)):item) } export const sha=(value:Uint8Array|string)=>createHash('sha256').update(value).digest('hex') export const bytes=(value:unknown)=>Buffer.from(canonical(value)+'\n','utf8')