Skip to content

Fingerprint a file

fingerprint() in the SDKs: a blinded fingerprint of a run log, a tool call, or a model output, made where the bytes live. PacSpace receives the fingerprint and the size, never the file.

Every entry carries at least one fingerprint: the fingerprint of the file, the payload, or the object the entry is about. You make it where the bytes are, with the SDK's fingerprint helper, and the result goes in payloads. PacSpace receives the fingerprint and the size. The fingerprint carries no part of the file, its name or its location; a title or note you write is stored as written.

Call

An evaluation harness fingerprints what it logged for run 4417: the run log on disk, one tool call it holds in memory, and an output it streams from its own storage.

TypeScript
import { createReadStream } from 'node:fs';
import { fingerprint, writeBlindingFile, blindingFileText } from '@pacspace-io/sdk';

// A file on disk, read in chunks: the run log.
const { ref, blinding } = await fingerprint(createReadStream('./runs/4417/run.jsonl'));

// blinding is set unless you pass { blind: false }
await writeBlindingFile('./runs/4417/run.jsonl', blinding!);
// Written beside the log as ./runs/4417/run.jsonl.pacspace.json

// Bytes you already hold: one tool call and its output, exactly as the harness logged them.
const { ref: callRef, blinding: callBlinding } = await fingerprint(new TextEncoder().encode(loggedLine));
// Keep blindingFileText(callBlinding!) with the logged line it belongs to.

// A stream, such as a model output read from your own storage. The output never leaves it.
const { ref: outputRef, blinding: outputBlinding } = await fingerprint(outputStream);
// Keep blindingFileText(outputBlinding!) with the output it belongs to.

What comes back

fingerprint returns the fingerprint as ref, and its blinding. ref is:

JSON
{ "alg": "hmac-sha-256", "digest": "<64 hex characters, different for each blinding>", "byteLength": "100000" }

alg is the method: hmac-sha-256 for a blinded fingerprint, the default, or sha-256 for a plain one ({ blind: false }, or blind=False in Python). digest is the fingerprint, 64 hex characters. byteLength is the size in bytes, as a string. Send ref as the payload and keep the blinding file with the file; never send the blinding file or its value. Whoever holds both the file and its blinding file can confirm the file is in the record, so keep the blinding file as private as the file.

To check a file you hold later, pass it with its blinding file to records.check in expect[].files, or pass the blinding back to fingerprint ({ blinding }, or blinding= in Python) to get the same ref again. Fingerprinting the file again without its blinding file gives a different fingerprint. If a blinding file is lost, its entry can no longer be matched to the file; the entry's seal still checks.

What to fingerprint

Fingerprint the thing as you store it, so you can reproduce the fingerprint later from what you hold. A run log as written to disk. A tool call serialized the way the harness logs it. A model output as it was returned. If you serialize the same data two different ways, you get two different fingerprints; pick one form and keep it.

An entry can carry more than one fingerprint. An agent's tool-call entry might carry the call and its output; a model release entry might carry the build and its test results.

A check matches the fingerprints in an entry's payloads. A fingerprint nested elsewhere in the content is shown and marked, but not matched.

Inputs

TypeScript accepts a File, a Blob, an ArrayBuffer, a Uint8Array, a ReadableStream, or any iterable or async iterable of byte chunks, such as a Node stream. A stream or an iterable is read in chunks; a File, a Blob or an ArrayBuffer is read whole. Node.js 20.19 or later. Python accepts bytes, a file object opened in binary mode, or any iterable of bytes.

When it refuses

fingerprint sends nothing, so these refusals come from the SDK itself, before any request.

What you getThe rule
RECORD_PAYLOAD_ALG_UNSUPPORTEDA fingerprint is made with sha-256 or hmac-sha-256.
RECORD_CONTENT_INVALIDThe input is bytes, a file, a stream, or an iterable of bytes.
ValidationErrorA blinding file is the one written for these bytes, unchanged, and its value is 32 bytes. alg and blind agree. writeBlindingFile writes only where no other blinding file, link, or folder already is.
RECORD_BLINDING_INCLUDEDA payload carries the fingerprint's ref only. records.emit and records.check refuse a blinding file, its value, or a whole fingerprint result before anything is sent, and the API refuses the same if it arrives.

The first two carry the code the API would give for the same mistake. ValidationError is the SDK's own error class: a blinding file is never sent, so no API code applies to it.