﻿# Free Quickstart（RunProof）
*Free Quickstart (RunProof)*

RunProof を **Free** で最短確認するための手順です。**生データは送らず、sha256 ハッシュだけ**を送ります。  
This is the shortest path to try RunProof on **Free**. **Do not send raw data — send only sha256 hashes.**

---

## 0) 重要（禁止事項）
*Important (Do NOT send)*

- 個人情報（PII）、機密情報、カード情報、秘密鍵、パスワード等は **送信禁止**  
  **No PII, secrets, card data, private keys, passwords.**
- 送るのは `sha256:<hex>` と、非機微な補助情報（`tags`、任意）だけ  
  Send only `sha256:<hex>` and (optional) non-sensitive tags.

入力ポリシー：`/policy/data_input_policy_v1.md`  
Data input policy: `/policy/data_input_policy_v1.md`

---

## 1) Freeキーを取得する（one-time）
*Get a Free key (one-time reveal)*

1. このページを開きます（Turnstileが出ます）  
   Open this page (Turnstile challenge):

   - `https://runproof-chamia.pages.dev/free/claim/`

2. 表示された APIキー文字列（例：`<API_KEY>...` など。先頭は環境により異なります）を安全な場所に保存します  
   Save the displayed API key string securely (prefix may vary).

> Freeは **1 IPあたり1日1回**の発行制限があります。  
> Free key issuance is limited to **once per IP per day**.

---

## 2) APIキーの入れ方（結論）
*Where to put the API key (answer)*

APIキーは **HTTPヘッダ**で渡します。  
Pass the API key via **HTTP header**.

- Header: `Authorization`
- Format: `Bearer <your-api-key>`

例 / Example:

```text
Authorization: Bearer <YOUR_API_KEY>
```

---

## 3) PowerShell（最小）— まず /v1/receipts を叩く
*PowerShell (minimal) — call /v1/receipts first*

最初の動作確認は **レシート作成（POST /v1/receipts）** が最短です。  
The fastest check is **Create receipt (POST /v1/receipts)**.

### 3-A) 変数とヘッダ
*Variables and headers*

```powershell
$BaseUrl = "https://runproof.chamia-20260215.workers.dev"   # RunProof API
$ApiKey  = "<YOUR_API_KEY>"   # ← /free/claim で取得したもの（先頭は環境により異なることがあります）

$Headers = @{
  Authorization = "Bearer $ApiKey"
  "Content-Type" = "application/json"
}
```

### 3-B) 入力から sha256 を作る（例）
*Create sha256 from input (example)*

```powershell
$InputText = "hello runproof"
$Bytes   = [System.Text.Encoding]::UTF8.GetBytes($InputText)
$HashHex = ([System.Security.Cryptography.SHA256]::Create().ComputeHash($Bytes) | ForEach-Object { $_.ToString("x2") }) -join ""
$InputHash = "sha256:$HashHex"
```

### 3-C) レシート作成（POST /v1/receipts）
*Create a receipt (POST /v1/receipts)*

```powershell
$Body = @{
  input_hash   = $InputHash
  receipt_kind = "release"
  tags         = @{ kind = "release"; note = "free test" }
} | ConvertTo-Json -Depth 6

$r1 = Invoke-RestMethod "$BaseUrl/v1/receipts" -Method Post -Headers $Headers -Body $Body
$r1 | ConvertTo-Json -Depth 12

$Rid = $r1.receipt.receipt_id
```

`$r1.receipt.receipt_id` が返れば「キーを入れて呼べている」ことが確定です。  
If `$r1.receipt.receipt_id` is returned, your key+request are working.

---

## 4) レシート取得（GET /v1/receipts/{id}）
*Get a receipt (GET /v1/receipts/{id})*

```powershell
Invoke-RestMethod "$BaseUrl/v1/receipts/$Rid" -Method Get -Headers $Headers |
  ConvertTo-Json -Depth 12
```


---

## 4.5) 成功判定（Free の最短導線）
*Success criteria (shortest Free path)*

Free の最短確認は、次の流れが通ることです。

- 1回目の POST `/v1/receipts` が **201**
- 同じ入力でもう一度 POST すると **200**（idempotency replay）
- GET `/v1/receipts/{receipt_id}` が **200**
- POST `/v1/verify` が `ok=true`

つまり、**201 -> 200 -> GET -> verify(ok=true)** が通れば成功です。

## 5) verify（POST /v1/verify）
*Verify (POST /v1/verify)*

```powershell
$VerifyBody = @{
  receipt_id = $Rid
  input_hash = $InputHash
} | ConvertTo-Json -Depth 6

Invoke-RestMethod "$BaseUrl/v1/verify" -Method Post -Headers $Headers -Body $VerifyBody |
  ConvertTo-Json -Depth 12
```

---

## 6) よくあるエラー（最短の見方）
*Common errors (quick interpretation)*

- **401 Unauthorized**：`Authorization: Bearer ...` が無い／キーが違う  
  Missing/invalid `Authorization: Bearer ...`
- **429 Too Many Requests**：Freeの制限（発行/レート）に到達  
  Hit Free limits (issuance/rate)
- **400 Bad Request**：入力がポリシー違反、または必須項目不足  
  Policy violation or missing required fields

---

## 7) 次に読む（リンク）
*What to read next (links)*

- 凍結仕様（公開仕様の入口） / Freeze spec: `/freeze/freeze_v2.md`
- APIリファレンス / API reference: `/ref/api_reference_v0.1.1.md`
- 入力ポリシー / Data input policy: `/policy/data_input_policy_v1.md`
- 料金 / Pricing: `/plan/pricing_v1.md`

---

## まとめ
*Summary*

- キーは `Authorization: Bearer <key>` で渡す  
  Put the key in `Authorization: Bearer <key>`
- 送るのは `sha256:<hex>`（生データは送らない）  
  Send `sha256:<hex>` only (no raw data)
- 返ってきたレシートは第三者に渡して検証できる  
  Receipts can be shared for third‑party verification

