/**
 * ProofChain — tamper-evident SHA-256 step chain for TRACE_V1.
 *
 * Coexists with the legacy Poseidon proof system in `./poseidon.ts`.
 * This module targets the TRACE_V1 schema (sprint-561:a2/a4).
 *
 * buildChain  — builds a ProofChain from a finalized Trace.
 * verifyChain — runs 7 integrity checks (R8-M4, CH9, AR6).
 *
 * rootHash binding (CH9):
 *   rootHash = sha256(canonical({
 *     lastStepHash,
 *     totalSteps,
 *     configHash,    ← anti config-swap
 *     agentId,
 *     agentVersion,
 *     runId,
 *   }))
 *
 * All-zeros prevStepHash sentinel for step[0]:
 *   "0000000000000000000000000000000000000000000000000000000000000000"
 *
 * @module proof/chain
 */
import type { Trace, TraceStep } from "../trace/schema.js";
export interface ProofChainEntry {
    /** Zero-based step index (mirrors TraceStep.index). */
    index: number;
    /** SHA-256(canonical({ ...step fields (excl. stepHash), runId })). */
    stepHash: string;
}
export interface ProofChain {
    /** Hash algorithm identifier. Always sha-256 in this schema version. */
    algorithm: "sha-256";
    /** One entry per step; ordered by index. */
    entries: ProofChainEntry[];
    /**
     * SHA-256(canonical({ lastStepHash, totalSteps, configHash, agentId, agentVersion, runId })).
     * Binds config, identity, and chain tail into a single commitment (CH9).
     */
    rootHash: string;
}
/**
 * Discriminated union returned by verifyChain.
 * R8-M4: receiptStatus propagated on BOTH branches when present.
 */
export type VerifyChainResult = {
    valid: true;
    receiptStatus?: "present" | "pending" | "failed";
} | {
    valid: false;
    /** Zero-based index of the first tampered step, or -1 for structural errors. */
    tamperedAt: number;
    reason: string;
    receiptStatus?: "present" | "pending" | "failed";
};
/** All-zeros sentinel for prevStepHash of the first step. */
export declare const GENESIS_PREV_HASH = "0000000000000000000000000000000000000000000000000000000000000000";
/**
 * SHA-256(canonical({ ...step fields (excluding stepHash), runId })).
 *
 * The stepHash field itself is excluded from its own digest to avoid
 * circular dependency. runId is included explicitly even though it is
 * already a step field — this is intentional for AR6 clarity.
 */
export declare function computeStepHash(step: TraceStep, runId: string): Promise<string>;
/**
 * Build a ProofChain from a finalized Trace.
 *
 * Recomputes stepHash for every step to produce the entries array,
 * then computes rootHash = sha256(canonical({ lastStepHash, totalSteps,
 * configHash, agentId, agentVersion, runId })).
 *
 * @throws If the trace has no steps.
 */
export declare function buildChain(trace: Trace): Promise<ProofChain>;
/**
 * Verify a ProofChain against a Trace — 7 integrity checks.
 *
 * Checks (in order):
 *   1. steps[i].index === i                    (monotone, anti-deletion)
 *   2. steps.length === trace.totalSteps        (anti-truncation)
 *   3. steps[i].runId === trace.runId for all i (anti-splice AR6)
 *   4. recompute stepHash === step.stepHash     (data integrity)
 *   5. steps[i].prevStepHash === steps[i-1].stepHash (chain linkage)
 *   6. rootHash === recomputed rootHash         (root commitment CH9)
 *   7. trace.configHash === sha256(canonical(trace.config)) (config anti-swap)
 */
export declare function verifyChain(trace: Trace, chain: ProofChain): Promise<VerifyChainResult>;
//# sourceMappingURL=chain.d.ts.map