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56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# Authority Key Deployment Guide

**Purpose:** Instructions for authority operators to sign capabilities and provision nodes.

**Audience:** PAX-Coder Authority Operator (not public)

---

## 1. Authority Setup (One-Time)

### 1.1 Generate Authority Keypair

**Location:** Authority server (secure environment)

```bash

cd pax-coder

bash sovereign/generate_authority_key.sh

```

**Output:**
- `sovereign/authority_sk.pem` β€” Private key (KEEP SECURE)
- `sovereign/authority_pk.pem` β€” Public key (distribute to nodes)

**Security:**
```bash

# Verify file permissions

ls -la sovereign/authority_sk.pem  # Should be 600

ls -la sovereign/authority_pk.pem  # Should be 644

```

### 1.2 Distribute Authority Public Key

**File:** `sovereign/authority_pk.pem`

Distribute to all nodes that will verify authorizations:

```bash

# Copy to known location on all nodes

cp sovereign/authority_pk.pem /etc/authority/pax-coder-authority-pk.pem

```

Or bake into deployment image:
```bash

# In Docker image or VM template

COPY sovereign/authority_pk.pem /etc/authority/pax-coder-authority-pk.pem

```

**Do NOT commit authority_pk.pem to public repositories.**



---



## 2. Create Authorization Records



### 2.1 Authorization Request Flow



```

Developer/Customer

    ↓ (Request)

Authority Operator

    ↓ (Review)

Authorization Database

    ↓ (Create)

authorization.json template

    ↓ (Sign)

Signed Capability

    ↓ (Deliver)

Developer/Customer

```



### 2.2 Create Capability Record



**Filename:** `capability_NODE_ID.json`



```json

{

  "node_id": "pax-coder-prod-12345",

  "release_id": "1.0.0",

  "commit": "abc123def456789abc123def456789abc123def4",

  "nonce": "nonce-2026-08-18-unique",

  "expires_at": "2026-12-31T23:59:59Z"

}

```



**Fields:**

| Field | Purpose | Example |
|-------|---------|---------|
| `node_id` | Unique node identifier | `pax-coder-prod-12345` |
| `release_id` | Allowed release version | `1.0.0` |
| `commit` | Exact git commit hash | `abc123...` |
| `nonce` | One-time use identifier | Date + random |
| `expires_at` | Expiration time (UTC) | ISO 8601 |

### 2.3 Sign Capability

**Command:**

```bash

bash sovereign/sign_capability.sh capability_NODE_ID.json

```

**Output:**

```

{"commit":"abc123...","expires_at":"2026-12-31T23:59:59Z",...}|b640c7a4f0af55c7abba64c8e444d39b0bd44431aabffeb814cd519b87e6352aaf0c63cbcb94bad1ae23ac52f1288dea7c0aa815158f76221cee56da9aad520a

```

Format: `CANONICAL_JSON|SIGNATURE_HEX`

**Signature:** 128 hex characters (64 bytes Ed25519)

### 2.4 Deliver to Node

**Send via secure channel:**

```bash

# Option 1: Email or secure message

PAX_CAPABILITY_TOKEN="$(bash sovereign/sign_capability.sh capability_NODE_ID.json)"

echo $PAX_CAPABILITY_TOKEN > /tmp/capability.txt

# Send /tmp/capability.txt to node operator (encrypted)



# Option 2: API endpoint

curl -X POST https://authority.example.com/provision \

  -H "Authorization: Bearer $AUTH_TOKEN" \

  -d '{

    "node_id": "pax-coder-prod-12345",

    "capability": "'$PAX_CAPABILITY_TOKEN'"

  }'



# Option 3: Kubernetes secret

kubectl create secret generic pax-capability-prod-12345 \

  --from-literal=token="$PAX_CAPABILITY_TOKEN"

```

---

## 3. Node Installation

### 3.1 Deploy Authority Public Key

**Automated (Terraform):**

```hcl

resource "local_file" "authority_pk" {

  content  = file("${path.module}/sovereign/authority_pk.pem")

  filename = "/etc/authority/pax-coder-authority-pk.pem"

}

```

