okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221serve: owned-server contract for the terminal (ready file, owner guard, launch identity, queue deadline, stage telemetry)c968d37a4

main
963 B22 linesraw
1"""Private proof of the configuration and arguments read by an owned server.
2
3The owner passes a fresh secret through the child environment, then compares
4this MAC with the value on the authenticated telemetry endpoint.  The digest
5does not expose a reusable hash of the run config's credentials.
6"""
7
8from __future__ import annotations
9
10import hashlib
11import hmac
12import json
13
14
15def attestation(key: bytes, config_bytes: bytes, argv: list[str]) -> str:
16    if len(key) != 32 or not isinstance(config_bytes, bytes) or \
17            not isinstance(argv, list) or not all(isinstance(arg, str) for arg in argv):
18        raise ValueError("invalid launch attestation inputs")
19    args = json.dumps(argv, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
20    message = b"strata-owned-launch-v1\0" + len(config_bytes).to_bytes(8, "big") + config_bytes + \
21        len(args).to_bytes(8, "big") + args
22    return hmac.new(key, message, hashlib.sha256).hexdigest()