Skip to content

Commit

Permalink
feat: additional metadata that's written onchain (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kahtaf authored Sep 27, 2024
1 parent 02128ab commit 4cc68b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions my_proof/models/proof_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]] = {}
7 changes: 6 additions & 1 deletion my_proof/proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 4cc68b7

Please sign in to comment.