# ClariMac proof format — v2

Open specification. License: MIT. Anyone can implement a verifier.

## Goal

A buyer can check that a ClariMac certificate is genuine and belongs to the Mac in front of them,
**without trusting ClariMac or DataMirror servers**, and **without the serial number ever being published**.

## 1. Payload

The sealed content is a JSON object, serialized as **canonical JSON**:
keys sorted alphabetically at every level, no whitespace, `undefined` fields dropped, `null` kept.

```json
{
  "certId": "847bf65d565d",
  "checklist": { "camera": true, "keyboard": true, "physical_condition": "good", "...": "..." },
  "proofs": { "camera_sha256": "…", "keyboard_keys": 78, "mic_sha256": "…" },
  "scan": { "battery_cycles": 112, "chip": "Apple M4 Pro", "model": "MacBook Pro 16-inch", "...": "..." },
  "serial_commitment": "…64 hex…",
  "v": 2
}
```

- `scan`: hardware data read by the scanner (model, chip, RAM, macOS, storage, battery, security state, crash counts).
- `checklist`: results of the manual tests done by the seller.
- `proofs`: keyboard key count, and SHA-256 of the mic and camera captures (the captures themselves stay private).
- The full field list is in `lib/anchor.ts` (`buildProofPayloadV2`).

## 2. Serial commitment

```
serial_commitment = hex( PBKDF2-SHA256(
  password   = normalize(serial),            // uppercase, keep A-Z and 0-9 only
  salt       = "clarimac-serial-v2:" + certId,
  iterations = 600000,
  length     = 32 bytes ) )
```

The serial number is never stored in the payload. The slow key derivation makes guessing it from the public payload expensive.

## 3. Fingerprint

```
hash = hex( SHA-256( canonical_payload_string ) )
```

## 4. Anchor on Solana

One transaction per certificate, with an SPL Memo instruction:

```
ClariMac:<certId>:<hash>
```

Official signer wallets:

| Network | Wallet |
|---|---|
| devnet (launch phase) | `9zCagz2pxPsp54ETCJyZhttcsvHCmHtACBn56KXoyLHC` |
| mainnet-beta | not active yet |

## 5. Verify

1. Get the proof bundle: `GET https://clarimac.com/api/cert/<certId>/proof` — save it; it is all you need later.
2. Read the serial number on the Mac (Apple menu › About This Mac), compute `serial_commitment`, compare with the payload.
3. Compute `hash` from the `payload` string.
4. Fetch the transaction from any Solana RPC (`getTransaction`, `jsonParsed`), check the memo ends with `:<hash>` and the signer is an official wallet.

Reference verifier (runs fully in the browser, open source): https://clarimac.com/verify.html

## Versions

- **v1** (before v2): `sha256(certId + JSON{k,m,c})` — covers the certificate ID and the keyboard/mic/camera captures only. Not publicly recomputable (captures are private).
- **v2**: this document.
