Skip to main content

A did:self implementation

Project description

A python implementation of did:self

This is a python implementation of the did:self method

Usage

This library can be used for Creating, Reading, or Updating a did:self DID. These operations are supported by an auxiliary script called the self registry.

Self registry preparation

Before any operation, a did:self a self registry must be configured with the user's key pair, encoded in JWK. An example of registry initialization is the following

# Generate DID and initial secret key
did_key = jwk.JWK.generate(kty='EC', crv='P-256')
# Initialize registry
owner_registry = registry.DIDSelfRegistry(did_key)

Create

A did:self DID is is the thumbprint of a JWK as defined in RFC 7638. In order to create a did:self DID, a user must generate the corresponding key-pair, create a DID document, and invoke the create method of the DID registry. An example of this process follows

did_key_dict = did_key.export_public(as_dict=True)
did = "did:self:" + did_key.thumbprint()
did_document = {
    'id': did,
    'authentication': [{
        'id': '#key1',
        'type': "JsonWebKey2020",
        'publicKeyJwk': did_key_dict
    }],  
}

owner_registry.create(did_document)

Read

By invoking the read operation of the registry a user obtains the DID document and the proof.

Update

A DID document can be simply updated by invoking the update method of the registry, providing as input the new DID document. For example:

authentication_jwk = jwk.JWK.generate(kty='OKP', crv='Ed25519')
did_document = {
    'id': did,
    'authentication': [{
        'id': did + '#key2',
        'type': "JsonWebKey2020",
        'publicKeyJwk': authentication_jwk.export_public(as_dict=True)
    }]
}
owner_registry.update(did_document)

Project details


Release history Release notifications | RSS feed

This version

2.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

didself-2.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

didself-2.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file didself-2.1.tar.gz.

File metadata

  • Download URL: didself-2.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.9

File hashes

Hashes for didself-2.1.tar.gz
Algorithm Hash digest
SHA256 3cc1c9a0935684a037db4d5b9ec9bac31ce9899ff8c8b8e760f6d9b9b0f28baa
MD5 a06fc72f299de22db3887be64957d6b5
BLAKE2b-256 e586b4920d541c5b074623513510eded82f144a397f530295898383433864f89

See more details on using hashes here.

File details

Details for the file didself-2.1-py3-none-any.whl.

File metadata

  • Download URL: didself-2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.9

File hashes

Hashes for didself-2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0887f201deb6dacc441461f5540b44dd44b03d5a29a49f50b52fb2429168eae
MD5 408d4cb4ad045d2cbd86724b16979ccf
BLAKE2b-256 6b5c45c019447501528ae775007d1560ada305f90f534588226a94ca2beb68b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page