**Manual:**

```bash

mkdir -p /etc/authority

cp authority_pk.pem /etc/authority/pax-coder-authority-pk.pem

chmod 644 /etc/authority/pax-coder-authority-pk.pem

```

### 3.2 Set Capability Token

**Environment Variable:**

```bash

export PAX_CAPABILITY_TOKEN="$(cat /path/to/capability.txt)"

```

**File:**

```bash

mkdir -p pax-coder/sovereign

echo "$PAX_CAPABILITY_TOKEN" > pax-coder/sovereign/.capability

chmod 600 pax-coder/sovereign/.capability

```

**Kubernetes Secret:**

```bash

kubectl create secret generic pax-capability \

  --from-file=capability=/path/to/capability.txt \

  -n pax-system



# Mount in pod

volumeMounts:

  - name: pax-capability

    mountPath: /opt/pax/sovereign/.capability

    subPath: capability

volumes:

  - name: pax-capability

    secret:

      secretName: pax-capability

```

### 3.3 Verify Setup

**Test gate:**

```bash

cd pax-coder

bash scripts/pax-coder-gate

```

**Expected output:**

```

PAX-CODER PROTECTED EXECUTION GATE

[1/5] Verifying release integrity...

βœ“ Release integrity verified

[2/5] Verifying node authorization status...

βœ“ Node authorization verified

[3/5] Checking for capability...

βœ“ Capability token found

[4/5] Parsing capability...

βœ“ Capability parsed

[5/5] Validating capability...

βœ“ Commit matches

βœ“ Capability not expired

βœ“ Node ID matches

[6/6] Verifying capability signature...

βœ“ Signature verified (cryptographic validation)



STATUS: AUTHORIZATION_GRANTED

Node pax-coder-prod-12345 is authorized for:

  Scope: protected-execution

```

---

## 4. Authority Operations

### 4.1 Rotate Authority Keys

**When:** Compromise suspected, key expires, policy change

**Steps:**

1. Generate new authority keypair:
   ```bash

   bash sovereign/generate_authority_key.sh

   ```

2. Distribute new authority_pk.pem to all nodes



3. Continue signing with new authority_sk.pem

4. Mark old capabilities as REVOKED (if managed in database)

**Old capabilities:** Will fail verification once authority_pk.pem is updated



### 4.2 Revoke Capability



**Option 1: Expiration (Automatic)**



Capabilities expire at `expires_at` timestamp.

**Option 2: Revocation (Operational)**

If compromise or revocation needed before expiration:

1. Update authorization database
2. Add to revocation list
3. Gate checks against revocation list (if implemented)

Current gate does not check revocation list; implement if needed.

### 4.3 Audit Trail

**Maintain log:**

```

Date          | Node ID          | Action    | Signature

2026-08-18    | pax-coder-12345  | PROVISION | b640c7a4...

2026-08-20    | pax-coder-12345  | REVOKE    | (reason: compromise)

2026-08-21    | pax-coder-12346  | PROVISION | f8a6008c...

```

---

## 5. Security Best Practices

### 5.1 Private Key Protection

```bash

# Generate on secure server, NEVER transfer

authority_sk.pem β†’ KEEP ONLY ON AUTHORITY SERVER



# Backup encrypted

openssl enc -aes-256-cbc -in authority_sk.pem -out authority_sk.pem.enc



# Verify file permissions

ls -la sovereign/authority_sk.pem  # Must be 600

stat -c "%a" sovereign/authority_sk.pem  # Should print 600

```

### 5.2 Public Key Distribution

```bash

# Safe to distribute, verify integrity:

# Use signed manifest or checksum



sha256sum sovereign/authority_pk.pem > authority_pk.sha256

gpg --sign authority_pk.sha256  # Sign with operator key



# Nodes verify before deployment:

gpg --verify authority_pk.sha256.gpg

sha256sum -c authority_pk.sha256

```

### 5.3 Secure Channels

- Use TLS for capability delivery
- Sign capabilities with operator signature (GPG)
- Encrypt in transit
- Audit who can provision

