io.net 백서

io.net

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 31쪽 중 9쪽

attested machine ## Key Components ### Trusted Execution Environment (TEE) The GPU runs inside a Trusted Execution Environment that provides: * **Memory isolation** - your data is encrypted in memory and inaccessible to the host * **Code integrity** - only authorized code can run inside the TEE * **Hardware attestation** - the GPU can prove its identity and configuration ### Attestation Agent (Open Source) The attestation agent running on GPU machines is fully open source. You can audit the code that generates attestation reports and signs responses: **Repository:** [https://github.com/ionet-official/cc-attestation-agent-api](https://github.com/ionet-official/cc-attestation-agent-api) This transparency allows you to: * Verify what code is running inside the TEE * Understand exactly what is being attested * Build confidence in the verification process ### Attestation Reports When you request attestation, you receive: | Field | Description | | - | - | | `gpu` | NVIDIA GPU attestation report proving the GPU identity and TEE state | | `cpu` | CPU attestation report (when available) for additional verification | | `image_digest` | SHA256 hash of the container image running in the TEE | | `signing_address` | Public key the machine will use to sign inference responses | | `nonce` | Your nonce echoed back, proving freshness | ### Response Signatures Every inference response includes cryptographic signatures in the response headers: | Header | Description | | - | - | | `text` | The content that was signed | | `signature` | Cryptographic signature of the text | | `signing_address` | Public key that signed (matches attestation report) | | `signing_algo` | Algorithm used for signing | ## What You Can Prove | Check | What It Proves | | - | - | | GPU attestation report is valid | Response came from genuine NVIDIA GPU in TEE mode | | `image_digest` matches release | Running container hasn't been tampered with | | `signing_address` matches attestation | Responses are signed by the attested machine | | Signature verifies | Response was not tampered with in transit and signed on attested machine | | Nonce matches your request | Attestation is fresh, not replayed | ## Privacy Guarantees Confidential compute operates in **Zero Data Retention (ZDR) mode**: * Your prompts and responses are **never stored** * Only token counts are recorded for billing * No logs of conversation content exist ## What's Next * [Quick Start API](./quick-start) - For developers building integrations * [Confidential Chat](./confidential-chat) - Use the web interface for private conversations * [Verification Guide](./verification-guide) - Deep dive into verifying attestation and signatures # Quick Start API Source: https://io.net/docs/guides/confidential-inference/quick-start This guide walks you through running your first verifiable AI inference with io.net's Confidential Compute. ## Prerequisites * io.net API key ([get one here](https://ai.io.net/ai/api-keys)) * `curl` or Python 3.7+ ## Step 1: Find Models with Attestation Support First, list available models and filter for those supporting attestation: ### curl ```bash theme={null} curl -s https://api.intelligence.io.solutions/v1/models \ -H "Authorization: Bearer $IO_API_KEY" | \ jq '.data[] | select(.supports_attestation == true) | {name, model_id}' ``` ### Python ```python theme={null} import requests response = requests.get( "https://api.intelligence.io.solutions/v1/models", headers={"Authorization": f"Bearer {IO_API_KEY}"} ) models = response.json()["data"] attestation_models = [m for m in models if m.get("supports_attestation")] for model in attestation_models: print(f"{model['name']}: {model['model_id']}") ``` Note the `model_id` (UUID) for a model you want to use. ## Step 2: Get Attestation Report Before running inference, request an attestation report to verify the GPU machine. Generate a unique nonce (random string) for freshness verification. ### curl ```bash theme={null} # Generate a random nonce NONCE=$(openssl rand -hex 16) # Request attestation report curl -X POST https://api.intelligence.io.solutions/v1/private/attestation \ -H "Authorization: Bearer $IO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model_id": "YOUR_MODEL_UUID_HERE", "nonce": "'$NONCE'" }' ``` ### Python ```python theme={null} import secrets import requests # Generate a random nonce nonce = secrets.token_hex(16) response = requests.post( "https://api.intelligence.io.solutions/v1/private/attestation", headers={ "Authorization": f"Bearer {IO_API_KEY}", "Content-Type": "application/json" }, json={ "model_id": "YOUR_MODEL_UUID_HERE", "nonce": nonce } ) attestation = response.json() # Nonce is padded to 64 hex characters - verify prefix matches print(f"Nonce verified: {attestation['nonce'].startswith(nonce)}") print(f"Signing address: {attestation['signing_address']}") ``` ### Example Response ```json theme={null} { "nonce": "87ebbef3ceb69d2d6d7edc1b05c42ad900000000000000000000000000000000", "gpu": { "nonce": "87ebbef3ceb69d2d6d7edc1b05c42ad900000000000000000000000000000000", "arch": "HOPPER", "evidence_list": [ { "evidence": "<base64-encoded attestation evidence>", "certificate": "<base64-encoded certificate chain>" } ], "claims_version": "3.0" }, "cpu": { "quote": "<hex-encoded CPU attestation quote>" }, "signing_address": "0xf52373547CAa0EeCB0fcD34042D7518E79aA80cC", "image_digest": "sha256:cf47db862b96b243e077a80ee51afa2c007604bf3c648232d42144947e56c339" } ``` **`Save the signing_address`** - you'll use it to verify response signatures. **`Verify the image_digest`** - compare with the expected digest published in the [latest official release](https://github.com/ionet-official/cc-attestation-agent-api/releases) to confirm the running container hasn't been tampered with. ## Step 3: Run Confidential Inference Now run inference using the confidential completions endpoint. The request format is OpenAI-compatible. ### curl ```bash theme={null} curl -X POST https://api.intelligence.io.solutions/v1/private/completions \ -H "Authorization: Bearer $IO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "meta-llama/Llama-3.3-70B-Instruct", "messages": [ {"role": "user", "content": "What is confidential computing?"} ], "max_tokens": 5000 }' \ -i # Include response headers ``` ### Python ```python theme={null} response = requests.post( "https://api.intelligence.io.solutions/v1/private/completions", headers={ "Authorization": f"Bearer {IO_API_KEY}", "Content-Type": "application/json" }, json={ "model": "meta-llama/Llama-3.3-70B-Instruct", "messages": [ {"role": "user", "content": "What is confidential computing?"} ], "max_tokens": 5000 } ) # Get the response body completion = response.json() print(completion["choices"][0]["message"]["content"]) # Get signature headers for verification signature_headers = { "text": response.headers.get("text"), "signature": response.headers.get("signature"), "signing_address": response.headers.get("signing_address"), "signing_algo": response.headers.get("signing_algo"), "image_digest": response.headers.get("image_digest"), } ``` ### Response Headers The response includes signature headers for verification: ``` text: <signed content> signature: <cryptographic signature> signing_address: 0x1234...abcd signing_algo: ecdsa image_digest: sha256:...c00 ``` ## Step 4: Verify the Response Signature Verify that the response came from the attested machine by checking the signature. ### Python (with eth\_account) ```python theme={null} from eth_account.messages import encode_defunct from eth_account import Account def verify_response(signature_headers, expected_signing_address): """Verify the response signature matches the attested machine.""" text = signature_headers["text"] signature = signature_headers["signature"] signing_address = signature_headers["signing_address"] # Verify signing address matches attestation if signing_address.lower() != expected_signing_address.lower(): raise ValueError("Signing address does not match attestation!") # Verify signature message = encode_defunct(text=text) recovered_address = Account.recover_message(message, signature=signature) if recovered_address.lower() != signing_address.lower(): raise ValueError("Signature verification failed!") return True # Verify using the signing_address from Step 2 signing_address_from_attestation = attestation["signing_address"] verify_response(signature_headers, signing_address_from_attestation) print("Response verified!") ``` ## Complete Example Here's a complete Python script that performs verified confidential inference: ```python theme={null} import secrets import requests from eth_account.messages import encode_defunct from eth_account import Account IO_API_KEY = "your-api-key" BASE_URL = "https://api.intelligence.io.solutions/v1" PRIVATE_URL = "https://api.intelligence.io.solutions/v1/private" def get_attestation_models(): """Get models that support attestation.""" response = requests.get( f"{BASE_URL}/models", headers={"Authorization": f"Bearer {IO_API_KEY}"} ) models = response.json()["data"] return [m for m in models if m.get("supports_attestation")] def get_attestation(model_id: str, nonce: str): """Get attestation report for a model.""" response = requests.post( f"{PRIVATE_URL}/attestation", headers={ "Authorization": f"Bearer {IO_API_KEY}", "Content-Type": "application/json" }, json={"model_id": model_id, "nonce": nonce} ) response.raise_for_status() return response.json() def confidential_completion(model: str, messages: list): """Run confidential inference and return response with headers.""" response = requests.post( f"{PRIVATE_URL}/completions", headers={ "Authorization": f"Bearer {IO_API_KEY}", "Content-Type": "application/json" }, json={"model": model, "messages": messages} ) response.raise_for_status() return { "body": response.json(), "signature_headers": { "text": response.headers.get("text"), "signature": response.headers.get("signature"), "signing_address": response.headers.get("signing_address"), "signing_algo": response.headers.get("signing_algo"), "image_digest": response.headers.get("image_digest"), } } def verify_signature(text: str, signature: str, expected_address: str): """Verify response signature.""" message = encode_defunct(text=text) recovered = Account.recover_message(message, signature=signature) return recovered.lower() == expected_address.lower() # Main flow if __name__ == "__main__": # 1. Find an attestation-enabled model models = get_attestation_models() model = models[0] print(f"Using model: {model['name']}") # 2. Get attestation with fresh nonce nonce = secrets.token_hex(16) attestation = get_attestation(model["model_id"], nonce) # Verify nonce freshness (nonce is padded to 64 hex chars) assert attestation["nonce"].startswith(nonce), "Nonce mismatch!" signing_address = attestation["signing_address"] print(f"Attestation verified, signing address: {signing_address}") # 3. Run confidential inference result = confidential_completion( model=model["name"], messages=[{"role": "user", "content": "Hello, explain TEE in one sentence."}] ) # 4. Verify response signature headers = result["signature_headers"] assert headers["signing_address"].lower() == signing_address.lower(), \ "Signing address mismatch!" assert verify_signature( headers["text"], headers["signature"], signing_address ), "Signature verification failed!" print("Response verified!") print(result["body"]["choices"][0]["message"]["content"]) ``` ## What's Next * [Confidential Chat](./confidential-chat) - Use the web interface for private conversations * [Verification Guide](./verification-guide) - Deep dive into verifying attestation and signatures # Verification Guide Source: https://io.net/docs/guides/confidential-inference/verification-guide This guide explains how to verify that your AI inference ran on genuine trusted hardware and that responses haven't been tampered with. ## Verification Checklist | Check | What It Proves | How to Verify | | - | - | - | | Nonce matches | Attestation is fresh, not replayed | Compare returned nonce with your generated nonce | | GPU report is valid | Machine has genuine NVIDIA GPU in TEE mode | Verify report against NVIDIA's root certificates | | CPU report is valid | Machine's CPU is in confidential compute mode | Verify report against AMD/Intel attestation services | | `image_digest` matches | Running container hasn't been tampered with | Compare with expected digest from official release | | `signing_address` matches | Responses come from attested machine | Compare header with attestation report | | Signature verifies | Response wasn't modified in transit | Cryptographic signature verification | ## Understanding the Attestation Report ### Nonce Verification The nonce prevents replay attacks. Always: 1. Generate a **unique, random nonce** for each attestation request 2. Verify the returned nonce **starts with** what you sent (it gets padded to 64 hex characters) 3. Never reuse nonces ```python theme={null} import secrets # Generate fresh nonce nonce = secrets.token_hex(16) # 32 character hex string # After receiving attestation - nonce is padded with zeros to 64 chars # e.g., "87ebbef3ceb69d2d6d7edc1b05c42ad900000000000000000000000000000000" assert attestation["nonce"].startswith(nonce), "Nonce mismatch - possible replay attack!" ``` ### GPU Attestation Report The `gpu` field contains NVIDIA's hardware attestation: ```json theme={null} { "gpu": { "nonce": "87ebbef3ceb69d2d6d7edc1b05c42ad900000000000000000000000000000000", "arch": "HOPPER", "evidence_list": [ { "evidence": "<base64-encoded attestation evidence>", "certificate": "<base64-encoded certificate chain to NVIDIA root>" } ], "claims_version": "3.0" } } ``` This proves: * The GPU is a genuine NVIDIA device (architecture identified, e.g., "HOPPER") * The GPU is running in Confidential Computing mode * The GPU's firmware and configuration are in a known-good state * Multiple GPUs may have multiple evidence entries in `evidence_list` **Verification:** Use NVIDIA's attestation API to verify the GPU evidence list: * [NVIDIA Multi-GPU Attestation API](https://docs.api.nvidia.com/attestation/reference/attestmultigpu) * Submit the `evidence_list` from the attestation response * The API validates the certificate chain and returns verification status ### CPU Attestation Report The `cpu` field (when present) contains CPU-level attestation: ```json theme={null} { "cpu": { "quote": "<hex-encoded CPU attestation quote>" } } ``` This proves: * The CPU is running in a Trusted Execution Environment (AMD SEV-SNP or Intel TDX) * The VM's memory is encrypted and isolated from the host **Verification:** Use the proof verifier to verify the CPU attestation quote: * [t16z Proof Verifier](https://proof.t16z.com/) * Submit the `cpu.quote` from the attestation response * The verifier validates the quote against Intel TDX attestation ### Image Digest The `image_digest` field contains the SHA256 hash of the container image running in the TEE: ```json theme={null} { "image_digest": "sha256:cf47db862b96b243e077a80ee51afa2c007604bf3c648232d42144947e56c339" } ``` This allows you to verify that the expected code is running inside the TEE. **Verification:** Compare the `image_digest` with the expected digest published in the [latest official release](https://github.com/ionet-official/cc-attestation-agent-api/releases). If the digests match, you can be confident the running container hasn't been tampered with. ### Signing Address The `signing_address` is the Ethereum-style public address the attested machine will use to sign inference responses: ```json theme={null} { "signing_address": "0xf52373547CAa0EeCB0fcD34042D7518E79aA80cC" } ``` This key is generated inside the TEE and its binding to the attestation report proves that: * Only the attested machine holds the private key * Responses signed with this key came from the attested hardware ## Verifying Response Signatures Every confidential inference response includes signature headers: | Header | Description | | - | - | | `text` | The content that was signed (typically the response body) | | `signature` | Cryptographic signature over `text` | | `signing_address` | Public key that created the signature | | `signing_algo` | Signing algorithm (e.g., ecdsa) | | `image_digest` | SHA256 hash of the container image running in the TEE | ### Verification Steps 1. **Verify signing address matches attestation** ```python theme={null} assert response_headers["signing_address"].lower() == \ attestation["signing_address"].lower(), \ "Signing address mismatch!" ``` 2. **Verify the cryptographic signature** For `ecdsa` signatures (Ethereum-style): ```python theme={null} from eth_account.messages import encode_defunct from eth_account import Account def verify_ecdsa_signature(text: str, signature: str, expected_address: str) -> bool: """Verify an Ethereum-style signature.""" message = encode_defunct(text=text) recovered_address = Account.recover_message(message, signature=signature) return recovered_address.lower() == expected_address.lower() # Verify is_valid = verify_ecdsa_signature( text=response_headers["text"], signature=response_headers["signature"], expected_address=attestation["signing_address"] ) if not is_valid: raise SecurityError("Response signature verification failed!") ``` 3. **Verify content integrity** Ensure the signed `text` matches the response you received: ```python theme={null} import json # For non-streaming responses, verify the signed text matches the response response_body = response.json() signed_text = response_headers["text"] # The exact format of signed_text depends on implementation # Typically it's the JSON response body or a hash of it ``` ## Complete Verification Flow ```python theme={null} import secrets import requests from eth_account.messages import encode_defunct from eth_account import Account class ConfidentialClient: def __init__(self, api_key: str, base_url: str = "https://api.intelligence.io.solutions/v1/private"): self.api_key = api_key self.base_url = base_url self.attestation = None self.nonce = None def _headers(self): return { "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json" } def attest(self, model_id: str) -> dict: """Get and verify attestation for a model.""" # Generate fresh nonce self.nonce = secrets.token_hex(16) response = requests.post( f"{self.base_url}/attestation", headers=self._headers(), json={"model_id": model_id, "nonce": self.nonce} ) response.raise_for_status() self.attestation = response.json() # Verify nonce freshness (nonce is padded to 64 hex chars) if not self.attestation["nonce"].startswith(self.nonce): raise SecurityError("Nonce mismatch - possible replay attack!") # TODO: Verify GPU/CPU attestation reports against root certificates # This requires NVIDIA/AMD attestation verification libraries return self.attestation def complete(self, model: str, messages: list, **kwargs) -> dict: """Run verified confidential inference.""" if not self.attestation: raise ValueError("Must call attest() before complete()") response = requests.post( f"{self.base_url}/completions", headers=self._headers(), json={"model": model, "messages": messages, **kwargs} ) response.raise_for_status() # Extract signature headers sig_headers = { "text": response.headers.get("text"), "signature": response.headers.get("signature"), "signing_address": response.headers.get("signing_address"), "signing_algo": response.headers.get("signing_algo") } # Verify signing address matches attestation if sig_headers["signing_address"].lower() != \ self.attestation["signing_address"].lower(): raise SecurityError("Sig
프로젝트로 돌아가기