|
| 1 | +import json |
| 2 | +import logging |
| 3 | + |
| 4 | +logger = logging.getLogger("aries_controller.models.proof_request") |
| 5 | + |
| 6 | +proof_request_template = json.loads({ |
| 7 | + "comment": "", |
| 8 | + "proof_request": { |
| 9 | + "name": "", |
| 10 | + "non_revoked": { |
| 11 | + "to": 1618218626 |
| 12 | + }, |
| 13 | + "nonce": "1234567890", |
| 14 | + "requested_attributes": { |
| 15 | + "additionalProp1": { |
| 16 | + "name": "", |
| 17 | + "names": [ |
| 18 | + "" |
| 19 | + ], |
| 20 | + "non_revoked": { |
| 21 | + "to": 1618218626 |
| 22 | + }, |
| 23 | + "restrictions": [ |
| 24 | + { |
| 25 | + "additionalProp1": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 26 | + "additionalProp2": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 27 | + "additionalProp3": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag" |
| 28 | + } |
| 29 | + ] |
| 30 | + }, |
| 31 | + "additionalProp2": { |
| 32 | + "name": "", |
| 33 | + "names": [ |
| 34 | + "" |
| 35 | + ], |
| 36 | + "non_revoked": { |
| 37 | + "to": 1618218626 |
| 38 | + }, |
| 39 | + "restrictions": [ |
| 40 | + { |
| 41 | + "additionalProp1": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 42 | + "additionalProp2": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 43 | + "additionalProp3": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag" |
| 44 | + } |
| 45 | + ] |
| 46 | + }, |
| 47 | + "additionalProp3": { |
| 48 | + "name": "", |
| 49 | + "names": [ |
| 50 | + "" |
| 51 | + ], |
| 52 | + "non_revoked": { |
| 53 | + "to": 1618218626 |
| 54 | + }, |
| 55 | + "restrictions": [ |
| 56 | + { |
| 57 | + "additionalProp1": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 58 | + "additionalProp2": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 59 | + "additionalProp3": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag" |
| 60 | + } |
| 61 | + ] |
| 62 | + } |
| 63 | + }, |
| 64 | + "requested_predicates": { |
| 65 | + "additionalProp1": { |
| 66 | + "name": "index", |
| 67 | + "non_revoked": { |
| 68 | + "to": 1618218626 |
| 69 | + }, |
| 70 | + "p_type": ">=", |
| 71 | + "p_value": 0, |
| 72 | + "restrictions": [ |
| 73 | + { |
| 74 | + "cred_def_id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 75 | + "issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 76 | + "schema_id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", |
| 77 | + "schema_issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 78 | + "schema_name": "transcript", |
| 79 | + "schema_version": "1.0" |
| 80 | + } |
| 81 | + ] |
| 82 | + }, |
| 83 | + "additionalProp2": { |
| 84 | + "name": "index", |
| 85 | + "non_revoked": { |
| 86 | + "to": 1618218626 |
| 87 | + }, |
| 88 | + "p_type": ">=", |
| 89 | + "p_value": 0, |
| 90 | + "restrictions": [ |
| 91 | + { |
| 92 | + "cred_def_id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 93 | + "issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 94 | + "schema_id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", |
| 95 | + "schema_issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 96 | + "schema_name": "transcript", |
| 97 | + "schema_version": "1.0" |
| 98 | + } |
| 99 | + ] |
| 100 | + }, |
| 101 | + "additionalProp3": { |
| 102 | + "name": "", |
| 103 | + "non_revoked": { |
| 104 | + "to": 1618218626 |
| 105 | + }, |
| 106 | + "p_type": ">=", |
| 107 | + "p_value": 0, |
| 108 | + "restrictions": [ |
| 109 | + { |
| 110 | + "cred_def_id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 111 | + "issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 112 | + "schema_id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", |
| 113 | + "schema_issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 114 | + "schema_name": "transcript", |
| 115 | + "schema_version": "1.0" |
| 116 | + } |
| 117 | + ] |
| 118 | + } |
| 119 | + }, |
| 120 | + "version": "1.0" |
| 121 | + }, |
| 122 | + "trace": false |
| 123 | +}) |
| 124 | + |
| 125 | + |
| 126 | +class ProofRequest(): |
| 127 | + def __init__(self, x): |
| 128 | + self.proof_request = {} |
| 129 | + self.proof_from_json = {} |
| 130 | + |
| 131 | + def proof_from_json(self, prop_json): |
| 132 | + try: |
| 133 | + self.proof_from_json = json.loads(prop_json) |
| 134 | + assert __verify_proof_format() |
| 135 | + except AssertionError as e: |
| 136 | + logger.error(f"Could not verify proof presentation format: {e!r}") |
| 137 | + raise |
| 138 | + except Exception: |
| 139 | + logger.error("Failed to load proposed JSON proof presentation.") |
| 140 | + raise |
| 141 | + |
| 142 | + def __verify_proof_format(self): |
| 143 | + |
| 144 | + return True |
| 145 | + |
| 146 | + # defs to pass single fields or sub dicts like |
| 147 | + """ |
| 148 | + "restrictions": [ |
| 149 | + { |
| 150 | + "cred_def_id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", |
| 151 | + "issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 152 | + "schema_id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", |
| 153 | + "schema_issuer_did": "WgWxqztrNooG92RXvxSTWv", |
| 154 | + "schema_name": "transcript", |
| 155 | + "schema_version": "1.0" |
| 156 | + } |
| 157 | + ] |
| 158 | + """ |
| 159 | + # See also presentation.py to get an idea of what we're trying to achieve |
| 160 | + |
0 commit comments