Skip to content

Conversation

Copy link

Copilot AI commented Oct 11, 2025

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Copilot said: Of course. Here is a concise and

Of course. Here is a concise and actionable prompt for the GitHub Copilot Agent, designed to capture all the requirements from your detailed project description. This prompt structures the request into clear sections for file organization, component-specific tasks, and overall project setup.
GitHub Copilot Agent Prompt:

Your task is to structure and enhance a Python-based surveillance system called "cryptoknight-beta". The system operates in a three-stage pipeline: an Edge Node, an Untrusted Server, and a Backend Server. You will be given five initial Python files (app.py, detect.py, he.py, sender.py, receiver.py) and a list of dependencies.

Refactor and expand the provided codebase to create the complete, operational pipeline, organizing the files into a logical structure for deployment across three separate machines.

  1. Project Structure

First, organize the project files into the following directory structure. Create new files as specified.
Code

/cryptoknight-beta
|-- edge_node/
| |-- app.py # (Modify) Orchestrator for the edge device
| |-- detect.py # (Modify) YOLO detection script
| |-- he.py # (Modify) Homomorphic encryption script
| |-- sender.py # (Modify) Sends data to Untrusted & Backend servers
|
|-- untrusted_server/
| |-- receiver.py # (New/Modify) Receives data from the edge
| |-- processor.py # (New) Performs HE data processing
| |-- sender.py # (New/Modify) Sends processed data to the backend
| |-- app.py # (New) Main application to run the untrusted server
|
|-- backend_server/
| |-- receiver.py # (New/Modify) Receives data from Edge & Untrusted servers
| |-- app.py # (New) Main Flask/Dash app for the dashboard
| |-- database.py # (New) SQLite database setup and operations
| |-- decrypt.py # (New) Handles decryption of HE and standard data
| |-- templates/
| | |-- index.html # (New) Dashboard UI
| |-- static/
| |-- styles.css # (New) CSS for the dashboard
|
|-- requirements.txt # (New) Python dependencies
|-- README.md # (New) Project setup and usage instructions

  1. Component-Specific Requirements

Modify the existing files and create new ones to meet the following specifications.

A. Edge Node (edge_node/)

detect.py:
    No major changes needed, but ensure it correctly streams JSON output for he.py.
he.py:
    Ensure it correctly parses the full JSON structure from detect.py.
    Update the create_encrypted_payload function to generate a JSON object containing the camera_id and the Base64-encoded encrypted data vector.
sender.py:
    This script must perform two parallel tasks:
        Send HE Data to Untrusted Server: Watch encrypted/session_data.bin and send its content (the HE JSON payload) to the Untrusted Server's receiver.py.
        Send Raw Data to Backend Server: Take the raw JSON output from detect.py, encrypt it using a standard, fast method (e.g., Fernet from the cryptography library), and send it directly to the Backend Server.
app.py:
    Update the script to manage the entire edge pipeline: detect.py -> he.py -> sender.py. The sender will now have two destinations.

B. Untrusted Server (untrusted_server/)

receiver.py:
    Listen for incoming HE JSON payloads from the Edge Node.
    Save the received data to a file or pass it directly to the processor.
processor.py:
    This is the core of the untrusted server. Implement homomorphic computations on the encrypted vectors received from the edge.
    Required Computations:
        Threat Count: Sum of high-threat objects (pistol, fire, smoke, drone, uav, person_fighting).
        Threat Level: Calculate a score based on the presence and confidence of threat objects.
        Threat Type: Identify the dominant threat class.
    Advanced Computations (Warns/Anomalies):
        Loitering: Detect if a 'person' object remains in a similar position over multiple timestamps.
        Suspicious Poses: Flag 'fighting', 'crouch', or 'surrender' states.
        High Velocity: Flag any object with velocity exceeding a set threshold.
sender.py:
    Send the results of the HE computations (still encrypted) to the Backend Server.
app.py:
    Create a main script to run the receiver and processor in a continuous loop.

C. Backend Server (backend_server/)

receiver.py:
    Listen for and differentiate between two incoming data streams:
        Raw, standard-encrypted data from the Edge Node.
        Processed, homomorphically-encrypted data from the Untrusted Server.
decrypt.py:
    Implement two decryption functions:
        A function to decrypt the raw data from the edge using the standard encryption key.
        A function to decrypt the processed HE results from the untrusted server using the TenSEAL context's secret ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants