aries_cloudagent.connections.models.diddoc package

DID Document model support.

Copyright 2017-2019 Government of Canada Public Services and Procurement Canada - buyandsell.gc.ca

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class aries_cloudagent.connections.models.diddoc.DIDDoc(did: Optional[str] = None)[source]

Bases: object

DID document, grouping a DID with verification keys and services.

Retains DIDs as raw values (orientated toward indy-facing operations), everything else as URIs (oriented toward W3C-facing operations).

CONTEXT = 'https://w3id.org/did/v1'
add_service_pubkeys(service: dict, tags: Union[Sequence[str], str]) List[aries_cloudagent.connections.models.diddoc.publickey.PublicKey][source]

Add public keys specified in service. Return public keys so discovered.

Parameters
  • service – service from DID document

  • tags – potential tags marking public keys of type of interest (the standard is still coalescing)

Raises

ValueError – for public key reference not present in DID document.

Returns: list of public keys from the document service specification

property authnkey: dict

Accessor for public keys marked as authentication keys, by identifier.

classmethod deserialize(did_doc: dict) aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Construct DIDDoc object from dict representation.

Parameters

did_doc – DIDDoc dict representation

Raises

ValueError – for bad DID or missing mandatory item.

Returns: DIDDoc from input json

property did: str

Accessor for DID.

classmethod from_json(did_doc_json: str) aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Construct DIDDoc object from json representation.

Parameters

did_doc_json – DIDDoc json representation

Returns: DIDDoc from input json

property pubkey: dict

Accessor for public keys by identifier.

serialize() dict[source]

Dump current object to a JSON-compatible dictionary.

Returns

dict representation of current DIDDoc

property service: dict

Accessor for services by identifier.

set(item: Union[aries_cloudagent.connections.models.diddoc.service.Service, aries_cloudagent.connections.models.diddoc.publickey.PublicKey]) aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Add or replace service or public key; return current DIDDoc.

Raises

ValueError – if input item is neither service nor public key.

Parameters

item – service or public key to set

Returns: the current DIDDoc

to_json() str[source]

Dump current object as json (JSON-LD).

Returns

json representation of current DIDDoc

class aries_cloudagent.connections.models.diddoc.LinkedDataKeySpec(ver_type, authn_type, specifier)

Bases: tuple

property authn_type

Alias for field number 1

property specifier

Alias for field number 2

property ver_type

Alias for field number 0

class aries_cloudagent.connections.models.diddoc.PublicKey(did: str, ident: str, value: str, pk_type: Optional[aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType] = None, controller: Optional[str] = None, authn: bool = False)[source]

Bases: object

Public key specification to embed in DID document.

Retains DIDs as raw values (orientated toward indy-facing operations), everything else as URIs (oriented toward W3C-facing operations).

property authn: bool

Accessor for the authentication marker.

Returns: whether public key is marked as having DID authentication privilege

property controller: str

Accessor for the controller DID.

property did: str

Accessor for the DID.

property id: str

Accessor for the public key identifier.

to_dict() dict[source]

Return dict representation of public key to embed in DID document.

property type: aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType

Accessor for the public key type.

property value: str

Accessor for the public key value.

class aries_cloudagent.connections.models.diddoc.PublicKeyType(value)[source]

Bases: enum.Enum

Class encapsulating public key types.

ED25519_SIG_2018 = LinkedDataKeySpec(ver_type='Ed25519VerificationKey2018', authn_type='Ed25519SignatureAuthentication2018', specifier='publicKeyBase58')
EDDSA_SA_SIG_SECP256K1 = LinkedDataKeySpec(ver_type='Secp256k1VerificationKey2018', authn_type='Secp256k1SignatureAuthenticationKey2018', specifier='publicKeyHex')
RSA_SIG_2018 = LinkedDataKeySpec(ver_type='RsaVerificationKey2018', authn_type='RsaSignatureAuthentication2018', specifier='publicKeyPem')
property authn_type: str

Accessor for the authentication type identifier.

static get(val: str) aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType[source]

Find enum instance corresponding to input value (RsaVerificationKey2018 etc).

Parameters

val – input value marking public key type

Returns: the public key type

specification(val: str) str[source]

Return specifier and input value for use in public key specification.

Parameters

val – value of public key

