/**
 * ProvenanceSigner -- P4-AIR-03 (EU AI Act Art. 50)
 *
 * Signs AI-generated narrative report bodies with AI-provenance metadata.
 * Produces a signed envelope that auditors can independently verify to
 * confirm the report was generated by our runtime with the declared model.
 *
 * Signed envelope fields:
 *   - contentHash: SHA-256 of the narrative body string
 *   - art50Disclosure: EU AI Act Art. 50 metadata block
 *   - packBindings: compliance packs that were in force at generation time
 *   - chainHeadHash: audit-chain tip hash at generate time
 *   - signedAt: ISO-8601 timestamp
 *   - signature: HMAC-SHA256 over canonical JSON of all above fields
 *
 * Security:
 *   - Signing key must be AI_PROVENANCE_HMAC_KEY env var (>= 32 chars).
 *   - AI_PROVENANCE_HMAC_KEY must be distinct from all other boot secrets
 *     (enforced at boot by the distinct-secret boot gate).
 *   - Canonical JSON sorts keys alphabetically before signing to prevent
 *     field-reordering attacks.
 *
 * Spec: P4-AIR-03 AC 7-9
 *
 * @connexum/ai-governance
 */
/**
 * EU AI Act Art. 50(1) disclosure block.
 * Identifies the LLM used to generate the report and when.
 */
export interface Art50Disclosure {
    wasLlmGenerated: true;
    model: string;
    modelProvider: string;
    generatedAt: string;
    governanceRuntime: string;
}
/**
 * A fully signed provenance envelope for a narrative report body.
 *
 * verifyProvenance(envelope, key) confirms the envelope has not been
 * tampered with after issuance.
 */
export interface ProvenanceEnvelope {
    /** SHA-256 hex of the narrative body content */
    contentHash: string;
    /** EU AI Act Art. 50 disclosure */
    art50Disclosure: Art50Disclosure;
    /** Pack IDs that governed this report */
    packBindings: string[];
    /** Audit chain tip hash at the time of generation */
    chainHeadHash: string;
    /** ISO-8601 signing timestamp */
    signedAt: string;
    /** HMAC-SHA256 over canonicalJson(all above fields) */
    signature: string;
}
/**
 * Input to signProvenance. Everything required to produce the envelope.
 */
export interface ProvenanceSignInput {
    /** The narrative body content being signed. */
    narrativeBody: string;
    /** LLM model identifier (e.g. 'claude-3-5-sonnet-20241022') */
    modelId: string;
    /** LLM provider identifier (e.g. 'anthropic') */
    modelProvider: string;
    /** ISO-8601 timestamp of when the narrative was generated */
    generatedAt: string;
    /** Pack IDs bound to the report */
    packBindings: string[];
    /** Audit chain tip hash at generate time (hex string or empty if chain is empty) */
    chainHeadHash: string;
    /** HMAC key. Must be >= 32 chars. If not provided, falls back to AI_PROVENANCE_HMAC_KEY env var. */
    hmacKey?: string;
}
export interface ProvenanceVerifyResult {
    valid: boolean;
    reason?: string;
}
/**
 * Validate the AI_PROVENANCE_HMAC_KEY at boot time.
 *
 * Requirements:
 *   - Must be present (non-empty).
 *   - Must be >= 32 characters.
 *   - Must be distinct from the other 5 named boot secrets.
 *
 * Throws on any violation (fail-closed).
 */
export declare function validateProvenanceHmacKey(provenanceKey: string, otherSecrets?: Record<string, string>): void;
/**
 * Error thrown by canonicalJson when homoglyph duplicate keys are detected.
 *
 * H9d: An object whose keys collide after NFKC normalization is a tamper
 * attempt. The canonical form would silently drop one of the values.
 * We throw instead so callers can emit an audit event and fail closed.
 *
 * Example: { "\u0041dmin": 1, "Admin": 2 } -- '\u0041' is 'A' after NFKC,
 * so both keys normalize to "Admin". The second entry would shadow the first.
 */
export declare class HomoglyphKeyError extends Error {
    /** Object path where the collision was detected (dot-notation) */
    readonly path: string;
    /** The two raw keys that collide after NFKC normalization */
    readonly collidingKeys: [string, string];
    /** The shared NFKC-normalized form */
    readonly normalizedKey: string;
    constructor(path: string, key1: string, key2: string, normalizedKey: string);
}
/**
 * Produce a canonical (sorted-keys, deterministic) JSON string.
 * Prevents field-reordering attacks on the signature.
 *
 * H4 fix: arrays are now handled deterministically:
 *   - Arrays of objects: each element has its keys sorted recursively.
 *   - Arrays of primitives: elements are sorted lexicographically so that
 *     ["b","a"] and ["a","b"] produce the same canonical form.
 *   - Mixed arrays: objects are recursed, primitives are sorted by
 *     their JSON serialization.
 *
 * H9d fix: object keys are NFKC-normalized before sorting. If two keys in
 * the same object normalize to the same NFKC form (homoglyph attack),
 * HomoglyphKeyError is thrown. Callers must catch this and emit an audit
 * event (canonicalJson.homoglyph-key-rejected) before failing closed.
 */
export declare function canonicalJson(obj: Record<string, unknown>): string;
/**
 * Sign a narrative body and produce a ProvenanceEnvelope.
 *
 * The envelope can be attached to a report response so external auditors
 * can verify it with verifyProvenance().
 *
 * @throws Error if hmacKey is missing or shorter than 32 characters.
 */
export declare function signProvenance(input: ProvenanceSignInput): ProvenanceEnvelope;
/**
 * Verify a ProvenanceEnvelope produced by signProvenance().
 *
 * Checks:
 *   1. All required fields are present.
 *   2. The HMAC signature is valid over the canonical JSON of the non-sig fields.
 *
 * Does NOT re-hash the narrative body against contentHash -- the caller
 * should separately verify contentHash === SHA-256(narrativeBody) if they
 * have the body available.
 *
 * Returns { valid: true } on success, { valid: false, reason } on failure.
 */
export declare function verifyProvenance(envelope: ProvenanceEnvelope, hmacKey: string): ProvenanceVerifyResult;
/**
 * Verify that the contentHash in an envelope matches the actual body.
 *
 * This is a separate check so callers can verify both the envelope
 * signature AND the body integrity in two steps.
 */
export declare function verifyContentHash(envelope: ProvenanceEnvelope, narrativeBody: string): ProvenanceVerifyResult;
//# sourceMappingURL=provenance-signer.d.ts.map