/**
 * SHA-256 hashing layer on top of canonical.ts string payloads.
 *
 * Computes record IDs (content-addressed hex digests) and
 * signature payloads (raw UTF-8 bytes) for trust records.
 *
 * @module domain/trust/TrustCanonical
 * @see docs/specs/TRUST_CRYPTO_ALGORITHM.md
 */
import { recordIdPayload, signaturePayload } from "./canonical.js";
import defaultCrypto from "../utils/defaultCrypto.js";
import { textEncode } from "../utils/bytes.js";
/**
 * Computes the record ID (SHA-256 hex digest) for a trust record.
 */
async function computeRecordId(record, deps = {}) {
    const c = deps.crypto ?? defaultCrypto;
    return await c.hash('sha256', recordIdPayload(record));
}
/**
 * Computes the signature payload as UTF-8 bytes.
 */
function computeSignaturePayload(record) {
    return textEncode(signaturePayload(record));
}
/**
 * Verifies that a record's recordId matches its content.
 */
async function verifyRecordId(record, deps = {}) {
    return record['recordId'] === await computeRecordId(record, deps);
}
export { computeRecordId, computeSignaturePayload, verifyRecordId };