Returns: dict mapping applicable specifier to input value

property specifier: str

Accessor for the value specifier.

property ver_type: str

Accessor for the verification type identifier.

class aries_cloudagent.connections.models.diddoc.Service(did: str, ident: str, typ: str, recip_keys: Union[Sequence, aries_cloudagent.connections.models.diddoc.publickey.PublicKey], routing_keys: Union[Sequence, aries_cloudagent.connections.models.diddoc.publickey.PublicKey], endpoint: str, priority: int = 0)[source]

Bases: object

Service specification to embed in DID document.

Retains DIDs as raw values (orientated toward indy-facing operations), everything else as URIs (oriented toward W3C-facing operations).

property did: str

Accessor for the DID value.

property endpoint: str

Accessor for the endpoint value.

property id: str

Accessor for the service identifier.

property priority: int

Accessor for the priority value.

property recip_keys: List[aries_cloudagent.connections.models.diddoc.publickey.PublicKey]

Accessor for the recipient keys.

property routing_keys: List[aries_cloudagent.connections.models.diddoc.publickey.PublicKey]

Accessor for the routing keys.

to_dict() dict[source]

Return dict representation of service to embed in DID document.

property type: str

Accessor for the service type.

Submodules

aries_cloudagent.connections.models.diddoc.diddoc module

DID Document classes.

Copyright 2017-2019 Government of Canada Public Services and Procurement Canada - buyandsell.gc.ca

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc(did: Optional[str] = None)[source]

Bases: object

DID document, grouping a DID with verification keys and services.

Retains DIDs as raw values (orientated toward indy-facing operations), everything else as URIs (oriented toward W3C-facing operations).

CONTEXT = 'https://w3id.org/did/v1'
add_service_pubkeys(service: dict, tags: Union[Sequence[str], str]) List[aries_cloudagent.connections.models.diddoc.publickey.PublicKey][source]

Add public keys specified in service. Return public keys so discovered.

Parameters
  • service – service from DID document

  • tags – potential tags marking public keys of type of interest (the standard is still coalescing)

Raises

ValueError – for public key reference not present in DID document.

Returns: list of public keys from the document service specification

property authnkey: dict

Accessor for public keys marked as authentication keys, by identifier.

classmethod deserialize(did_doc: dict) aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Construct DIDDoc object from dict representation.

Parameters

did_doc – DIDDoc dict representation

Raises

ValueError – for bad DID or missing mandatory item.

Returns: DIDDoc from input json

property did: str

Accessor for DID.

classmethod from_json(did_doc_json: str) aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Construct DIDDoc object from json representation.

Parameters

did_doc_json – DIDDoc json representation

Returns: DIDDoc from input json

property pubkey: dict

Accessor for public keys by identifier.

serialize() dict[source]

Dump current object to a JSON-compatible dictionary.

Returns

dict representation of current DIDDoc

property service: dict

Accessor for services by identifier.

set(item: Union[aries_cloudagent.connections.models.diddoc.service.Service, aries_cloudagent.connections.models.diddoc.publickey.PublicKey]) aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Add or replace service or public key; return current DIDDoc.

Raises

ValueError – if input item is neither service nor public key.

Parameters

item – service or public key to set

Returns: the current DIDDoc

to_json() str[source]

Dump current object as json (JSON-LD).

Returns

json representation of current DIDDoc

aries_cloudagent.connections.models.diddoc.publickey module

DID Document Public Key classes.

Copyright 2017-2019 Government of Canada Public Services and Procurement Canada - buyandsell.gc.ca

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class aries_cloudagent.connections.models.diddoc.publickey.LinkedDataKeySpec(ver_type, authn_type, specifier)

Bases: tuple

property authn_type

Alias for field number 1

property specifier

Alias for field number 2

property ver_type

Alias for field number 0

class aries_cloudagent.connections.models.diddoc.publickey.PublicKey(did: str, ident: str, value: str, pk_type: Optional[aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType] = None, controller: Optional[str] = None, authn: bool = False)[source]

Bases: object

Public key specification to embed in DID document.

Retains DIDs as raw values (orientated toward indy-facing operations), everything else as URIs (oriented toward W3C-facing operations).

property authn: bool

Accessor for the authentication marker.

Returns: whether public key is marked as having DID authentication privilege

