الانتقال إلى المحتوى الرئيسي
يقدّم Venice نماذج معزّزة للخصوصية تعمل داخل بيئات تنفيذ موثوقة (TEE) وتدعم التشفير الكامل من طرف إلى طرف (E2EE). توفّر هذه النماذج ضمانات تشفيرية تكفل أن تبقى بياناتك خاصة — حتى عن Venice نفسها.

فهم مستويات الخصوصية

النوعالبادئةما يعنيه
TEEtee-*يعمل النموذج داخل جيب مؤمَّن عتاديًا. لا يستطيع Venice الوصول إلى الحسابات. يمكنك التحقق من ذلك عبر التصديق (attestation).
E2EEe2ee-*تشفير كامل من طرف إلى طرف. تُشفَّر مطالباتك على جانب العميل قبل إرسالها. فقط TEE يمكنه فك تشفيرها.
تشمل نماذج E2EE حماية TEE بالإضافة إلى تشفير من جانب العميل. أما نماذج TEE فتوفر أمان الجيب دون اشتراط تشفير من جانب العميل.

النماذج المتاحة

جارٍ التحميل…
راجع صفحة النماذج للاطلاع على القائمة الكاملة مع التسعير وحدود السياق.

نماذج TEE

تعمل نماذج TEE داخل جيوب مؤمَّنة عتاديًا (Intel TDX، NVIDIA Confidential Computing). تكون أوزان النموذج وبياناتك محمية من النظام المضيف — بما في ذلك البنية التحتية لـ Venice.

الاستخدام الأساسي

تعمل نماذج TEE تمامًا مثل النماذج العادية:
from openai import OpenAI

client = OpenAI(
    api_key="your-venice-api-key",
    base_url="https://api.venice.ai/api/v1"
)

response = client.chat.completions.create(
    model="tee-qwen3-5-122b-a10b",
    messages=[{"role": "user", "content": "Explain quantum computing"}]
)

print(response.choices[0].message.content)

التحقق من تصديق TEE

يمكنك التحقق تشفيريًا من أن النموذج يعمل داخل TEE حقيقي عبر جلب تقرير التصديق الخاص به:
# توليد nonce عشوائي (يمنع هجمات إعادة التشغيل)
NONCE=$(openssl rand -hex 16)

# جلب التصديق
curl "https://api.venice.ai/api/v1/tee/attestation?model=tee-qwen3-5-122b-a10b&nonce=$NONCE" \
  -H "Authorization: Bearer $API_KEY_VENICE"
تتضمن استجابة التصديق:
الحقلالوصف
verifiedما إذا نجح التصديق في التحقق من جانب الخادم
nonceالـ nonce الخاص بك، يؤكد حداثة الاستجابة
modelمعرّف النموذج المُصدَّق عليه
tee_providerمعرّف مزوّد TEE
intel_quoteاقتباس Intel TDX الخام (base64) للتحقق من جانب العميل
nvidia_payloadبيانات تصديق GPU من NVIDIA (إن وُجدت)
signing_keyالمفتاح العام للتحقق من توقيع الاستجابة (يُطلب عادةً لتدفقات E2EE؛ وقد يُحذف لبعض نماذج TEE العادية)
signing_addressعنوان Ethereum المشتق من مفتاح التوقيع
للاستخدام في الإنتاج، تحقق من التصديق من جانب العميل عبر تحليل اقتباس Intel TDX والتحقق من تصديق NVIDIA.
بالنسبة للتحقق من نموذج TEE العادي، يكفي signing_address وحقول التحقق من جانب الخادم لإجراء فحوصات التصديق الأساسية. ويُطلب signing_key عندما تحتاج إلى اتفاق مفاتيح E2EE من جانب العميل وفحوصات ربط مفاتيح صارمة.

توقيعات الاستجابة

يمكن لنماذج TEE توقيع استجاباتها، ما يُثبت أن المخرجات صدرت من الجيب المُصدَّق عليه:
# بعد الحصول على إكمال، تحقق من التوقيع
curl "https://api.venice.ai/api/v1/tee/signature?model=tee-qwen3-5-122b-a10b&request_id=chatcmpl-abc123" \
  -H "Authorization: Bearer $API_KEY_VENICE"

