|
1 | | -# Vana Satya Proof of Contribution - dFusion Private Social Lens |
2 | | - |
3 | | -This repository serves as a template for creating a [proof of contribution](https://docs.vana.org/vana/core-concepts/key-elements/proof-of-contribution) tasks using Python. It is executed on Vana's Satya Network, a group of highly confidential and secure compute nodes that can validate data without revealing its contents to the node operator. |
4 | | - |
5 | | -## Overview |
6 | | - |
7 | | -This template provides a basic structure for building proof tasks that: |
8 | | - |
9 | | -1. Read input files from the `/input` directory. |
10 | | -2. Process the data securely, running any necessary validations to prove the data authentic, unique, high quality, etc. |
11 | | -3. Write proof results to the `/output/results.json` file in the following format: |
12 | | - |
13 | | -```json |
14 | | -{ |
15 | | - "dlp_id": 1234, // DLP ID is found in the Root Network contract after the DLP is registered |
16 | | - "valid": false, // A single boolean to summarize if the file is considered valid in this DLP |
17 | | - "score": 0.7614457831325301, // A score between 0 and 1 for the file, used to determine how valuable the file is. This can be an aggregation of the individual scores below. |
18 | | - "authenticity": 1.0, // A score between 0 and 1 to rate if the file has been tampered with |
19 | | - "ownership": 1.0, // A score between 0 and 1 to verify the ownership of the file |
20 | | - "quality": 0.6024096385542169, // A score between 0 and 1 to show the quality of the file |
21 | | - "uniqueness": 0, // A score between 0 and 1 to show unique the file is, compared to others in the DLP |
22 | | - "attributes": { // Custom attributes that can be added to the proof to provide extra context about the encrypted file |
23 | | - "total_score": 0.5, |
24 | | - "score_threshold": 0.83, |
25 | | - "email_verified": true |
26 | | - } |
27 | | -} |
28 | | -``` |
29 | | - |
30 | | -The project is designed to work with Intel TDX (Trust Domain Extensions), providing hardware-level isolation and security guarantees for confidential computing workloads. |
31 | | - |
32 | | -## Project Structure |
33 | | - |
34 | | -- `psl_proof/`: Contains the main proof logic |
35 | | - - `proof.py`: Implements the proof generation logic |
36 | | - - `__main__.py`: Entry point for the proof execution |
37 | | - - `models/`: Data models for the proof system |
38 | | -- `demo/`: Contains sample input and output for testing |
39 | | -- `Dockerfile`: Defines the container image for the proof task |
40 | | -- `requirements.txt`: Python package dependencies |
41 | | - |
42 | | -## Getting Started |
43 | | - |
44 | | -To use this template: |
45 | | - |
46 | | -1. Fork this repository |
47 | | -2. Modify the `psl_proof/proof.py` file to implement your specific proof logic |
48 | | -3. Update the project dependencies in `requirements.txt` if needed |
49 | | -4. Commit your changes and push to your repository |
50 | | - |
51 | | -## Customizing the Proof Logic |
52 | | - |
53 | | -The main proof logic is implemented in `psl_proof/proof.py`. To customize it, update the `Proof.generate()` function to change how input files are processed. |
54 | | - |
55 | | -The proof can be configured using environment variables. |
56 | | - |
57 | | -If you want to use a language other than Python, you can modify the Dockerfile to install the necessary dependencies and build the proof task in the desired language. |
58 | | - |
59 | | -## Proof Scores |
60 | | - |
61 | | -Loop through chat/conversal list, get average scores |
62 | | -1. Quality scores (qs) based on Timely, Thoughtful & Contextual |
63 | | -2. Uniqueness scores (us) based, |
64 | | - a. For each chat, fetch the timestamp of the last entry. |
65 | | - b. Determine the time difference (td) between the last entry and the current timestamp: |
66 | | - c. If td > 1 hour, assign a Uniqueness Score of 1.0 for that chat, else 0.0 |
67 | | -3. Detemine the total score (ts) |
68 | | - a. if us > 0, then add value to ts. |
69 | | - |
70 | | -Determine score: |
71 | | - valid flag alway true |
72 | | - normalise total score to value range 0 to 1 |
73 | | - total score is restricted by Minimum & Maximum value |
74 | | - |
75 | | - |
76 | | -## Local Development |
77 | | - |
78 | | -To run the proof locally for testing, you can use Docker: |
79 | | - |
80 | | -```bash |
81 | | -docker build -t psl-proof . |
82 | | -docker run \ |
83 | | - --rm \ |
84 | | - --volume $(pwd)/input:/input \ |
85 | | - --volume $(pwd)/output:/output \ |
86 | | - --env USER_EMAIL=user123@gmail.com \ |
87 | | - psl-proof |
88 | | -``` |
89 | | - |
90 | | -## Running with Intel TDX |
91 | | - |
92 | | -Intel TDX (Trust Domain Extensions) provides hardware-based memory encryption and integrity protection for virtual machines. To run this container in a TDX-enabled environment, follow your infrastructure provider's specific instructions for deploying confidential containers. |
93 | | - |
94 | | -Common volume mounts and environment variables: |
95 | | - |
96 | | -```bash |
97 | | -docker run \ |
98 | | - --rm \ |
99 | | - --volume /path/to/input:/input \ |
100 | | - --volume /path/to/output:/output \ |
101 | | - --env USER_EMAIL=user123@gmail.com \ |
102 | | - psl-proof |
103 | | -``` |
104 | | - |
105 | | -Remember to populate the `/input` directory with the files you want to process. |
106 | | - |
107 | | -## Security Features |
108 | | - |
109 | | -This template leverages several security features: |
110 | | - |
111 | | -1. **Hardware-based Isolation**: The proof runs inside a TDX-protected environment, isolating it from the rest of the system |
112 | | -2. **Input/Output Isolation**: Input and output directories are mounted separately, ensuring clear data flow boundaries |
113 | | -3. **Minimal Container**: Uses a minimal Python base image to reduce attack surface |
114 | | - |
115 | | -## Contributing |
116 | | - |
117 | | -If you have suggestions for improving this proof, please submit a pull request. |
118 | | - |
119 | | -## License |
120 | | - |
| 1 | +# Vana Satya Proof of Contribution - dFusion Private Social Lens |
| 2 | + |
| 3 | +This repository serves as a template for creating a [proof of contribution](https://docs.vana.org/vana/core-concepts/key-elements/proof-of-contribution) tasks using Python. It is executed on Vana's Satya Network, a group of highly confidential and secure compute nodes that can validate data without revealing its contents to the node operator. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This template provides a basic structure for building proof tasks that: |
| 8 | + |
| 9 | +1. Read input files from the `/input` directory. |
| 10 | +2. Process the data securely, running any necessary validations to prove the data authentic, unique, high quality, etc. |
| 11 | +3. Write proof results to the `/output/results.json` file in the following format: |
| 12 | + |
| 13 | +```json |
| 14 | +{ |
| 15 | + "dlp_id": 1234, // DLP ID is found in the Root Network contract after the DLP is registered |
| 16 | + "valid": false, // A single boolean to summarize if the file is considered valid in this DLP |
| 17 | + "score": 0.7614457831325301, // A score between 0 and 1 for the file, used to determine how valuable the file is. This can be an aggregation of the individual scores below. |
| 18 | + "authenticity": 1.0, // A score between 0 and 1 to rate if the file has been tampered with |
| 19 | + "ownership": 1.0, // A score between 0 and 1 to verify the ownership of the file |
| 20 | + "quality": 0.6024096385542169, // A score between 0 and 1 to show the quality of the file |
| 21 | + "uniqueness": 0, // A score between 0 and 1 to show unique the file is, compared to others in the DLP |
| 22 | + "attributes": { // Custom attributes that can be added to the proof to provide extra context about the encrypted file |
| 23 | + "total_score": 0.5, |
| 24 | + "score_threshold": 0.83, |
| 25 | + "email_verified": true |
| 26 | + } |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +The project is designed to work with Intel TDX (Trust Domain Extensions), providing hardware-level isolation and security guarantees for confidential computing workloads. |
| 31 | + |
| 32 | +## Project Structure |
| 33 | + |
| 34 | +- `psl_proof/`: Contains the main proof logic |
| 35 | + - `proof.py`: Implements the proof generation logic |
| 36 | + - `__main__.py`: Entry point for the proof execution |
| 37 | + - `models/`: Data models for the proof system |
| 38 | +- `demo/`: Contains sample input and output for testing |
| 39 | +- `Dockerfile`: Defines the container image for the proof task |
| 40 | +- `requirements.txt`: Python package dependencies |
| 41 | + |
| 42 | +## Getting Started |
| 43 | + |
| 44 | +To use this template: |
| 45 | + |
| 46 | +1. Fork this repository |
| 47 | +2. Modify the `psl_proof/proof.py` file to implement your specific proof logic |
| 48 | +3. Update the project dependencies in `requirements.txt` if needed |
| 49 | +4. Commit your changes and push to your repository |
| 50 | + |
| 51 | +## Customizing the Proof Logic |
| 52 | + |
| 53 | +The main proof logic is implemented in `psl_proof/proof.py`. To customize it, update the `Proof.generate()` function to change how input files are processed. |
| 54 | + |
| 55 | +The proof can be configured using environment variables. |
| 56 | + |
| 57 | +If you want to use a language other than Python, you can modify the Dockerfile to install the necessary dependencies and build the proof task in the desired language. |
| 58 | + |
| 59 | +## Proof Scores |
| 60 | + |
| 61 | +Loop through chat/conversal list, get average scores |
| 62 | +1. Quality scores (qs) based on Timely, Thoughtful & Contextual |
| 63 | +2. Uniqueness scores (us) based, |
| 64 | + a. For each chat, fetch the timestamp of the last entry. |
| 65 | + b. Determine the time difference (td) between the last entry and the current timestamp: |
| 66 | + c. If td > 1 hour, assign a Uniqueness Score of 1.0 for that chat, else 0.0 |
| 67 | +3. Detemine the total score (ts) |
| 68 | + a. if us > 0, then add value to ts. |
| 69 | + |
| 70 | +Determine score: |
| 71 | + valid flag alway true |
| 72 | + normalise total score to value range 0 to 1 |
| 73 | + total score is restricted by Minimum & Maximum value |
| 74 | + |
| 75 | + |
| 76 | +## Local Development |
| 77 | + |
| 78 | +To run the proof locally for testing, you can use Docker: |
| 79 | + |
| 80 | +```bash |
| 81 | +docker build -t psl-proof . |
| 82 | +docker run \ |
| 83 | + --rm \ |
| 84 | + --volume $(pwd)/input:/input \ |
| 85 | + --volume $(pwd)/output:/output \ |
| 86 | + --env USER_EMAIL=user123@gmail.com \ |
| 87 | + psl-proof |
| 88 | +``` |
| 89 | + |
| 90 | +## Running with Intel TDX |
| 91 | + |
| 92 | +Intel TDX (Trust Domain Extensions) provides hardware-based memory encryption and integrity protection for virtual machines. To run this container in a TDX-enabled environment, follow your infrastructure provider's specific instructions for deploying confidential containers. |
| 93 | + |
| 94 | +Common volume mounts and environment variables: |
| 95 | + |
| 96 | +```bash |
| 97 | +docker run \ |
| 98 | + --rm \ |
| 99 | + --volume /path/to/input:/input \ |
| 100 | + --volume /path/to/output:/output \ |
| 101 | + --env USER_EMAIL=user123@gmail.com \ |
| 102 | + psl-proof |
| 103 | +``` |
| 104 | + |
| 105 | +Remember to populate the `/input` directory with the files you want to process. |
| 106 | + |
| 107 | +## Security Features |
| 108 | + |
| 109 | +This template leverages several security features: |
| 110 | + |
| 111 | +1. **Hardware-based Isolation**: The proof runs inside a TDX-protected environment, isolating it from the rest of the system |
| 112 | +2. **Input/Output Isolation**: Input and output directories are mounted separately, ensuring clear data flow boundaries |
| 113 | +3. **Minimal Container**: Uses a minimal Python base image to reduce attack surface |
| 114 | + |
| 115 | +## Contributing |
| 116 | + |
| 117 | +If you have suggestions for improving this proof, please submit a pull request. |
| 118 | + |
| 119 | +## License |
| 120 | + |
121 | 121 | [MIT License](LICENSE) |
0 commit comments