aries_cloudagent.vc.vc_ld package

class aries_cloudagent.vc.vc_ld.CredentialSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Linked data credential schema.

Based on https://www.w3.org/TR/vc-data-model

class Meta[source]

Bases: object

Accept parameter overload.

model_class

alias of VerifiableCredential

add_unknown_properties(data: dict, original, **kwargs)

Add back unknown properties before outputting.

class aries_cloudagent.vc.vc_ld.LDProof(type: Optional[str] = None, proof_purpose: Optional[str] = None, verification_method: Optional[str] = None, created: Optional[str] = None, domain: Optional[str] = None, challenge: Optional[str] = None, jws: Optional[str] = None, proof_value: Optional[str] = None, nonce: Optional[str] = None, **kwargs)[source]

Bases: BaseModel

Linked Data Proof model.

class Meta[source]

Bases: object

LinkedDataProof metadata.

schema_class = 'LinkedDataProofSchema'
class aries_cloudagent.vc.vc_ld.LinkedDataProofSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Linked data proof schema.

Based on https://w3c-ccg.github.io/ld-proofs

class Meta[source]

Bases: object

Accept parameter overload.

model_class

alias of LDProof

add_unknown_properties(data: dict, original, **kwargs)

Add back unknown properties before outputting.

class aries_cloudagent.vc.vc_ld.PresentationVerificationResult(*, verified: bool, presentation_result: Optional[DocumentVerificationResult] = None, credential_results: Optional[List[DocumentVerificationResult]] = None, errors: Optional[List[str]] = None)[source]

Bases: BaseModel

Presentation verification result class.

class Meta[source]

Bases: object

PresentationVerificationResult metadata.

schema_class = 'PresentationVerificationResultSchema'
class aries_cloudagent.vc.vc_ld.VerifiableCredential(context: Optional[List[Union[str, dict]]] = None, id: Optional[str] = None, type: Optional[List[str]] = None, issuer: Optional[Union[dict, str]] = None, issuance_date: Optional[str] = None, expiration_date: Optional[str] = None, credential_subject: Optional[Union[dict, List[dict]]] = None, credential_status: Optional[Union[dict, List[dict]]] = None, proof: Optional[Union[dict, LDProof]] = None, **kwargs)[source]

Bases: BaseModel

Verifiable Credential model.

class Meta[source]

Bases: object

VerifiableCredential metadata.

schema_class = 'CredentialSchema'
add_context(context: Union[str, dict])[source]

Add a context to this credential.

add_type(type: str)[source]

Add a type to this credential.

property context

Getter for context.

property context_urls: List[str]

Getter for context urls.

property credential_status

Getter for credential status.

property credential_subject

Getter for credential subject.

property credential_subject_ids: List[str]

Getter for credential subject ids.

property expiration_date

Getter for expiration date.

property id

Getter for id.

property issuance_date

Getter for issuance date.

property issuer

Getter for issuer.

property issuer_id: Optional[str]

Getter for issuer id.

property proof

Getter for proof.

property type: List[str]

Getter for type.

class aries_cloudagent.vc.vc_ld.VerifiableCredentialSchema(*args: Any, **kwargs: Any)[source]

Bases: CredentialSchema

Linked data verifiable credential schema.

Based on https://www.w3.org/TR/vc-data-model

async aries_cloudagent.vc.vc_ld.create_presentation(*, credentials: List[dict], presentation_id: Optional[str] = None) dict[source]

Create presentation and add the credentials to it.

Will validates the structure off all credentials, but does not sign the presentation yet. Call sing_presentation to do this.

Parameters
  • credentials (List[dict]) – Credentails to add to the presentation

  • presentation_id (str, optional) – Id of the presentation. Defaults to None.

Raises

LinkedDataProofException – When not all credentials have a valid structure

Returns

The unsigned presentation object

Return type

dict

async aries_cloudagent.vc.vc_ld.derive_credential(*, credential: dict, reveal_document: dict, suite: LinkedDataProof, document_loader: Callable[[str, dict], dict]) dict[source]

Derive new credential from the existing credential and the reveal document.

All proofs matching the signature suite type will be replaced with a derived proof. Other proofs will be discarded.

Parameters
  • credential (dict) – The credential to derive the new credential from.

  • reveal_document (dict) – JSON-LD frame to select which attributes to include.

  • suite (LinkedDataProof) – The signature suite to use for derivation

  • document_loader (DocumentLoader) – The document loader to use.

Returns

The derived credential.

Return type

dict

async aries_cloudagent.vc.vc_ld.issue_vc(*, credential: dict, suite: LinkedDataProof, document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None) dict

Issue a verifiable credential.

Takes the base credentail document, verifies it, and adds a digital signature to it.

Parameters
  • credential (dict) – Base credential document.

  • suite (LinkedDataProof) – Signature suite to sign the credential with.

  • document_loader (DocumentLoader) – Document loader to use

  • purpose (ProofPurpose, optional) – A proof purpose instance that will match proofs to be verified and ensure they were created according to the appropriate purpose. Default to CredentialIssuancePurpose

Raises