property controller: str

Accessor for the controller DID.

property did: str

Accessor for the DID.

property id: str

Accessor for the public key identifier.

to_dict() dict[source]

Return dict representation of public key to embed in DID document.

property type: aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType

Accessor for the public key type.

property value: str

Accessor for the public key value.

class aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType(value)[source]

Bases: enum.Enum

Class encapsulating public key types.

ED25519_SIG_2018 = LinkedDataKeySpec(ver_type='Ed25519VerificationKey2018', authn_type='Ed25519SignatureAuthentication2018', specifier='publicKeyBase58')
EDDSA_SA_SIG_SECP256K1 = LinkedDataKeySpec(ver_type='Secp256k1VerificationKey2018', authn_type='Secp256k1SignatureAuthenticationKey2018', specifier='publicKeyHex')
RSA_SIG_2018 = LinkedDataKeySpec(ver_type='RsaVerificationKey2018', authn_type='RsaSignatureAuthentication2018', specifier='publicKeyPem')
property authn_type: str

Accessor for the authentication type identifier.

static get(val: str) aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType[source]

Find enum instance corresponding to input value (RsaVerificationKey2018 etc).

Parameters

val – input value marking public key type

Returns: the public key type

specification(val: str) str[source]

Return specifier and input value for use in public key specification.

Parameters

val – value of public key

Returns: dict mapping applicable specifier to input value

property specifier: str

Accessor for the value specifier.

property ver_type: str

Accessor for the verification type identifier.

aries_cloudagent.connections.models.diddoc.service module

DID Document Service classes.

Copyright 2017-2019 Government of Canada Public Services and Procurement Canada - buyandsell.gc.ca

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class aries_cloudagent.connections.models.diddoc.service.Service(did: str, ident: str, typ: str, recip_keys: Union[Sequence, aries_cloudagent.connections.models.diddoc.publickey.PublicKey], routing_keys: Union[Sequence, aries_cloudagent.connections.models.diddoc.publickey.PublicKey], endpoint: str, priority: int = 0)[source]

Bases: object

Service specification to embed in DID document.

Retains DIDs as raw values (orientated toward indy-facing operations), everything else as URIs (oriented toward W3C-facing operations).

property did: str

Accessor for the DID value.

property endpoint: str

Accessor for the endpoint value.

property id: str

Accessor for the service identifier.

property priority: int

Accessor for the priority value.

property recip_keys: List[aries_cloudagent.connections.models.diddoc.publickey.PublicKey]

Accessor for the recipient keys.

property routing_keys: List[aries_cloudagent.connections.models.diddoc.publickey.PublicKey]

Accessor for the routing keys.

to_dict() dict[source]

Return dict representation of service to embed in DID document.

property type: str

Accessor for the service type.

aries_cloudagent.connections.models.diddoc.util module

DIDDoc utility methods.

Copyright 2017-2019 Government of Canada Public Services and Procurement Canada - buyandsell.gc.ca

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

aries_cloudagent.connections.models.diddoc.util.canon_did(uri: str) str[source]

Convert a URI into a DID if need be, left-stripping ‘did:sov:’ if present.

Parameters

uri – input URI or DID

Raises

ValueError – for invalid input.

aries_cloudagent.connections.models.diddoc.util.canon_ref(did: str, ref: str, delimiter: Optional[str] = None)[source]

Given a reference in a DID document, return it in its canonical form of a URI.

Parameters
  • did – DID acting as the identifier of the DID document

  • ref – reference to canonicalize, either a DID or a fragment pointing to a location in the DID doc

  • delimiter – delimiter character marking fragment (default ‘#’) or introducing identifier (‘;’) against DID resource

aries_cloudagent.connections.models.diddoc.util.ok_did(token: str) bool[source]

Whether input token looks like a valid decentralized identifier.

Parameters

token – candidate string

Returns: whether input token looks like a valid schema identifier

aries_cloudagent.connections.models.diddoc.util.resource(ref: str, delimiter: Optional[str] = None) str[source]

Extract the resource for an identifier.

Given a (URI) reference, return up to its delimiter (exclusively), or all of it if there is none.

Parameters
  • ref – reference

  • delimiter – delimiter character (default None maps to ‘#’, or ‘;’ introduces identifiers)