|
3 | 3 | from os import urandom
|
4 | 4 | from pyld import jsonld
|
5 | 5 | from typing import List
|
| 6 | +from .BbsBlsSignature2020Base import BbsBlsSignature2020Base |
6 | 7 |
|
7 |
| -from ursa_bbs_signatures import ( |
8 |
| - create_proof as bls_create_proof, |
9 |
| - verify_proof as bls_verify_proof, |
10 |
| - CreateProofRequest, |
11 |
| - VerifyProofRequest, |
12 |
| - get_total_message_count, |
13 |
| - ProofMessage, |
14 |
| - BlsKeyPair, |
15 |
| - ProofMessageType, |
16 |
| -) |
17 |
| - |
| 8 | +if BbsBlsSignature2020Base.BBS_SUPPORTED: |
| 9 | + from ursa_bbs_signatures import ( |
| 10 | + create_proof as bls_create_proof, |
| 11 | + verify_proof as bls_verify_proof, |
| 12 | + CreateProofRequest, |
| 13 | + VerifyProofRequest, |
| 14 | + get_total_message_count, |
| 15 | + ProofMessage, |
| 16 | + BlsKeyPair, |
| 17 | + ProofMessageType, |
| 18 | + ) |
| 19 | + |
| 20 | +from ....utils.dependencies import assert_ursa_bbs_signatures_installed |
18 | 21 | from ....wallet.util import b64_to_bytes, bytes_to_b64
|
19 | 22 | from ..crypto import KeyPair
|
20 | 23 | from ..error import LinkedDataProofException
|
21 | 24 | from ..validation_result import ProofResult
|
22 | 25 | from ..document_loader import DocumentLoaderMethod
|
23 | 26 | from ..purposes import ProofPurpose
|
24 |
| -from .BbsBlsSignature2020Base import BbsBlsSignature2020Base |
25 | 27 | from .BbsBlsSignature2020 import BbsBlsSignature2020
|
26 | 28 | from .LinkedDataProof import DeriveProofResult
|
27 | 29 |
|
@@ -61,6 +63,7 @@ async def derive_proof(
|
61 | 63 | nonce: bytes = None,
|
62 | 64 | ):
|
63 | 65 | """Derive proof for document, return dict with derived document and proof."""
|
| 66 | + assert_ursa_bbs_signatures_installed() |
64 | 67 |
|
65 | 68 | # Validate that the input proof document has a proof compatible with this suite
|
66 | 69 | if proof.get("type") not in self.supported_derive_proof_types:
|
@@ -222,6 +225,7 @@ async def verify_proof(
|
222 | 225 | document_loader: DocumentLoaderMethod,
|
223 | 226 | ) -> ProofResult:
|
224 | 227 | """Verify proof against document and proof purpose."""
|
| 228 | + assert_ursa_bbs_signatures_installed() |
225 | 229 | try:
|
226 | 230 | proof["type"] = self.mapped_derived_proof_type
|
227 | 231 |
|
|
0 commit comments