نماذج E2EE

تضيف نماذج E2EE تشفيرًا من جانب العميل فوق حماية TEE. تُشفَّر مطالباتك قبل مغادرة جهازك، ولا يستطيع فك تشفيرها سوى TEE. يستخدم Venice E2EE:
  • ECDH (Elliptic Curve Diffie-Hellman) على secp256k1 لتبادل المفاتيح
  • HKDF-SHA256 لاشتقاق المفاتيح
  • AES-256-GCM للتشفير المتماثل
  • تصديق TEE للتحقق من أن النموذج يعمل في جيب آمن
يتطلب E2EE تنفيذًا من جانب العميل. توضّح الأمثلة أدناه البروتوكول الكامل.

كيف يعمل E2EE

1

توليد زوج مفاتيح مؤقت

يولّد العميل زوج مفاتيح secp256k1 لهذه الجلسة.
2

جلب تصديق TEE

يطلب العميل /api/v1/tee/attestation ويتلقّى المفتاح العام للنموذج، ودليل التصديق، والـ nonce.
3

التحقق من التصديق

يتحقق العميل من تطابق الـ nonce، وتعطيل وضع التصحيح، وصلاحية التصديق.
4

تشفير الرسائل

يُشفّر العميل المطالبات باستخدام السر المشترك ECDH → HKDF → AES-GCM.
5

إرسال الطلب

يرسل العميل الطلب مع رؤوس E2EE (X-Venice-TEE-Client-Pub-Key، X-Venice-TEE-Model-Pub-Key، X-Venice-TEE-Signing-Algo).
6

معالجة TEE

يفك TEE تشفير الطلب، ويعالجه، ويُشفّر الاستجابة.
7

فك تشفير الاستجابة

يتلقى العميل أجزاءً مشفّرة ويفك تشفيرها باستخدام المفتاح الخاص.

المتطلبات المسبقة

JavaScript (Node.js ESM):
npm install elliptic @noble/ciphers @noble/hashes
Python:
pip install cryptography ecdsa requests

الخطوة 1: التحقق من دعم النموذج لـ E2EE

أولًا، تحقق من أن النموذج يدعم E2EE عبر فحص نقطة النهاية /models.
async function getE2EEModels(apiKey) {
  const response = await fetch('https://api.venice.ai/api/v1/models', {
    headers: { Authorization: `Bearer ${apiKey}` },
  })
  const { data } = await response.json()

  return data.filter(model => model.model_spec?.capabilities?.supportsE2EE === true)
}

// مثال على الاستخدام
const models = await getE2EEModels('your-api-key')
console.log('E2EE Models:', models.map(m => m.id))
// المخرجات: ['e2ee-qwen3-5-122b-a10b', 'e2ee-glm-5', ...]

الخطوة 2: توليد زوج مفاتيح مؤقت

ولّد زوج مفاتيح جديدًا لكل جلسة. يجب الإبقاء على المفتاح الخاص في الذاكرة فقط وتصفيره بأمان بعد الاستخدام.
import { ec as EC } from 'elliptic'

function generateEphemeralKeyPair() {
  const ec = new EC('secp256k1')
  const keyPair = ec.genKeyPair()

  return {
    privateKey: new Uint8Array(keyPair.getPrivate().toArray('be', 32)),
    publicKeyHex: keyPair.getPublic('hex'), // التنسيق غير المضغوط (65 بايت hex)
  }
}

// أمان: قم بملء المفتاح الخاص بالأصفار عند الانتهاء
function zeroFill(arr) {
  arr.fill(0)
}

مساعدات التحقق

استخدم دوال المساعدة هذه للتحقق من المفاتيح والمحتوى المشفّر قبل إرسال الطلبات.
function validateClientPubkey(pubkeyHex) {
  if (pubkeyHex.length !== 130 || !pubkeyHex.startsWith('04')) {
    throw new Error(`Client pubkey must be 130 hex chars starting with '04' (got ${pubkeyHex.length})`)
  }
}

