// Copyright © 2026 Riley Betts Ltd (rileybetts.ai) // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package lean_tee.v1; // Normative wire contract for lean-tee (Lean stubs in LeanTee/Proto.lean). message Measurement { bytes code_hash = 1; bytes config_hash = 2; } message PublicIO { bytes inputs = 1; bytes outputs = 2; } message ReceiptMeta { string version = 1; string domain = 2; string sink_id = 3; // Empty => sha256+mock (lean-tee-v1). See docs/CRYPTO.md. string crypto_suite = 4; // Empty => off. "local" => optional local sealed-worker confidentiality (not Nitro). string confidentiality = 5; // Hex SHA-256 of secret_inputs when confidentiality=local; never the secret bytes. string secret_digest_hex = 6; } message TeeReceipt { Measurement measurement = 1; PublicIO public_io = 2; bytes result_hash = 3; bytes nonce = 4; bytes proof_ref = 5; ReceiptMeta meta = 6; } message ExecuteRequest { bytes guest_id = 1; // Raw rules/config bytes (server stores SHA256 as configHash), unless program mode. bytes config_hash = 2; bytes inputs = 3; bytes nonce = 4; bool submit_to_sink = 5; // Lean-specified GuestProg bytes (`guest_prog_runtime`). Empty => registry guest. bytes program = 6; // Hex id from LoadProgram (alternative to inline program). string program_id = 7; // Secret bytes for confidentiality=local (rules or payload). Rejected when mode=off. // Never copied into PublicIO; only SHA-256 digest is receipt-bound. bytes secret_inputs = 8; } message ExecuteResponse { string job_id = 1; TeeReceipt receipt = 2; string status = 3; } message GetReceiptRequest { string job_id = 1; } message MeasureRequest { bytes config_hash = 1; bytes guest_id = 2; bytes program = 3; } message MeasureResponse { Measurement measurement = 1; } message ProveRequest { Measurement measurement = 1; bytes inputs = 2; bytes program = 3; // Raw rules/config bytes for compliance path (SHA256 must equal measurement.config_hash). // Empty when GuestProg mode or when only the hash is known. bytes rules = 4; } message ProveResponse { bytes outputs = 1; bytes proof_ref = 2; // Empty => sha256+mock. prove_server sets sha256+sp1 after host-verified SP1 prove. string crypto_suite = 3; } message AcceptReceiptRequest { TeeReceipt receipt = 1; bytes policy_code_hash = 2; bytes policy_config_hash = 3; bool proof_ok = 4; // If "local", require receiptMeta.confidentiality=local and non-empty secret_digest_hex. string require_confidentiality = 5; } message AcceptReceiptResponse { bool accepted = 1; string reason = 2; } message SubmitRequest { TeeReceipt receipt = 1; } message SubmitAck { bool ok = 1; string ref = 2; string message = 3; } // Lean-specified programs — executed by measured RISC-V guest_prog_runtime. message GuestProgram { bytes program = 1; string name = 2; } message LoadProgramRequest { GuestProgram program = 1; } message LoadProgramResponse { string program_id = 1; bytes program_hash = 2; bytes runtime_code_hash = 3; string runtime_guest_id = 4; } message GetProgramRequest { string program_id = 1; } message GetProgramResponse { GuestProgram program = 1; bytes program_hash = 2; } service Tee { rpc Execute(ExecuteRequest) returns (ExecuteResponse); rpc GetReceipt(GetReceiptRequest) returns (ExecuteResponse); rpc Measure(MeasureRequest) returns (MeasureResponse); rpc LoadProgram(LoadProgramRequest) returns (LoadProgramResponse); rpc GetProgram(GetProgramRequest) returns (GetProgramResponse); } service Prove { rpc Prove(ProveRequest) returns (ProveResponse); } service Verify { rpc AcceptReceipt(AcceptReceiptRequest) returns (AcceptReceiptResponse); } service AnchorSink { rpc Submit(SubmitRequest) returns (SubmitAck); }