|
| 1 | +import json |
| 2 | + |
1 | 3 | class Presentation():
|
2 | 4 | def __init__(self, verify):
|
3 | 5 | self.verify = verify
|
4 | 6 |
|
5 | 7 | def get_self_attested(self):
|
6 |
| - for (name, val) in self.verify['presentation']['requested_proof']['self_attested_attrs'].items(): |
7 |
| - print(name + " : " + val) |
| 8 | + data = {} |
| 9 | + for (name, val) in self.verify['presentation']['requested_proof']['self_attested_attrs'].items(): |
| 10 | + data[name] = val['raw'] |
| 11 | + return json.dumps(data) |
8 | 12 |
|
9 | 13 | def get_revealed(self):
|
10 |
| - for (name, val) in self.verify['presentation']['requested_proof']['revealed_attrs'].items(): |
11 |
| - ## This is the actual data that you want. It's a little hidden |
12 |
| - print(name + " : " + val['raw']) |
| 14 | + data = {} |
| 15 | + for (name, val) in self.verify['presentation']['requested_proof']['revealed_attrs'].items(): |
| 16 | + data[name] = val['raw'] |
| 17 | + |
| 18 | + return json.dumps(data) |
13 | 19 |
|
14 | 20 | def get_unrevealed_attrs(self):
|
15 |
| - for (name, val) in self.verify['presentation']['requested_proof']['unrevealed_attrs'].items(): |
16 |
| - ## This is the actual data that you want. It's a little hidden |
17 |
| - print(name + " : " + val['raw']) |
| 21 | + data = {} |
| 22 | + for (name, val) in self.verify['presentation']['requested_proof']['unrevealed_attrs'].items(): |
| 23 | + data[name] = val['raw'] |
| 24 | + return json.dumps(data) |
| 25 | + |
18 | 26 | def get_predicates(self):
|
19 |
| - for (name, val) in self.verify['presentation']['requested_proof']['predicates'].items(): |
20 |
| - ## This is the actual data that you want. It's a little hidden |
21 |
| - print(name + " : " + val['raw']) |
| 27 | + data = {} |
| 28 | + for (name, val) in self.verify['presentation']['requested_proof']['predicates'].items(): |
| 29 | + data[name] = val['raw'] |
| 30 | + return json.dumps(data) |
22 | 31 |
|
23 | 32 | def get_identifiers(self):
|
24 |
| - print(self.verify['presentation']['identifiers']) |
25 |
| - """ |
26 |
| - "schema_id": "PQRXDxdGqQGSZ8z69p4xZP:2:test_revocable_schema:0.0.1", |
27 |
| - "cred_def_id": "PQRXDxdGqQGSZ8z69p4xZP:3:CL:14:default", |
28 |
| - "rev_reg_id": "PQRXDxdGqQGSZ8z69p4xZP:4:PQRXDxdGqQGSZ8z69p4xZP:3:CL:14:default:CL_ACCUM:24f4f2ad-0d38-4f46-b020-23eb3cbd0595", |
29 |
| - "timestamp": 1613564695 |
30 |
| - """ |
| 33 | + return self.verify['presentation']['identifiers'] |
31 | 34 |
|
32 | 35 | def get_role(self):
|
33 |
| - print(self.verify['role']) |
| 36 | + return(self.verify['role']) |
34 | 37 |
|
35 | 38 | def get_threadid(self):
|
36 |
| - print(self.verify['thread_id']) |
| 39 | + return(self.verify['thread_id']) |
37 | 40 |
|
38 | 41 | def get_presentation_request(self):
|
39 |
| - print(self.verify['presentation_request']) |
| 42 | + return(self.verify['presentation_request']) |
40 | 43 |
|
41 | 44 | def get_verified_state(self):
|
42 |
| - print(self.verify['state']) |
| 45 | + return self.verify['state'] |
43 | 46 |
|
44 | 47 | def is_verified(self):
|
45 |
| - if self.verify['state'] == 'verified': |
46 |
| - print('verified') |
47 |
| - else: |
48 |
| - print('verification failed') |
| 48 | + # Assume the actual state of the verification is in "verified": "true", |
| 49 | + return bool(self.verify['state'] == 'verified') |
49 | 50 |
|
50 | 51 | verify = {
|
51 | 52 | "presentation_exchange_id": "49baae24-57e0-48ad-8df8-adf0ea567c96",
|
|
0 commit comments