Skip to content

Prompt Storage and Retrieval with nilDB and nilAI #124

@jcabrero

Description

@jcabrero

📦 Prompt Storage and Retrieval with nilDB and nilAI

This module enables users to store prompts in nilDB and securely retrieve them through nilAI for trusted prompt-based execution. This ensures the privacy-preserving capabilities of the Prompt

🔧 Overview

This system introduces a secure mechanism for:

  • Storing user-owned prompts in nilDB
  • Delegating retrieval rights to nilAI using NUCs.

Access and retrieval are strictly scoped via cryptographic delegation and verified enclave execution.


⚙️ How It Works

1. Prompt Storage in nilDB

  • nilDB hosts a collection with owned schemas.
  • Each user owns one or more prompt records.
  • Prompts can be stored using provided SDKs:
    • nilai-py (Python SDK)
    • nilai-ts (TypeScript SDK)

2. Access Delegation

  • The prompt owner stores the prompt in a nilDB user-owned collection and obtains a store_id.
  • The prompt owner generates a NUC, which is issued to a specific nilAI server, which already owns its private-public keypair.
  • The owner provides the Store ID and NUC to a requesting User to make their query.

3. Query Execution via nilAI

  • The user sends a query to nilAI including:
    • The Prompt Owner Store ID of the prompt
    • The Prompt Owner Delegation Token (NUC)
  • nilAI retrieves the prompt inside a TEE, ensuring:
    • Only the delegated server can access the prompt
    • Execution is secure and auditable

🔁 Sequence Diagram

sequenceDiagram
    participant User
    participant PromptOwner
    participant nilai-py/ts
    participant nilDB
    participant nilAI

    PromptOwner->>nilai-py/ts: Store prompt("promptText")
    nilai-py/ts->>nilDB: Write prompt to collection
    nilDB-->>nilai-py/ts: Store ID
    nilai-py/ts-->>PromptOwner: Store ID

    PromptOwner-->>User: Send Delegation NUC for nilAI + Store ID

    User->>nilAI: Send query with Store ID + Delegation Token (NUC)
    nilAI-->>nilDB: Secure retrieval with NUC
    nilDB-->>nilAI: Return prompt if authorized
    nilAI-->>nilAI: Execute query using prompt
    nilAI-->>User: Query result
Loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions