Verifiable Credentials verifier supporting W3C Data Integrity Proofs (ecdsa-jcs-2022), did:web, and StatusList2021
Project description
VC Verifier
Open-source Verifiable Credentials verifier supporting W3C standards.
Features
- W3C Data Integrity Proofs -
ecdsa-jcs-2022cryptosuite - ECDSA P-256 (secp256r1) signature verification
- did:web DID method resolution
- StatusList2021 revocation/suspension checking
- JCS (JSON Canonicalization Scheme, RFC 8785) support
Installation
pip install vc-verifier
Or from source:
git clone https://github.com/RLDAC/vc-verifier.git
cd vc-verifier
pip install -e .
Quick Start
Python API
from vc_verifier import verify_credential, VCVerifier
# Verify a credential
credential = {
"@context": ["https://www.w3.org/ns/credentials/v2"],
"type": ["VerifiableCredential"],
"issuer": "did:web:example.com",
"credentialSubject": {
"id": "did:example:holder",
"name": "Alice"
},
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "ecdsa-jcs-2022",
"verificationMethod": "did:web:example.com#key-1",
"proofValue": "..."
}
}
# Simple verification
result = verify_credential(credential)
print(f"Valid: {result.is_valid}")
# With more control
verifier = VCVerifier(verify_status=True)
result = verifier.verify(credential)
if result.is_valid:
print("Credential is valid!")
else:
print(f"Errors: {result.errors}")
Command Line
# Verify a local file
vc-verify credential.json
# Verify from URL
vc-verify https://example.com/credentials/123
# Verify from stdin
cat credential.json | vc-verify -
# Output as JSON
vc-verify credential.json --json-output
# Skip revocation check
vc-verify credential.json --no-status
Supported Standards
| Standard | Support |
|---|---|
| W3C VC Data Model 2.0 | Full |
| W3C Data Integrity | ecdsa-jcs-2022 |
| did:web | Full |
| StatusList2021 | Revocation, Suspension |
Cryptographic Details
Signature Verification
- Extract
prooffrom credential - Canonicalize the unsigned credential using JCS (RFC 8785)
- Encode as UTF-8 bytes
- Verify ECDSA P-256 signature against the public key
JCS Canonicalization (RFC 8785)
json.dumps(data, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
DID Resolution
did:web:example.com -> https://example.com/.well-known/did.json
did:web:example.com:path:doc -> https://example.com/path/doc/did.json
did:web:example.com%3A8080 -> https://example.com:8080/.well-known/did.json
StatusList2021
Bitstring encoding: base64(gzip(bitstring))
- Bit 0 = MSB of byte 0
0= valid,1= revoked/suspended
API Reference
VCVerifier
class VCVerifier:
def __init__(
self,
did_resolver: DIDResolver | None = None,
statuslist_checker: StatusListChecker | None = None,
verify_status: bool = True,
) -> None: ...
def verify(self, credential: dict) -> VerificationResult: ...
VerificationResult
@dataclass
class VerificationResult:
status: VerificationStatus # VALID, INVALID, or ERROR
credential_id: str | None
issuer: str | None
proof: ProofVerificationResult | None
credential_status: StatusCheckResult | None
errors: list[str]
warnings: list[str]
@property
def is_valid(self) -> bool: ...
DIDResolver
class DIDResolver:
def __init__(
self,
timeout: float = 30.0,
verify_ssl: bool = True,
) -> None: ...
def resolve(self, did: str, use_cache: bool = True) -> DIDDocument: ...
StatusListChecker
class StatusListChecker:
def __init__(
self,
timeout: float = 30.0,
verify_ssl: bool = True,
) -> None: ...
def check_status(
self,
credential: dict,
use_cache: bool = True,
) -> StatusCheckResult | None: ...
Development
# Clone
git clone https://github.com/RLDAC/vc-verifier.git
cd vc-verifier
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check src tests
License
MIT License - see LICENSE for details.
Related
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
vc_verifier-0.1.0.tar.gz
(14.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vc_verifier-0.1.0.tar.gz.
File metadata
- Download URL: vc_verifier-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2befc237bedd663a3bd21388b14cd92eaa3ddc43927765db6b850b4358396734
|
|
| MD5 |
12ddd9b71a66ad04413fc2761ccbb741
|
|
| BLAKE2b-256 |
03a3934c9955d3609b262d50127bab0db99cd4d1c5e9fde4260151f2a1db72b9
|
File details
Details for the file vc_verifier-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vc_verifier-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
473a5353bcf27127c3748d7767e63868cb5698d61a653f5411d62dd9772f5d7d
|
|
| MD5 |
eff1f12c087cf1027880c3d1d1ca52db
|
|
| BLAKE2b-256 |
3ab6c6f6da24f2f58d072dc7e31df2f83c05ca3b82da51c187dea19144a0d49c
|