signet_content_hash
Compute SHA-256 hash of any JSON value after canonical serialization (RFC 8785 JCS) to ensure consistent content fingerprints for audit and accountability.
Instructions
Compute SHA-256 hash of canonical JSON (RFC 8785 JCS). Accepts any JSON value.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | JSON content to hash (object, array, string, number, boolean, or null) |
Implementation Reference
- Handler for the signet_content_hash tool. Calls contentHash() on the provided content argument and returns the hash as JSON.
case 'signet_content_hash': { const hash = contentHash(args?.content); return { content: [{ type: 'text', text: JSON.stringify({ hash }) }], }; } - packages/signet-mcp-tools/src/tools.ts:60-70 (registration)Registration of the signet_content_hash tool in the MCP ListTools handler, including its description and input schema requiring 'content' (any JSON value).
{ name: 'signet_content_hash', description: 'Compute a deterministic SHA-256 hash over canonical JSON using RFC 8785 JCS. Use this when you need a stable digest for receipt params, audit records, or comparing semantically identical JSON with different formatting or key order. Returns JSON {hash: string}.', inputSchema: { type: 'object' as const, properties: { content: { description: 'Any JSON value to hash: object, array, string, number, boolean, or null.' }, }, required: ['content'], }, }, - Input schema for signet_content_hash: takes a single required 'content' parameter (any JSON value).
{ name: 'signet_content_hash', description: 'Compute a deterministic SHA-256 hash over canonical JSON using RFC 8785 JCS. Use this when you need a stable digest for receipt params, audit records, or comparing semantically identical JSON with different formatting or key order. Returns JSON {hash: string}.', inputSchema: { type: 'object' as const, properties: { content: { description: 'Any JSON value to hash: object, array, string, number, boolean, or null.' }, }, required: ['content'], }, }, - The core contentHash() function that JSON-stringifies the input and delegates to the WASM implementation wasm_content_hash.
export function contentHash(value: unknown): string { return wasm_content_hash(JSON.stringify(value)); } - The WASM binding for content hashing (wasm_content_hash) that passes the JSON string to the Rust/WASM module and returns the hash string.
function wasm_content_hash(json) { let deferred3_0; let deferred3_1; try { const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.wasm_content_hash(ptr0, len0); var ptr2 = ret[0]; var len2 = ret[1]; if (ret[3]) { ptr2 = 0; len2 = 0; throw takeFromExternrefTable0(ret[2]); } deferred3_0 = ptr2; deferred3_1 = len2; return getStringFromWasm0(ptr2, len2); } finally { wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); } } exports.wasm_content_hash = wasm_content_hash;