fix encode decode base64

This commit is contained in:
Cayo Puigdefabregas 2024-02-14 18:35:34 +01:00
parent 0fed4b914d
commit 764d1e5f03
2 changed files with 7 additions and 3 deletions

View File

@ -118,7 +118,11 @@ def serve_did(request, did_id):
# revoked_credential_indexes.append(credential.revocationBitmapIndex) # revoked_credential_indexes.append(credential.revocationBitmapIndex)
# TODO: Conditionally add "service" to DID document only if the DID has issued any VC # TODO: Conditionally add "service" to DID document only if the DID has issued any VC
revocation_bitmap = pyroaring.BitMap(revoked_credential_indexes) revocation_bitmap = pyroaring.BitMap(revoked_credential_indexes)
encoded_revocation_bitmap = base64.b64encode(zlib.compress(revocation_bitmap.serialize())) encoded_revocation_bitmap = base64.b64encode(
zlib.compress(
revocation_bitmap.serialize()
)
).decode('utf-8')
revocation_service = [{ # This is an object within a list. revocation_service = [{ # This is an object within a list.
"id": f"{id_did}#revocation", "id": f"{id_did}#revocation",
"type": "RevocationBitmap2022", "type": "RevocationBitmap2022",

View File

@ -117,7 +117,7 @@ def verify_credential(vc):
return valid, reason return valid, reason
# Credential passes basic signature verification. Now check it against its schema. # Credential passes basic signature verification. Now check it against its schema.
# TODO: check agasint schema # TODO: check agasint schema
pass # pass
# Credential verifies against its schema. Now check revocation status. # Credential verifies against its schema. Now check revocation status.
vc = json.loads(vc) vc = json.loads(vc)
if "credentialStatus" in vc: if "credentialStatus" in vc:
@ -130,7 +130,7 @@ def verify_credential(vc):
revocation_bitmap = BitMap.deserialize( revocation_bitmap = BitMap.deserialize(
zlib.decompress( zlib.decompress(
base64.b64decode( base64.b64decode(
issuer_revocation_list["serviceEndpoint"].rsplit(",")[1] issuer_revocation_list["serviceEndpoint"].rsplit(",")[1].encode('utf-8')
) )
) )
) )