carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env python3
2"""Generate the launch binding with Python integers, independent of Go code."""
3import base64
4import hashlib
5import json
6from pathlib import Path
7
8root = Path(__file__).parent
9identity = lambda n: base64.urlsafe_b64encode(bytes([n]) * 32).decode().rstrip('=')
10c = {
11 'version': 2, 'account': 'bds', 'app': 'home',
12 'host': 'overnight-home.bds.oncarlos.com',
13 'request_id': identity(1), 'attempt_id': identity(2),
14 'request_digest': '1' * 64, 'record_identity': '2' * 64,
15 'artifact_digest': '3' * 64, 'environment_envelope_digest': '4' * 64,
16 'guard_generation': 9223372036854775807, 'input_sha256': '5' * 64,
17 'database_path': '/data/<home>&/☃.db',
18 'database_device': 18446744073709551615, 'database_inode': 9007199254740993,
19 'execution_deadline': '2026-09-11T20:00:00.123456789Z',
20 'execution_kind': 'compatibility-check', 'operation_id': identity(3),
21 'expected_state_sha256': '6' * 64,
22 'closed_checkpoint': {
23 'version': 1, 'preparation_id': identity(4),
24 'completed_at': '2026-09-11T19:59:59.123456789Z',
25 'main_length': 268435456, 'main_sha256': '7' * 64,
26 'evidence_sha256': '',
27 },
28}
29p = c['closed_checkpoint']
30values = ['carlos/closed-checkpoint/v1'] + [c[k] for k in [
31 'account', 'app', 'host', 'operation_id', 'request_id', 'attempt_id',
32 'request_digest', 'record_identity', 'artifact_digest',
33 'environment_envelope_digest', 'guard_generation', 'input_sha256',
34 'expected_state_sha256', 'database_path', 'database_device',
35 'database_inode', 'execution_deadline',
36]] + [p[k] for k in ['preparation_id', 'completed_at', 'main_length', 'main_sha256']]
37binding = json.dumps(values, ensure_ascii=False, separators=(',', ':'))
38for char, escaped in [('<', '\\u003c'), ('>', '\\u003e'), ('&', '\\u0026'),
39 ('\u2028', '\\u2028'), ('\u2029', '\\u2029')]:
40 binding = binding.replace(char, escaped)
41binding = binding.encode()
42p['evidence_sha256'] = hashlib.sha256(binding).hexdigest()
43(root / 'launch-v2.json').write_text(json.dumps(c, ensure_ascii=False, indent=2) + '\n')
44(root / 'launch-v2-binding.json').write_bytes(binding)
45