### 5.4 Monitoring

```bash

# Log all capability issuances:

bash sovereign/sign_capability.sh capability_$NODE.json 2>&1 | \

  tee -a /var/log/pax-authority.log



# Alert on failures:

# - Failed signature operations

# - Missing authority_sk

# - Unauthorized sign requests

```

---

## 6. Troubleshooting

### Issue: "Authority public key not found"

**Solution:** Deploy authority_pk.pem to node:



```bash

mkdir -p /etc/authority

cp sovereign/authority_pk.pem /etc/authority/pax-coder-authority-pk.pem
```



### Issue: "Signature verification failed"



**Possible causes:**

1. Wrong authority_pk.pem (mismatched keypair)

2. Capability modified after signing

3. Gate using node_pk.pem instead of authority_pk.pem



**Verify:**

```bash

# Check gate is using correct key:

grep "AUTHORITY_PUBLIC_KEY_FILE" scripts/pax-coder-gate

# Should show: authority_pk.pem (not node_pk.pem)



# Test capability locally:

bash sovereign/sign_capability.sh test_cap.json

# Output should be: JSON|SIGNATURE_HEX

```

### Issue: "Node ID mismatch"

**Cause:** Capability for wrong node

**Solution:** Create new capability with correct node_id:

```bash

# Verify local node ID:

cat sovereign/node.json | grep node_id

# Create capability with matching node_id:

cat > capability_$NODE_ID.json << EOF

{

  "node_id": "$(cat sovereign/node.json | grep -o '"node_id":"[^"]*"' | cut -d'"' -f4)",

  ...

}

EOF

```



---



## 7. Testing



### 7.1 Test Authority Signatures



```bash

# Run comprehensive test suite:

bash scripts/test_authority_key_separation.sh

# Expected: 8/8 tests pass
```



### 7.2 Manual Verification



```bash

# Create test capability

cat > test_cap.json << EOF

{

  "node_id": "test-node",

  "release_id": "1.0.0",

  "commit": "abc123def456789abc123def456789abc123def4",

  "nonce": "test-nonce",

  "expires_at": "2026-12-31T23:59:59Z"

}

EOF



# Sign it

SIGNED=$(bash sovereign/sign_capability.sh test_cap.json)



# Verify signature (extract components)

JSON_PART=$(echo "$SIGNED" | cut -d'|' -f1)

SIG_PART=$(echo "$SIGNED" | cut -d'|' -f2)



# Verify with openssl

echo -n "$JSON_PART" > /tmp/msg.bin

printf '%s' "$(printf '%s' "$SIG_PART" | xxd -r -p)" > /tmp/sig.bin



openssl pkeyutl -verify -inkey sovereign/authority_pk.pem \

                 -pubin -sigfile /tmp/sig.bin \

                 -in /tmp/msg.bin



# Should output: "Signature Verified Successfully"

```

---

## 8. Reference

### Files

- `sovereign/authority_sk.pem` β€” Authority private key (secure server)
- `sovereign/authority_pk.pem` β€” Authority public key (distribute)
- `sovereign/sign_capability.sh` β€” Signing utility
- `scripts/pax-coder-gate` β€” Gate that verifies authorizations
- `scripts/test_authority_key_separation.sh` β€” Test suite

### Commands

- Generate keys: `bash sovereign/generate_authority_key.sh`
- Sign capability: `bash sovereign/sign_capability.sh <file.json>`
- Test gate: `bash scripts/test_authority_key_separation.sh`
- Verify clone: `bash scripts/verify-clone`

### Related Documentation

- [ADR-0010: Public Repository vs. Production Authorization Separation](./adr/0010-public-repository-authorization-separation.md)
- [ADR-0009: Protected Execution Capability Gate](./adr/0009-protected-execution-capability.md)
- [Authority Key Separation Audit](./AUTHORITY_KEY_SEPARATION_AUDIT.md)

---

*Bel Esprit D'Accord Irrevocable Trust Β· SnapKitty West Β· Evidence or Silence β€” 2026*