Skip to content

Commit

Permalink
Create zkp_verifier.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 7, 2024
1 parent cc7fa56 commit 9a6d643
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions projects/DAPIO/security/zero-knowledge-proofs/zkp_verifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import hashlib
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.backends import default_backend

class ZKPVerifier:
def __init__(self, public_key: str):
self.public_key = serialization.load_pem_public_key(public_key.encode(), backend=default_backend())

def verify(self, statement: str, proof: bytes) -> bool:
hash_value = hashlib.sha256(statement.encode()).digest()
signature = ec.ECDSA(self.public_key).verify(proof, hash_value)
return signature.valid

0 comments on commit 9a6d643

Please sign in to comment.