Peerdid Python
Implementation of the Peer DID method specification in Python.
Implements static layers of support (1, 2a, 2b) only.
Installation
pip install peerdid
DIDComm + peerdid Demo
See https://github.com/sicpa-dlab/didcomm-demo.
Example
Example code:
from peerdid.dids import (
create_peer_did_numalgo_0,
create_peer_did_numalgo_2,
resolve_peer_did,
)
from peerdid.keys import Ed25519VerificationKey, X25519KeyAgreementKey
encryption_keys = [
X25519KeyAgreementKey.from_base58(
"DmgBSHMqaZiYqwNMEJJuxWzsGGC8jUYADrfSdBrC6L8s"
)
]
signing_keys = [
Ed25519VerificationKey.from_base58(
"ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L7"
)
]
service = {
"type": "DIDCommMessaging",
"serviceEndpoint": "https://example.com/endpoint1",
"routingKeys": ["did:example:somemediator#somekey1"],
"accept": ["didcomm/v2", "didcomm/aip2;env=rfc587"],
}
peer_did_algo_0 = create_peer_did_numalgo_0(inception_key=signing_keys[0])
peer_did_algo_2 = create_peer_did_numalgo_2(
encryption_keys=encryption_keys, signing_keys=signing_keys, service=service
)
did_doc_algo_0 = resolve_peer_did(peer_did_algo_0)
did_doc_algo_2 = resolve_peer_did(peer_did_algo_2)
did_doc_algo_0_json = did_doc_algo_0.to_json()
did_doc_algo_2_json = did_doc_algo_2.to_json()
Example of DID documents:
// did_doc_algo_0_json
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V",
"verificationMethod": [
{
"id": "#6MkqRYqQ",
"type": "Ed25519VerificationKey2020",
"controller": "did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V",
"publicKeyMultibase": "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V"
}
],
"authentication": ["#6MkqRYqQ"],
"assertionMethod": ["#6MkqRYqQ"],
"capabilityInvocation": ["#6MkqRYqQ"],
"capabilityDelegation": ["#6MkqRYqQ"]
}
// did_doc_algo_2_json
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/x25519-2020/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ",
"verificationMethod": [
{
"id": "#6LSpSrLx",
"type": "X25519KeyAgreementKey2020",
"controller": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ",
"publicKeyMultibase": "z6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud"
},
{
"id": "#6MkqRYqQ",
"type": "Ed25519VerificationKey2020",
"controller": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ",
"publicKeyMultibase": "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V"
}
],
"authentication": ["#6MkqRYqQ"],
"assertionMethod": ["#6MkqRYqQ"],
"keyAgreement": ["#6LSpSrLx"],
"capabilityInvocation": ["#6MkqRYqQ"],
"capabilityDelegation": ["#6MkqRYqQ"],
"service": [
{
"id": "#didcommmessaging-0",
"type": "DIDCommMessaging",
"serviceEndpoint": "https://example.com/endpoint1",
"accept": ["didcomm/v2", "didcomm/aip2;env=rfc587"],
"routingKeys": ["did:example:somemediator#somekey1"]
}
]
}
Assumptions and limitations
- Only static layers 1, 2a, 2b are supported
- Only
X25519keys are supported for key agreement - Only
Ed25519keys are supported for authentication - Supported verification materials (input and in the resolved DID Document):
- [Default] 2020 verification materials (
Ed25519VerificationKey2020andX25519KeyAgreementKey2020) with multibase base58 (publicKeyMultibase) public key encoding. - JWK (
JsonWebKey2020) using JWK (publicKeyJwk) public key encoding - 2018/2019 verification materials (
Ed25519VerificationKey2018andX25519KeyAgreementKey2019) using base58 (publicKeyBase58) public key encoding.
- [Default] 2020 verification materials (
How to contribute
Pull requests are welcome!
Pull requests should have a descriptive name, include the summary of all changes made in the pull request description, and include unit tests that provide good coverage of the feature or fix. A Continuous Integration ( CI) pipeline is executed on all PRs before review and contributors are expected to address all CI issues identified.
A Continuous Integration (CI) pipeline does the following jobs:
- Executes all unit tests from the pull request.
- Analyzes code style using Flake8.
Metadata
Release files for peerdid 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| peerdid-0.5.2.tar.gz | 20.0 kB | Without provenance | Details for peerdid-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| peerdid-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for peerdid-0.5.2-py3-none-any.whl |
Total release size: 36.4 kB
Release files / peerdid-0.5.2.tar.gz
| Download URL | peerdid-0.5.2.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efc4c16a4cf2b3802a62e0d5be459a5019ccf48befdc17d1c97f6d47be4f7130
|
|
BLAKE2b-256 checksum How to use checksums |
ee539148681bcffcaa735829c5d9fa73cc915473e8476f5e4b296c027975a16e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / peerdid-0.5.2-py3-none-any.whl
| Download URL | peerdid-0.5.2-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e92be3ba483cf3e37e87d9855afae2346266f8e4d86809071edb6dbce510d569
|
|
BLAKE2b-256 checksum How to use checksums |
26b9347dfa01036f7d6158691d34ff46ddbd482ba79ea3e3e6f43584b5691a9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for peerdid 0.5.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.