# `core/charts/attest.ts`

<p class="generated-note">Generated from the exports of <a href="https://github.com/altasystem-ai/alta/blob/main/core/charts/attest.ts"><code>core/charts/attest.ts</code></a> · <code>npm run docs:gen</code></p>

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](https://docs.altasystem.ai/reference/advanced/specs/alta-attestation-0.1)

## Exports

### `ATTESTATION_SCHEMA` 
```ts
const ATTESTATION_SCHEMA = "alta.attestation/0.1"
```

### `DSSE_PAYLOAD_TYPE` 
```ts
const DSSE_PAYLOAD_TYPE = "application/vnd.in-toto+json"
```

### `STATEMENT_TYPE` 
```ts
const STATEMENT_TYPE = "https://in-toto.io/Statement/v1"
```

### `PREDICATES` 
```ts
const PREDICATES = { publish: "https://altasystem.ai/attestations/chart-publish/v0.1", review: …
```

### `AttestationType` 
```ts
type AttestationType = keyof typeof PREDICATES;
```

### `CHART_ATTESTATION_TYPES` 
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` 
```ts
interface Subject { name: string; digest: { sha256: string } }
```

### `Statement` 
```ts
interface Statement { _type: typeof STATEMENT_TYPE; subject: Subject[]; predicateType: string; predicate: Record<string, unknown> }
```

### `Envelope` 
```ts
interface Envelope { payloadType: string; payload: string; signatures: { keyid?: string; sig: string }[] }
```

### `TrustedKey` 
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` 
Ed25519 verification, given by the caller: raw 32-byte public key, message, signature.

```ts
type Ed25519Verify = (publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
```

### `toBase64` 
```ts
function toBase64(b: Uint8Array): string
```

### `fromBase64` 
Standard or URL-safe base64 (DSSE accepts both), with or without padding; undefined when malformed.

```ts
function fromBase64(s: unknown): Uint8Array | undefined
```

### `pae` 
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): Uint8Array
```

### `chartStatement` 
The statement of a chart version.

```ts
function chartStatement(o: { id: string; version: string; tree: string; type: AttestationType; predicate?: Record<string, unknown> }): Statement
```

### `indexStatement` 
The statement of a repository index: its bytes' sha256.

```ts
function indexStatement(o: { sha256: string; repo?: string; generatedAt?: string }): Statement
```

### `envelopeOf` 
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): Envelope
```

### `readEnvelope` 
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` 
The attestation type of a statement (undefined: unknown).

```ts
const typeOf = (s: Statement): AttestationType | undefined => …
```

### `Verdict` 
```ts
interface Verdict {
  ok: boolean;
  statement?: Statement;
  type?: AttestationType;
  /** The key that verified the signature. */
  signer?: TrustedKey;
  problems: string[];
}
```

### `verifyEnvelope` 
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
```