LinkedDataProofException – When the credential has an invalid structure OR signing fails

Returns

The signed verifiable credential

Return type

dict

async aries_cloudagent.vc.vc_ld.sign_presentation(*, presentation: dict, suite: LinkedDataProof, document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None, challenge: Optional[str] = None, domain: Optional[str] = None) dict[source]

Sign the presentation with the passed signature suite.

Will set a default AuthenticationProofPurpose if no proof purpose is passed.

Parameters
  • presentation (dict) – The presentation to sign

  • suite (LinkedDataProof) – The signature suite to sign the presentation with

  • document_loader (DocumentLoader) – Document loader to use.

  • purpose (ProofPurpose, optional) – Purpose to use. Required if challenge is None

  • challenge (str, optional) – Challenge to use. Required if domain is None.

  • domain (str, optional) – Domain to use. Only used if purpose is None.

Raises

LinkedDataProofException – When both purpose and challenge are not provided And when signing of the presentation fails

Returns

A verifiable presentation object

Return type

dict

async aries_cloudagent.vc.vc_ld.verify_credential(*, credential: dict, suites: List[LinkedDataProof], document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None) DocumentVerificationResult[source]

Verify credential structure, proof purpose and signature.

Parameters
  • credential (dict) – The credential to verify

  • suites (List[LinkedDataProof]) – The signature suites to verify with

  • document_loader (DocumentLoader) – Document loader used for resolving of documents

  • purpose (ProofPurpose, optional) – Proof purpose to use. Defaults to CredentialIssuancePurpose

Returns

The result of the verification. Verified property

indicates whether the verification was successful

Return type

DocumentVerificationResult

async aries_cloudagent.vc.vc_ld.verify_presentation(*, presentation: dict, suites: List[LinkedDataProof], document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None, challenge: Optional[str] = None, domain: Optional[str] = None) PresentationVerificationResult[source]

Verify presentation structure, credentials, proof purpose and signature.

Parameters
  • presentation (dict) – The presentation to verify

  • suites (List[LinkedDataProof]) – The signature suites to verify with

  • document_loader (DocumentLoader) – Document loader used for resolving of documents

  • purpose (ProofPurpose, optional) – Proof purpose to use. Defaults to AuthenticationProofPurpose

  • challenge (str, optional) – The challenge to use for authentication. Required if purpose is not passed, not used if purpose is passed

  • domain (str, optional) – Domain to use for the authentication proof purpose. Not used if purpose is passed

Returns

The result of the verification. Verified property

indicates whether the verification was successful

Return type

PresentationVerificationResult

Subpackages

Submodules

aries_cloudagent.vc.vc_ld.issue module

Verifiable Credential issuance methods.

async aries_cloudagent.vc.vc_ld.issue.issue(*, credential: dict, suite: LinkedDataProof, document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None) dict[source]

Issue a verifiable credential.

Takes the base credentail document, verifies it, and adds a digital signature to it.

Parameters
  • credential (dict) – Base credential document.

  • suite (LinkedDataProof) – Signature suite to sign the credential with.

  • document_loader (DocumentLoader) – Document loader to use

  • purpose (ProofPurpose, optional) – A proof purpose instance that will match proofs to be verified and ensure they were created according to the appropriate purpose. Default to CredentialIssuancePurpose

Raises

LinkedDataProofException – When the credential has an invalid structure OR signing fails

Returns

The signed verifiable credential

Return type

dict

aries_cloudagent.vc.vc_ld.manager module

Manager for performing Linked Data Proof signatures over JSON-LD formatted W3C VCs.

class aries_cloudagent.vc.vc_ld.manager.VcLdpManager(profile: Profile)[source]

Bases: object

Class for managing Linked Data Proof signatures over JSON-LD formatted W3C VCs.

async assert_can_issue_with_id_and_proof_type(issuer_id: Optional[str], proof_type: Optional[str])[source]

Assert that it is possible to issue using the specified id and proof type.

Parameters
  • issuer_id (str) – The issuer id

  • proof_type (str) – the signature suite proof type

Raises

VcLdpManagerError

  • If the proof type is not supported - If the issuer id is not a did - If the did is not found in th wallet - If the did does not support to create signatures for the proof type

async issue(credential: VerifiableCredential, options: LDProofVCOptions) VerifiableCredential[source]

Sign a VC with a Linked Data Proof.

async prepare_credential(credential: VerifiableCredential, options: LDProofVCOptions, holder_did: Optional[str] = None) VerifiableCredential[source]

Prepare a credential for issuance.

async prepare_presentation(presentation: VerifiablePresentation, options: LDProofVCOptions) VerifiableCredential[source]

Prepare a presentation for issuance.

async prove(presentation: VerifiablePresentation, options: LDProofVCOptions) VerifiablePresentation[source]

Sign a VP with a Linked Data Proof.

async store_credential(vc: VerifiableCredential, options: LDProofVCOptions, cred_id: Optional[str] = None) VerifiableCredential[source]

Store a verifiable credential.

async verify_credential(vc: VerifiableCredential) DocumentVerificationResult[source]

Verify a VC with a Linked Data Proof.

