diff --git a/my_proof/models/proof_response.py b/my_proof/models/proof_response.py index ba7e335..f5b21d2 100644 --- a/my_proof/models/proof_response.py +++ b/my_proof/models/proof_response.py @@ -4,6 +4,23 @@ class ProofResponse(BaseModel): + """ + Represents the response of a proof of contribution. Only the score and metadata will be written onchain, the rest of the proof lives offchain. + + Onchain attributes - these are written to the data registry: + score: 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. + metadata: Additional metadata about the proof + + Offchain attributes - the remainder of the proof is written to IPFS + dlp_id: The DLP ID is found in the DLP Root Network contract after the DLP is registered. + valid: A single boolean to summarize if the file is considered valid in this DLP. + authenticity: A score between 0 and 1 to rate if the file has been tampered with. + ownership: A score between 0 and 1 to verify the ownership of the file. + quality: A score between 0 and 1 to show the quality of the file + uniqueness: A score between 0 and 1 to show unique the file is, compared to others in the DLP. + attributes: Custom attributes added to the proof to provide extra context about the encrypted file. + """ + dlp_id: int valid: bool = False score: float = 0.0 @@ -12,3 +29,4 @@ class ProofResponse(BaseModel): quality: float = 0.0 uniqueness: float = 0.0 attributes: Optional[Dict[str, Any]] = {} + metadata: Optional[Dict[str, Any]] = {} diff --git a/my_proof/proof.py b/my_proof/proof.py index c932564..929ac66 100644 --- a/my_proof/proof.py +++ b/my_proof/proof.py @@ -48,13 +48,18 @@ def generate(self) -> ProofResponse: self.proof_response.score = 0.6 * self.proof_response.quality + 0.4 * self.proof_response.ownership self.proof_response.valid = email_matches and total_score >= score_threshold - # Add additional metadata to the proof - these are public attributes about the data + # Additional (public) properties to include in the proof about the data self.proof_response.attributes = { 'total_score': total_score, 'score_threshold': score_threshold, 'email_verified': email_matches, } + # Additional metadata about the proof, written onchain + self.proof_response.metadata = { + 'dlp_id': self.config['dlp_id'], + } + return self.proof_response