function isValidEncrypted(s) {
  // الحد الأدنى: ephemeral_pub (65) + nonce (12) + tag (16) = 93 بايت = 186 محرف hex
  return s.length >= 186 && /^[0-9a-fA-F]+$/.test(s)
}

الخطوة 3: جلب تصديق TEE والتحقق منه

يُثبت التصديق أن النموذج يعمل داخل TEE حقيقي. تحقق دائمًا من التصديق قبل الوثوق بمفتاح النموذج العام.
مهم: طول الـ nonce — يجب أن يكون nonce العميل بطول 32 بايت (64 محرف hex). تشترط بعض مزوّدي TEE 32 بايت بالضبط وترفض أي nonce أقصر.
import crypto from 'crypto'

async function fetchAndVerifyAttestation(modelId, apiKey) {
  // توليد nonce للعميل للحماية من الإعادة (32 بايت = 64 محرف hex)
  const clientNonce = crypto.randomBytes(32).toString('hex')

  const response = await fetch(
    `https://api.venice.ai/api/v1/tee/attestation?model=${encodeURIComponent(modelId)}&nonce=${clientNonce}`,
    { headers: { Authorization: `Bearer ${apiKey}` } }
  )

  const attestation = await response.json()

  // التحقق من التصديق
  if (attestation.verified !== true) {
    throw new Error('TEE attestation verification failed on server')
  }

  if (attestation.nonce !== clientNonce) {
    throw new Error('Attestation nonce mismatch - possible replay attack')
  }

  // الحصول على المفتاح العام للنموذج للتشفير
  const modelPublicKey = attestation.signing_key || attestation.signing_public_key
  if (!modelPublicKey) {
    throw new Error('No signing key in attestation response')
  }

  return {
    modelPublicKey,
    signingAddress: attestation.signing_address,
    attestation,
  }
}

الخطوة 4: تشفير الرسائل

قم بتشفير رسائل المستخدم والنظام قبل الإرسال. تحتاج رسائل دور user وsystem فقط إلى التشفير.
عند وجود رؤوس E2EE، يجب تشفير جميع رسائل دور user وsystem. إرسال أي محتوى نصي عادي في هذه الأدوار سيؤدي إلى خطأ “Encrypted field is not valid hex”.
import { gcm } from '@noble/ciphers/aes.js'
import { hkdf } from '@noble/hashes/hkdf.js'
import { sha256 } from '@noble/hashes/sha2.js'
import { ec as EC } from 'elliptic'
import crypto from 'crypto'

const HKDF_INFO = new TextEncoder().encode('ecdsa_encryption')

function encryptMessage(plaintext, modelPublicKeyHex) {
  const ec = new EC('secp256k1')

  // تطبيع المفتاح العام (إضافة بادئة 04 إذا لزم الأمر)
  let normalizedKey = modelPublicKeyHex
  if (!normalizedKey.startsWith('04') && normalizedKey.length === 128) {
    normalizedKey = '04' + normalizedKey
  }

  const modelPublicKey = ec.keyFromPublic(normalizedKey, 'hex')

  // توليد زوج مفاتيح مؤقت لهذه الرسالة
  const ephemeralKeyPair = ec.genKeyPair()

  // السر المشترك ECDH
  const sharedSecret = ephemeralKeyPair.derive(modelPublicKey.getPublic())
  const sharedSecretBytes = new Uint8Array(sharedSecret.toArray('be', 32))

  // اشتقاق مفتاح AES باستخدام HKDF
  const aesKey = hkdf(sha256, sharedSecretBytes, undefined, HKDF_INFO, 32)

  // توليد nonce عشوائي
  const nonce = crypto.randomBytes(12)

  // التشفير باستخدام AES-GCM
  const cipher = gcm(aesKey, nonce)
  const encrypted = cipher.encrypt(new TextEncoder().encode(plaintext))

  // الحصول على المفتاح العام المؤقت (غير مضغوط)
  const ephemeralPublic = new Uint8Array(ephemeralKeyPair.getPublic(false, 'array'))

  // الدمج: ephemeral_public (65 بايت) + nonce (12 بايت) + ciphertext
  const result = new Uint8Array(65 + 12 + encrypted.length)
  result.set(ephemeralPublic, 0)
  result.set(nonce, 65)
  result.set(encrypted, 65 + 12)

  return Buffer.from(result).toString('hex')
}

