11
11
from ......anoncreds .models .presentation_request import AnoncredsPresentationRequestSchema
12
12
from ......anoncreds .models .proof import AnoncredsProofSchema
13
13
from ......anoncreds .models .utils import get_requested_creds_from_proof_request_preview
14
+ from ......anoncreds .registry import AnonCredsRegistry
14
15
from ......anoncreds .util import generate_pr_nonce
15
16
from ......anoncreds .verifier import AnonCredsVerifier
16
17
from ......messaging .decorators .attach_decorator import AttachDecorator
@@ -175,7 +176,7 @@ async def create_pres(
175
176
async def receive_pres (self , message : V20Pres , pres_ex_record : V20PresExRecord ):
176
177
"""Receive a presentation and check for presented values vs. proposal request."""
177
178
178
- def _check_proof_vs_proposal ():
179
+ async def _check_proof_vs_proposal ():
179
180
"""Check for bait and switch in presented values vs. proposal request."""
180
181
from ..indy .handler import IndyPresExchangeHandler
181
182
@@ -231,15 +232,18 @@ def _check_proof_vs_proposal():
231
232
name : values ["raw" ] for name , values in attr_spec ["values" ].items ()
232
233
}
233
234
sub_proof_index = attr_spec ["sub_proof_index" ]
235
+ registry = self .profile .inject (AnonCredsRegistry )
234
236
schema_id = proof ["identifiers" ][sub_proof_index ]["schema_id" ]
237
+ schema_info = await registry .get_schema_info_by_id (schema_id )
235
238
cred_def_id = proof ["identifiers" ][sub_proof_index ]["cred_def_id" ]
239
+ cred_def_info = await registry .get_cred_def_info_by_id (cred_def_id )
236
240
criteria = {
237
241
"schema_id" : schema_id ,
238
- "schema_issuer_did" : schema_id . split ( ":" )[ - 4 ] ,
239
- "schema_name" : schema_id . split ( ":" )[ - 2 ] ,
240
- "schema_version" : schema_id . split ( ":" )[ - 1 ] ,
242
+ "schema_issuer_did" : schema_info . issuer_id ,
243
+ "schema_name" : schema_info . name ,
244
+ "schema_version" : schema_info . version ,
241
245
"cred_def_id" : cred_def_id ,
242
- "issuer_did" : cred_def_id . split ( ":" )[ - 5 ] ,
246
+ "issuer_did" : cred_def_info . issuer_id ,
243
247
** {
244
248
f"attr::{ name } ::value" : value
245
249
for name , value in proof_values .items ()
@@ -292,15 +296,18 @@ def _check_proof_vs_proposal():
292
296
f"Proposed request predicate on { req_name } not in presentation"
293
297
)
294
298
299
+ registry = self .profile .inject (AnonCredsRegistry )
295
300
schema_id = proof ["identifiers" ][sub_proof_index ]["schema_id" ]
301
+ schema_info = await registry .get_schema_info_by_id (schema_id )
296
302
cred_def_id = proof ["identifiers" ][sub_proof_index ]["cred_def_id" ]
303
+ cred_def_info = await registry .get_cred_def_info_by_id (cred_def_id )
297
304
criteria = {
298
305
"schema_id" : schema_id ,
299
- "schema_issuer_did" : schema_id . split ( ":" )[ - 4 ] ,
300
- "schema_name" : schema_id . split ( ":" )[ - 2 ] ,
301
- "schema_version" : schema_id . split ( ":" )[ - 1 ] ,
306
+ "schema_issuer_did" : schema_info . issuer_id ,
307
+ "schema_name" : schema_info . name ,
308
+ "schema_version" : schema_info . version ,
302
309
"cred_def_id" : cred_def_id ,
303
- "issuer_did" : cred_def_id . split ( ":" )[ - 5 ] ,
310
+ "issuer_did" : cred_def_info . issuer_id ,
304
311
}
305
312
306
313
if (
@@ -313,7 +320,7 @@ def _check_proof_vs_proposal():
313
320
)
314
321
315
322
proof = message .attachment (AnonCredsPresExchangeHandler .format )
316
- _check_proof_vs_proposal ()
323
+ await _check_proof_vs_proposal ()
317
324
318
325
async def verify_pres (self , pres_ex_record : V20PresExRecord ) -> V20PresExRecord :
319
326
"""Verify a presentation.
0 commit comments