okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
c968d37a4
main
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 : 16if len (key )!= 32 or not isinstance (config_bytes ,bytes )or \ 17not isinstance (argv ,list )or not all (isinstance (arg ,str )for arg in argv ): 18raise ValueError ("invalid launch attestation inputs" ) 19args = json .dumps (argv ,ensure_ascii = False ,separators = ("," ,":" )).encode ("utf-8" ) 20message = b"strata-owned-launch-v1\0" + len (config_bytes ).to_bytes (8 ,"big" )+ config_bytes + \ 21len (args ).to_bytes (8 ,"big" )+ args 22return hmac .new (key ,message ,hashlib .sha256 ).hexdigest ()