pyvckit/verify_vp.py

38 lines
789 B
Python
Raw Normal View History

2024-05-24 10:38:48 +00:00
import json
2024-05-24 20:16:58 +00:00
import argparse
from verify import verify_vc
2024-05-24 10:38:48 +00:00
2024-05-24 20:16:58 +00:00
def get_presentation(path_presentation):
with open(path_presentation, "r") as f:
vc = f.read()
return vc
2024-05-24 10:38:48 +00:00
2024-05-24 20:29:14 +00:00
def verify_vp(presentation):
vp = json.loads(presentation)
if not verify_vc(presentation):
return False
for vc in vp['verifiableCredential']:
vc_str = json.dumps(vc)
if not verify_vc(vc_str):
return False
return True
2024-05-24 20:16:58 +00:00
def main():
parser=argparse.ArgumentParser(description='Verify a presentation')
parser.add_argument("presentation_path")
args=parser.parse_args()
2024-05-24 10:38:48 +00:00
2024-05-24 20:16:58 +00:00
if args.presentation_path:
presentation = get_presentation(args.presentation_path)
2024-05-24 20:29:14 +00:00
print(verify_vp(presentation))
2024-05-24 10:38:48 +00:00
if __name__ == "__main__":
2024-05-24 20:16:58 +00:00
main()