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: 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

authnkey

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

did

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

pubkey

Accessor for public keys by identifier.

serialize() → str[source]

Dump current object to a JSON-compatible dictionary.

Returns:dict representation of current DIDDoc
service

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

authn_type

Alias for field number 1

specifier

Alias for field number 2

ver_type

Alias for field number 0

class aries_cloudagent.connections.models.diddoc.PublicKey(did: str, ident: str, value: str, pk_type: aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType = None, controller: 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).

authn

Accessor for the authentication marker.

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

controller

Accessor for the controller DID.

did

Accessor for the DID.

id

Accessor for the public key identifier.

to_dict() → dict[source]

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

type

Accessor for the public key type.

value

Accessor for the public key value.

class aries_cloudagent.connections.models.diddoc.PublicKeyType[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')
authn_type

Accessor for the authentication type identifier.

get = <function PublicKeyType.get>[source]
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

specifier

Accessor for the value specifier.

ver_type

Accessor for the verification type identifier.

class aries_cloudagent.connections.models.diddoc.Service(did: str, ident: str, typ: str, recip_keys: Union[Sequence[T_co], aries_cloudagent.connections.models.diddoc.publickey.PublicKey], routing_keys: Union[Sequence[T_co], 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).

did

Accessor for the DID value.

endpoint

Accessor for the endpoint value.

id

Accessor for the service identifier.

priority

Accessor for the priority value.

recip_keys

Accessor for the recipient keys.

routing_keys

Accessor for the routing keys.

to_dict() → dict[source]

Return dict representation of service to embed in DID document.

type

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: 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

authnkey

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

did

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

pubkey

Accessor for public keys by identifier.

serialize() → str[source]

Dump current object to a JSON-compatible dictionary.

Returns:dict representation of current DIDDoc
service

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

authn_type

Alias for field number 1

specifier

Alias for field number 2

ver_type

Alias for field number 0

class aries_cloudagent.connections.models.diddoc.publickey.PublicKey(did: str, ident: str, value: str, pk_type: aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType = None, controller: 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).

authn

Accessor for the authentication marker.

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

controller

Accessor for the controller DID.

did

Accessor for the DID.

id

Accessor for the public key identifier.

to_dict() → dict[source]

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

type

Accessor for the public key type.

value

Accessor for the public key value.

class aries_cloudagent.connections.models.diddoc.publickey.PublicKeyType[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')
authn_type

Accessor for the authentication type identifier.

get = <function PublicKeyType.get>[source]
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

specifier

Accessor for the value specifier.

ver_type

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[T_co], aries_cloudagent.connections.models.diddoc.publickey.PublicKey], routing_keys: Union[Sequence[T_co], 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).

did

Accessor for the DID value.

endpoint

Accessor for the endpoint value.

id

Accessor for the service identifier.

priority

Accessor for the priority value.

recip_keys

Accessor for the recipient keys.

routing_keys

Accessor for the routing keys.

to_dict() → dict[source]

Return dict representation of service to embed in DID document.

type

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: 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: 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)