Skip to main content

PyVckit

⚠️ Status: Experimental. PyVckit is under active development and its API may change without notice. It has not undergone a formal security audit. Use it at your own risk, and avoid relying on it for production or security-critical systems until it reaches a stable release. Bug reports, issues, and pull requests are welcome.

PyVckit is a library for:

  • sign verifiable credentials
  • verify verifiable credentials
  • generate verifiable presentations
  • verify verifiable submissions

This library is strongly inspired by SpruceId didkit and aims to maintain compatibility with it.

For now the supported cryptography is only EdDSA with a signature Ed25519Signature2018.

Install

For now the installation is from the repository:

    python -m venv env
    source env/bin/activate
    git clone https://farga.pangea.org/ereuse/pyvckit.git
    cd pyvckit
    pip install -r requirements.txt
    pip install -e .

Cli

The mode of use under the command line would be the following:

generate a key pair:

    python pyvckit/did.py -n keys > keypair.json

generate a did identifier:

did key

  python pyvckit/did.py -n did -k keypair.json

did web

  python pyvckit/did.py -n did -k keypair.json -u https://localhost/user1/dids/

generate an example signed credential:

An example of a credential is generated, which is the one that appears in the credential_tmpl template in the file templates.py

    python pyvckit/sign_vc.py -k keypair.json > credential_signed.json

verify a signed credential:

    python pyvckit/verify_vc.py credential_signed.json

generate a verifiable presentation:

    python pyvckit/sign_vp.py -k keypair.json -c credential_signed.json > presentation_signed.json

verify a verifiable presentation:

    python pyvckit/verify_vp.py presentation_signed.json

creation of did document:

This command will create a json document and a url path where to place this document. The did must be a web did. This document is an example and in production it must be adapted to contain the revoked verifiable credentials.

  python pyvckit/did.py -k keypair.json -g did:web:localhost:did-registry:z6MkiNc8xqJLcG7QR1wzD9HPs5oPQEaWNcVf92QsbppNiB7C

Use as a library

In the tests you can find examples of use. Now I will explain the usual cases

generate a key pair:

    from pyvckit.did import generate_keys
    key = generate_keys()

generate a did identifier:

did key

    from pyvckit.did import generate_keys, generate_did
    key = generate_keys()
    did = generate_did(key)

did web

    from pyvckit.did import generate_keys, generate_did
    key = generate_keys()
    url = "https://localhost/user1/dids/"
    did = generate_did(key, url)

generate a signed credential:

Assuming credential is a valid credential. credential is a string variable

    from pyvckit.did import generate_keys, generate_did, get_signing_key
    from pyvckit.sign_vc import sign

    key = generate_keys()
    did = generate_did(key)
    signing_key = get_signing_key(key)
    vc = sign(credential, signing_key, did)

verify a signed credential:

Assuming vc is a properly signed verifiable credential

    import json
    from pyvckit.verify import verify_vc

    verified = verify_vc(json.dumps(vc))

generate a verifiable presentation:

    from pyvckit.did import generate_keys, generate_did, get_signing_key
    from pyvckit.sign_vp import sign_vp

    holder_key = generate_keys()
    holder_did = generate_did(holder_key)
    holder_signing_key = get_signing_key(holder_key)
    vp = sign_vp(holder_signing_key, holder_did, vc_string)

verify a verifiable presentation:

    from pyvckit.verify_vp import verify_vp
    verified = verify_vp(json.dumps(vp))

creation of did document:

This command will create a json document and a url path where to place this document. The did must be a web did. This document is an example and in production it must be adapted to contain the revoked verifiable credentials.

    from pyvckit.did import generate_keys, generate_did, gen_did_document

    key = generate_keys()
    url = "https://localhost/did-registry"
    did = generate_did(key, url)
    definitive_url, document = gen_did_document(did, key)

Differences with didkit from spruceId:

Although there is didkit support, there are some small differences in behavior.

Namespaces:

In didkit it is necessary to define in the context every name, (key) used in the credential or else both the signature and the verification will fail. In pyvckit if a name, (key) is used but is not defined in the context, then that signature or verification will filter out that part of the credential and ignore it as if it did not exist. The signature will be made by deleting that undefined part.

Release files for pyvckit 0.0.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvckit 0.0.21
File Size Uploaded
pyvckit-0.0.21.tar.gz 27.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyvckit 0.0.21
File Interpreter ABI Platform
pyvckit-0.0.21-py3-none-any.whl Python 3 none any Details

Total release size: 53.3 kB

Release files / pyvckit-0.0.21.tar.gz

Download URL pyvckit-0.0.21.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4c637ea81bb990fc4c3839db030ca5b5dddc3ee0d516fb1a67f9145e1df64eea
BLAKE2b-256 checksum
How to use checksums
90a26449b006e4943783416822a58227f1d21a043c8b3583bf188e5a4bf2f9c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / pyvckit-0.0.21-py3-none-any.whl

Download URL pyvckit-0.0.21-py3-none-any.whl
Size 26.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43e8a28a18eb5aed0433b57014cb0f743fb87658952f449b5397e4ae8a4c275d
BLAKE2b-256 checksum
How to use checksums
b499c05738f56501eae22483a067c449aff86823e87353d366c2b02dc9fe99f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.0.21 This release

2 release files

0.0.19

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page