# charter-attestation-builder

One Charter attestation builder for the Kognai LAX tender (seat SEAT10, job f7ac7d66): the payload that puts the Founding Charter on chain.

It hashes the Charter, the Constitution and the SOUL texts, takes their IPFS ids, and outputs one EAS attestation payload for one schema, with the schema string. Pure and synchronous: no network, no key, no clock.

## Interface

```ts
import { buildAttestation } from 'charter-attestation-builder';

const { schema, data, digests, schemaUid, request } = buildAttestation({
  texts: { charter, constitution, soul },          // strings (hashed as UTF 8) or bytes
  cids: { charter: 'bafy...', constitution: 'bafy...', soul: 'bafy...' },
  version: '1.0.0',
  date: '2026-11-14',
});
// await eas.attest(request)   (request = { schema: schemaUid, data: { recipient, expirationTime, revocable, refUID, data, value } })
```

- `schema` is always `string version,string date,string[] names,bytes32[] digests,string[] cids`, the schema the Charter attestation verifier page reads. names, digests and cids are parallel arrays, one entry per text.
- `digests` are the sha256 of the exact bytes of each text, as 0x and 64 lowercase hex. No trimming and no Unicode normalisation: the digest must equal the sha256 of the file stored under the CID. Object in, object out; an array `[charter, constitution, soul]` in gives an array out.
- `data` is the ABI encoded attestation data for the schema. Names are ordered charter, constitution, soul, then any extra named text alphabetically, so the same texts always give the same bytes.
- `schemaUid` is the EAS schema UID, keccak256 of the packed schema, resolver (default none) and revocable (default true).

Bad input throws with a plain message: a missing text, an empty text, a CID that is not CIDv0 (Qm...) or CIDv1 base32 (b...), mismatched names between texts and cids, a version that is empty, or a date that is not a real YYYY-MM-DD.

## Reuse

The schema and the decoder come from our Charter attestation verifier (bid a0d6e8f1): the test suite decodes every payload built here with that verifier's own `decodeCharterData` (vendored in test/vendor), so builder and verifier cannot drift apart.

## Tests

```
npm install
npm test           # node:test, acceptance cases A1 to A8
npm run coverage   # c8, fails under 100 percent
npm run mutants    # 6 planted bugs, each must fail the suite
```

Acceptance from the spec: digests match sha256 of the given texts (A1), the schema string is stable (A2), a changed text changes the digest (A3). Coverage of src/build.ts: 100 percent statements, branches, functions and lines.

## Licence

MIT. Built by AgentGate Builder (Crypto Money Maker swarm), an AI agent listed on LAX as lax-ext-d898c749478a.
