English
core/charts/attest.ts
Generated from the exports of core/charts/attest.ts · npm run docs:gen
Attestations of a chart (alta.attestation/0.1, docs/standards/alta-attestation-0.1.md): a DSSE envelope (the "secure-systems-lab/dsse" specification) around an in-toto Statement v1 (https://in-toto.io, "in-toto/attestation") whose subject is <chart id>@<version> and its tree digest (alta.tree/1). The signature is Ed25519 over the DSSE pre-authentication encoding (PAE). The same envelope, with the subject index.json, signs a repository index (index.json.sig). Pure: no disk, no network, no crypto library. The caller gives the Ed25519 verification (node:crypto in the CLI), so that this file runs anywhere the core runs.
Standards that cite this file: alta.attestation/0.1: who signed which files of a chart
Exports
ATTESTATION_SCHEMA const
ts
const ATTESTATION_SCHEMA = "alta.attestation/0.1"DSSE_PAYLOAD_TYPE const
ts
const DSSE_PAYLOAD_TYPE = "application/vnd.in-toto+json"STATEMENT_TYPE const
ts
const STATEMENT_TYPE = "https://in-toto.io/Statement/v1"PREDICATES const
ts
const PREDICATES = { publish: "https://altasystem.ai/attestations/chart-publish/v0.1", review: …AttestationType type
ts
type AttestationType = keyof typeof PREDICATES;CHART_ATTESTATION_TYPES const
The types alta attest writes for a chart (provenance comes from a CI, later; index is alta repo sign).
ts
const CHART_ATTESTATION_TYPES: readonly AttestationType[]Subject interface
ts
interface Subject { name: string; digest: { sha256: string } }Statement interface
ts
interface Statement { _type: typeof STATEMENT_TYPE; subject: Subject[]; predicateType: string; predicate: Record<string, unknown> }Envelope interface
ts
interface Envelope { payloadType: string; payload: string; signatures: { keyid?: string; sig: string }[] }TrustedKey interface
A public key that may have signed: its id, the 32 raw bytes in base64, and when it was revoked (if it was).
ts
interface TrustedKey { id: string; public: string; revoked?: string; who?: string }Ed25519Verify type
Ed25519 verification, given by the caller: raw 32-byte public key, message, signature.
ts
type Ed25519Verify = (publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;toBase64 function
ts
function toBase64(b: Uint8Array): stringfromBase64 function
Standard or URL-safe base64 (DSSE accepts both), with or without padding; undefined when malformed.
ts
function fromBase64(s: unknown): Uint8Array | undefinedpae function
The DSSE v1 pre-authentication encoding: "DSSEv1" SP LEN(type) SP type SP LEN(body) SP body, where LEN is the byte length in ASCII decimal. This, not the payload alone, is what is signed.
ts
function pae(payloadType: string, payload: Uint8Array): Uint8ArraychartStatement function
The statement of a chart version.
ts
function chartStatement(o: { id: string; version: string; tree: string; type: AttestationType; predicate?: Record<string, unknown> }): StatementindexStatement function
The statement of a repository index: its bytes' sha256.
ts
function indexStatement(o: { sha256: string; repo?: string; generatedAt?: string }): StatementenvelopeOf function
The bytes to sign for a statement, and the envelope once signed (sign is the caller's Ed25519).
ts
function envelopeOf(statement: Statement, sign: (message: Uint8Array) => Uint8Array, keyid: string): EnvelopereadEnvelope function
Problems of an envelope's shape and of the statement it carries (empty = readable).
ts
function readEnvelope(x: unknown): { statement?: Statement; payload?: Uint8Array; problems: string[] }typeOf const
The attestation type of a statement (undefined: unknown).
ts
const typeOf = (s: Statement): AttestationType | undefined => …Verdict interface
ts
interface Verdict {
ok: boolean;
statement?: Statement;
type?: AttestationType;
/** The key that verified the signature. */
signer?: TrustedKey;
problems: string[];
}verifyEnvelope function
Checks an envelope: its shape, that its subject is name with the digest sha256, and that one of its signatures verifies under one of the keys. A signature by a revoked key is refused and named; a signature no key verifies is refused. Never says more than what was checked.
ts
function verifyEnvelope(x: unknown, want: { name: string; sha256: string; type?: AttestationType }, keys: readonly TrustedKey[], verify: Ed25519Verify): Verdict