async verify_presentation(vp: VerifiablePresentation, options: LDProofVCOptions) PresentationVerificationResult[source]

Verify a VP with a Linked Data Proof.

exception aries_cloudagent.vc.vc_ld.manager.VcLdpManagerError[source]

Bases: Exception

Generic VcLdpManager Error.

aries_cloudagent.vc.vc_ld.prove module

Verifiable Credential and Presentation proving methods.

async aries_cloudagent.vc.vc_ld.prove.create_presentation(*, credentials: List[dict], presentation_id: Optional[str] = None) dict[source]

Create presentation and add the credentials to it.

Will validates the structure off all credentials, but does not sign the presentation yet. Call sing_presentation to do this.

Parameters
  • credentials (List[dict]) – Credentails to add to the presentation

  • presentation_id (str, optional) – Id of the presentation. Defaults to None.

Raises

LinkedDataProofException – When not all credentials have a valid structure

Returns

The unsigned presentation object

Return type

dict

async aries_cloudagent.vc.vc_ld.prove.derive_credential(*, credential: dict, reveal_document: dict, suite: LinkedDataProof, document_loader: Callable[[str, dict], dict]) dict[source]

Derive new credential from the existing credential and the reveal document.

All proofs matching the signature suite type will be replaced with a derived proof. Other proofs will be discarded.

Parameters
  • credential (dict) – The credential to derive the new credential from.

  • reveal_document (dict) – JSON-LD frame to select which attributes to include.

  • suite (LinkedDataProof) – The signature suite to use for derivation

  • document_loader (DocumentLoader) – The document loader to use.

Returns

The derived credential.

Return type

dict

async aries_cloudagent.vc.vc_ld.prove.sign_presentation(*, presentation: dict, suite: LinkedDataProof, document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None, challenge: Optional[str] = None, domain: Optional[str] = None) dict[source]

Sign the presentation with the passed signature suite.

Will set a default AuthenticationProofPurpose if no proof purpose is passed.

Parameters
  • presentation (dict) – The presentation to sign

  • suite (LinkedDataProof) – The signature suite to sign the presentation with

  • document_loader (DocumentLoader) – Document loader to use.

  • purpose (ProofPurpose, optional) – Purpose to use. Required if challenge is None

  • challenge (str, optional) – Challenge to use. Required if domain is None.

  • domain (str, optional) – Domain to use. Only used if purpose is None.

Raises

LinkedDataProofException – When both purpose and challenge are not provided And when signing of the presentation fails

Returns

A verifiable presentation object

Return type

dict

aries_cloudagent.vc.vc_ld.validation_result module

Presentation verification and validation result classes.

class aries_cloudagent.vc.vc_ld.validation_result.PresentationVerificationResult(*, verified: bool, presentation_result: Optional[DocumentVerificationResult] = None, credential_results: Optional[List[DocumentVerificationResult]] = None, errors: Optional[List[str]] = None)[source]

Bases: BaseModel

Presentation verification result class.

class Meta[source]

Bases: object

PresentationVerificationResult metadata.

schema_class = 'PresentationVerificationResultSchema'
class aries_cloudagent.vc.vc_ld.validation_result.PresentationVerificationResultSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Presentation verification result schema.

class Meta[source]

Bases: object

PresentationVerificationResultSchema metadata.

model_class

alias of PresentationVerificationResult

presentation_result

alias of DocumentVerificationResultSchema

aries_cloudagent.vc.vc_ld.verify module

Verifiable Credential and Presentation verification methods.

async aries_cloudagent.vc.vc_ld.verify.verify_credential(*, credential: dict, suites: List[LinkedDataProof], document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None) DocumentVerificationResult[source]

Verify credential structure, proof purpose and signature.

Parameters
  • credential (dict) – The credential to verify

  • suites (List[LinkedDataProof]) – The signature suites to verify with

  • document_loader (DocumentLoader) – Document loader used for resolving of documents

  • purpose (ProofPurpose, optional) – Proof purpose to use. Defaults to CredentialIssuancePurpose

Returns

The result of the verification. Verified property

indicates whether the verification was successful

Return type

DocumentVerificationResult

async aries_cloudagent.vc.vc_ld.verify.verify_presentation(*, presentation: dict, suites: List[LinkedDataProof], document_loader: Callable[[str, dict], dict], purpose: Optional[ProofPurpose] = None, challenge: Optional[str] = None, domain: Optional[str] = None) PresentationVerificationResult[source]

Verify presentation structure, credentials, proof purpose and signature.

Parameters
  • presentation (dict) – The presentation to verify

  • suites (List[LinkedDataProof]) – The signature suites to verify with

  • document_loader (DocumentLoader) – Document loader used for resolving of documents

  • purpose (ProofPurpose, optional) – Proof purpose to use. Defaults to AuthenticationProofPurpose

  • challenge (str, optional) – The challenge to use for authentication. Required if purpose is not passed, not used if purpose is passed

  • domain (str, optional) – Domain to use for the authentication proof purpose. Not used if purpose is passed

Returns

The result of the verification. Verified property

indicates whether the verification was successful

Return type

PresentationVerificationResult