function encryptMessagesForE2EE(messages, modelPublicKey) {
  return messages.map(msg => {
    if (msg.role === 'user' || msg.role === 'system') {
      return {
        ...msg,
        content: encryptMessage(msg.content, modelPublicKey),
      }
    }
    return msg
  })
}

الخطوة 5: إرسال الطلب مع رؤوس E2EE

ضمِّن الرؤوس المطلوبة لتمكين معالجة E2EE.
الرأسالوصف
X-Venice-TEE-Client-Pub-Keyمفتاحك العام المؤقت (hex غير مضغوط، 130 محرف)
X-Venice-TEE-Model-Pub-Keyالمفتاح العام للنموذج من التصديق
X-Venice-TEE-Signing-Algoدائمًا ecdsa
async function sendE2EERequest(messages, model, e2eeContext, apiKey) {
  // تشفير الرسائل
  const encryptedMessages = encryptMessagesForE2EE(messages, e2eeContext.modelPublicKey)

  const response = await fetch('https://api.venice.ai/api/v1/chat/completions', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${apiKey}`,
      'Content-Type': 'application/json',
      // رؤوس E2EE
      'X-Venice-TEE-Client-Pub-Key': e2eeContext.publicKeyHex,
      'X-Venice-TEE-Model-Pub-Key': e2eeContext.modelPublicKey,
      'X-Venice-TEE-Signing-Algo': 'ecdsa',
    },
    body: JSON.stringify({
      model,
      messages: encryptedMessages,
      stream: true, // يتطلب E2EE البث المتدفق
    }),
  })

  return response
}

الخطوة 6: فك تشفير أجزاء الاستجابة

تكون الاستجابات من نماذج E2EE أجزاءً مشفّرة بترميز hex. فك تشفير كل جزء باستخدام مفتاحك الخاص.
import { gcm } from '@noble/ciphers/aes.js'
import { hkdf } from '@noble/hashes/hkdf.js'
import { sha256 } from '@noble/hashes/sha2.js'
import { ec as EC } from 'elliptic'

const HKDF_INFO = new TextEncoder().encode('ecdsa_encryption')

function hexToBytes(hex) {
  const h = hex.startsWith('0x') ? hex.slice(2) : hex
  const bytes = new Uint8Array(h.length / 2)
  for (let i = 0; i < bytes.length; i++) {
    bytes[i] = parseInt(h.substring(i * 2, i * 2 + 2), 16)
  }
  return bytes
}

function isHexEncrypted(s) {
  // الحد الأدنى: ephemeral_pub (65) + nonce (12) + tag (16) = 93 بايت = 186 محرف hex
  if (s.length < 186) return false
  return /^[0-9a-fA-F]+$/.test(s)
}

function decryptChunk(ciphertextHex, clientPrivateKey) {
  const raw = hexToBytes(ciphertextHex)

  // تحليل المكونات
  const serverEphemeralPubKey = raw.slice(0, 65)
  const nonce = raw.slice(65, 65 + 12)
  const ciphertext = raw.slice(65 + 12)

  // ECDH مع مفتاح الخادم المؤقت
  const ec = new EC('secp256k1')
  const clientKey = ec.keyFromPrivate(Buffer.from(clientPrivateKey))
  const serverKey = ec.keyFromPublic(Buffer.from(serverEphemeralPubKey))
  const sharedSecret = clientKey.derive(serverKey.getPublic())
  const sharedSecretBytes = new Uint8Array(sharedSecret.toArray('be', 32))

  // اشتقاق مفتاح AES
  const aesKey = hkdf(sha256, sharedSecretBytes, undefined, HKDF_INFO, 32)

  // فك التشفير
  const cipher = gcm(aesKey, nonce)
  const plaintext = cipher.decrypt(ciphertext)

  return new TextDecoder().decode(plaintext)
}

// معالجة الاستجابة المتدفقة
async function processE2EEStream(response, clientPrivateKey) {
  const reader = response.body.getReader()
  const decoder = new TextDecoder()
  let fullContent = ''

  while (true) {
    const { done, value } = await reader.read()
    if (done) break

    const text = decoder.decode(value)
    const lines = text.split('\n')

    for (const line of lines) {
      if (!line.startsWith('data: ')) continue
      const data = line.slice(6)
      if (data === '[DONE]') continue

      try {
        const chunk = JSON.parse(data)
        const content = chunk.choices?.[0]?.delta?.content

        if (content && isHexEncrypted(content)) {
          const decrypted = decryptChunk(content, clientPrivateKey)
          fullContent += decrypted
          process.stdout.write(decrypted) // إخراج في الوقت الفعلي
        } else if (content) {
          fullContent += content
          process.stdout.write(content)
        }
      } catch (e) {
        // تخطّي الأجزاء المشوّهة
      }
    }
  }

  return fullContent
}

مثال عملي كامل

import elliptic from 'elliptic';
import { gcm } from '@noble/ciphers/aes.js';
import { hkdf } from '@noble/hashes/hkdf.js';
import { sha256 } from '@noble/hashes/sha2.js';
import crypto from 'crypto';

const EC = elliptic.ec;

const API_KEY = process.env.API_KEY_VENICE;
const BASE_URL = 'https://api.venice.ai/api/v1';
const MODEL = 'e2ee-qwen3-5-122b-a10b';
const HKDF_INFO = new TextEncoder().encode('ecdsa_encryption');

function hexToBytes(hex) {
  const bytes = new Uint8Array(hex.length / 2);
  for (let i = 0; i < bytes.length; i++) {
    bytes[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16);
  }
  return bytes;
}

async function main() {
  // الخطوة 1: توليد زوج مفاتيح مؤقت
  console.log('🔑 Generating ephemeral key pair...');
  const ec = new EC('secp256k1');
  const keyPair = ec.genKeyPair();
  const clientPublicKeyHex = keyPair.getPublic('hex');

  // الخطوة 2: جلب التصديق والتحقق منه
  console.log('🔍 Fetching TEE attestation...');
  const clientNonce = crypto.randomBytes(32).toString('hex'); // مطلوب 32 بايت
  const attestationRes = await fetch(
    `${BASE_URL}/tee/attestation?model=${MODEL}&nonce=${clientNonce}`,
    { headers: { Authorization: `Bearer ${API_KEY}` } }
  );
  const attestation = await attestationRes.json();

  if (attestation.verified !== true || attestation.nonce !== clientNonce) {
    throw new Error('Attestation verification failed');
  }

  const modelPublicKey = attestation.signing_key || attestation.signing_public_key;
  console.log('✅ TEE attestation verified');

  // الخطوة 3: تشفير الرسالة
  console.log('🔐 Encrypting message...');
  const plaintext = 'What is 2+2? Answer briefly.';

  // تطبيع وتحليل المفتاح العام للنموذج
  let normalizedKey = modelPublicKey;
  if (!normalizedKey.startsWith('04') && normalizedKey.length === 128) {
    normalizedKey = '04' + normalizedKey;
  }

  const modelKey = ec.keyFromPublic(normalizedKey, 'hex');
  const ephemeralKeyPair = ec.genKeyPair();
  const sharedSecret = ephemeralKeyPair.derive(modelKey.getPublic());
  const sharedSecretBytes = new Uint8Array(sharedSecret.toArray('be', 32));
  const aesKey = hkdf(sha256, sharedSecretBytes, undefined, HKDF_INFO, 32);
  const nonce = crypto.randomBytes(12);
  const cipher = gcm(aesKey, nonce);
  const encrypted = cipher.encrypt(new TextEncoder().encode(plaintext));
  const ephemeralPublic = new Uint8Array(ephemeralKeyPair.getPublic(false, 'array'));

  const result = new Uint8Array(65 + 12 + encrypted.length);
  result.set(ephemeralPublic, 0);
  result.set(nonce, 65);
  result.set(encrypted, 77);

  const encryptedContent = Buffer.from(result).toString('hex');
  const messages = [{ role: 'user', content: encryptedContent }];

  // الخطوة 4: إرسال طلب E2EE
  console.log('📤 Sending encrypted request...');
  const response = await fetch(`${BASE_URL}/chat/completions`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      'Content-Type': 'application/json',
      'X-Venice-TEE-Client-Pub-Key': clientPublicKeyHex,
      'X-Venice-TEE-Model-Pub-Key': modelPublicKey,
      'X-Venice-TEE-Signing-Algo': 'ecdsa',
    },
    body: JSON.stringify({ model: MODEL, messages, stream: true }),
  });

  // الخطوة 5: فك تشفير الاستجابة
  console.log('📥 Decrypting response...\n');
  const reader = response.body.getReader();
  const decoder = new TextDecoder();

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    const text = decoder.decode(value);
    for (const line of text.split('\n')) {
      if (!line.startsWith('data: ') || line.includes('[DONE]')) continue;

      try {
        const chunk = JSON.parse(line.slice(6));
        const content = chunk.choices?.[0]?.delta?.content;
        if (!content) continue;

        if (/^[0-9a-fA-F]+$/.test(content) && content.length >= 186) {
          // فك التشفير
          const raw = hexToBytes(content);
          const serverEphemeralPub = raw.slice(0, 65);
          const nonce = raw.slice(65, 77);
          const ciphertext = raw.slice(77);

          const serverKey = ec.keyFromPublic(Buffer.from(serverEphemeralPub));
          const sharedSecret = keyPair.derive(serverKey.getPublic());
          const aesKey = hkdf(sha256, new Uint8Array(sharedSecret.toArray('be', 32)), undefined, HKDF_INFO, 32);
          const cipher = gcm(aesKey, nonce);
          const plaintext = new TextDecoder().decode(cipher.decrypt(ciphertext));
          process.stdout.write(plaintext);
        } else {
          process.stdout.write(content);
        }
      } catch {}
    }
  }

  console.log('\n\n🔐 Response decrypted end-to-end');
}

main().catch(console.error);

قيود E2EE

يفرض E2EE بعض القيود نتيجة متطلبات التشفير:
الميزةالحالة
البث المتدفقمطلوب (لا يُدعم عدم البث)
البحث على الويبمعطّل (قد يكشف المحتوى)
تحميل الملفاتغير مدعوم
استدعاء الدوالغير مدعوم
موجّه نظام Veniceمعطّل (يجب تشفيره من جانب العميل)

أفضل ممارسات الأمان

  1. ولّد أزواج مفاتيح جديدة لكل جلسة — لا تُعد استخدام المفاتيح المؤقتة
  2. املأ المفاتيح الخاصة بالأصفار — امسح بايتات المفتاح الخاص من الذاكرة عند الانتهاء
  3. تحقق من التصديق — تأكد دائمًا من verified: true ومطابقة nonce
  4. افحص وضع التصحيح — ارفض التصديقات من جيوب التصحيح
  5. استخدم البث المتدفق — يتطلب E2EE البث للتجزئة الصحيحة للتشفير
  6. عالج الأخطاء بأناقة — لا تُظهر أخطاء فك التشفير للمستخدمين
  7. استخدم nonce بحجم 32 بايت — تتطلب مزوّدات TEE 32 بايت بالضبط

أفضل الممارسات

لا تكتفِ بالثقة في استجابة verified: true. قم بتحليل اقتباس Intel TDX من جانب العميل وتحقق من أن القياسات تطابق القيم المتوقعة. بالنسبة إلى وحدات معالجة الرسومات من NVIDIA، تحقق من التصديق عبر خدمة التحقق من NVIDIA.
ولّد دائمًا nonce عشوائيًا جديدًا لكل طلب تصديق. يمنع ذلك هجمات إعادة التشغيل التي يمكن للمهاجم فيها تقديم تصديق قديم.
يجب أن يكون مفتاح التوقيع مرتبطًا بحقل TDX REPORTDATA. وهذا يُثبت أن المفتاح وُلّد داخل الجيب.
تحقق من أن تصديق TDX لا يحتوي على أعلام تصحيح مضبوطة. يمكن فحص جيب التصحيح ولا ينبغي الوثوق به في الإنتاج.
يتطلب E2EE تنفيذًا تشفيريًا دقيقًا. استخدم SDK الرسمية الخاصة بنا بدلًا من تنفيذ البروتوكول بنفسك.

التحقق من قدرات النموذج

يمكنك التحقق مما إذا كان النموذج يدعم TEE أو E2EE عبر نقطة نهاية النماذج:
curl https://api.venice.ai/api/v1/models \
  -H "Authorization: Bearer $API_KEY_VENICE" | jq '.data[] | select(.model_spec.capabilities.supportsTeeAttestation == true or .model_spec.capabilities.supportsE2EE == true) | {id, tee: .model_spec.capabilities.supportsTeeAttestation, e2ee: .model_spec.capabilities.supportsE2EE}'

معالجة الأخطاء

الخطأالسببالحل
TEE attestation verification failedلم يجتز التصديق التحققأعد المحاولة أو اتصل بالدعم
Attestation nonce mismatchهجوم إعادة تشغيل محتملولّد nonce جديدًا
TDX debug mode detectedالجيب في وضع التصحيحلا تستخدمه في الإنتاج
Failed to decrypt fieldفشل فك تشفير E2EE من جانب الخادمراجع تنفيذ التشفير لديك
E2EE requires streamingطلب غير متدفق إلى نموذج E2EEاضبط stream: true
Encrypted field is not valid hexإرسال نص عادي مع رؤوس E2EEشفّر جميع رسائل user/system
Invalid public keyتنسيق مفتاح خاطئاستخدم 130 محرف hex يبدأ بـ 04

استكشاف الأخطاء وإصلاحها

طول الـ nonce غير صحيح. تتطلب مزوّدات TEE 32 بايت (64 محرف hex) بالضبط.
  • استخدم crypto.randomBytes(32).toString('hex') (JS) أو secrets.token_hex(32) (Python)
  • خطأ شائع: secrets.token_hex(16) يُنتج 32 محرف hex (16 بايت)، وليس 32 بايت
  • تأكد من أن النموذج يدعم E2EE (supportsE2EE: true)
  • تحقق من أن مفتاح API صالح ولديه وصول إلى النموذج المطلوب
  • تحقق من اتصال الشبكة بـ Venice API
  • تأكد من أنك تستخدم نفس المفتاح الخاص الذي ولّد المفتاح العام المرسل في الرؤوس
  • تحقق من أن محتوى الاستجابة مشفّر فعلًا بترميز hex (E2EE نشط)
  • تأكد من أن المفتاح العام للنموذج يطابق ما استُخدم للتشفير
  • يجب تشفير جميع رسائل دور user وsystem عند وجود رؤوس E2EE
  • تحقق من أن المحتوى المشفّر يجتاز التحقق isValidEncrypted() (الحد الأدنى 186 محرف hex)
  • تأكد من أن إخراج التشفير hex بأحرف صغيرة دون أي بادئات
  • يجب أن يكون المفتاح العام للعميل بطول 130 محرف hex بالضبط ويبدأ بـ 04
  • استخدم المساعد validateClientPubkey() للتحقق من التنسيق قبل الإرسال
  • تأكد من استخدام تنسيق المفتاح العام غير المضغوط (65 بايت = 130 محرف hex)
  • تحقق من صحة معرّف النموذج وأنه يدعم E2EE
  • استخدم نقطة النهاية /models للتحقق من نماذج E2EE المتاحة

الموارد