Skip to main content

VCB Verify

CI PyPI Python

Verify Verifiable Credential Barcodes on DL/ID PDF417 barcodes.

Background

Verifiable Credential Barcodes embed digitally signed credentials inside PDF417 barcodes on government-issued drivers licenses and identification cards. This library verifies those credentials: it parses the barcode, checks the cryptographic proof, and optionally checks revocation status.

The library is jurisdiction-agnostic. Any issuer that follows the W3C VCB specification can be supported by adding an IssuerProfile. Built-in profiles are included for California DMV and the W3C Utopia test vectors. Each profile bundles DID documents for offline use, but online resolution is recommended for production to pick up key rotations. Host allowlists on each profile restrict which remote resources can be fetched during verification.

The API is synchronous. Python 3.12+.

Install

pip install vcb-verify

Development:

git clone https://github.com/subfile-llc/vcb-verify.git
cd vcb-verify
pip install -e ".[dev]"

Usage

Basic verification

from vcb_verify import verify
from vcb_verify.issuers import ca_dmv_prod_profile

scanned_data = ...  # PDF417 bytes or string from barcode scanner
result = verify(data=scanned_data, profile=ca_dmv_prod_profile())

if result.valid:
    print("Valid credential")
else:
    print(f"Invalid: {result.error}")

By default, barcodes without VCB data are returned as not-valid rather than raising an error. Pass require_vcb=True to treat missing VCB data as a verification failure, or use profile.vcb_required_after to require it based on the credential's issued date.

Check revocation status

result = verify(
    data=scanned_data,
    profile=ca_dmv_prod_profile(),
    verify_status=True,
)

This uses profile.get_fetching_loader() by default. To supply a custom fetch implementation, pass http_fetch=... to verify() or use profile.get_fetching_loader(http_fetch=...) as document_loader.

Document loaders

Verification resolves JSON-LD contexts and DID documents through a DocumentLoader callback. IssuerProfile.get_loader() provides offline (bundled) and online (HTTP) defaults. For custom fetch behaviour, use build_loader(..., http_fetch=...) or profile.get_fetching_loader(http_fetch=...).

Online mode

online=True (and verify_status=True) enables HTTP for allowlisted remote resources such as revocation status lists. Live did:web fetch happens only when no bundled document is available.

Debug output

result = verify(
    data=scanned_data,
    profile=ca_dmv_prod_profile(),
    debug=True,
)
if result.debug:
    print(result.debug["credential"])
    print(result.debug["aamva_hash"].hex())

Issuer Profiles

An IssuerProfile configures verification for a specific jurisdiction.

Built-in profiles

Profile Function Description
CA DMV Production ca_dmv_prod_profile() California production credentials
CA DMV UAT ca_dmv_uat_profile() California test/UAT credentials
W3C Utopia utopia_test_profile() W3C spec test vectors (offline only)
from vcb_verify.issuers import ca_dmv_prod_profile, ca_dmv_uat_profile, utopia_test_profile

Custom profiles

from vcb_verify import IssuerProfile

profile = IssuerProfile(
    name="my-state",
    issuer_identification_number="123456",
    vcb_subfile="ZC",
    vcb_field="ZCE",
    type_table={ ... },           # CBOR-LD compression table for this issuer
    allowed_hosts={"did.example.com"},
    static_documents={ ... },     # Bundled DID documents for offline mode
)

See the CA DMV profile for a complete example.

API

verify(data, *, profile, ...)

Parameter Type Default Description
data bytes | str (required) PDF417 barcode data
profile IssuerProfile (required) Issuer configuration
require_vcb bool False Require VCB data to be present
verify_status bool False Check revocation status online
document_loader DocumentLoader None Override document loader (default from profile)
http_fetch Callable None Custom HTTP fetch when verify_status=True
debug bool False Include debug details in result

Returns: VerifyResult

Field Type Description
valid bool True if the credential is valid
error Exception | None Error details if invalid
debug dict | None Debug details if requested

IssuerProfile.get_loader(*, online=False)

Returns a document loader for this profile.

Mode Behaviour
online=False (default) Bundled static DID documents (no HTTP)
online=True Bundled DIDs for keys; HTTP for allowlisted status / remote URLs
get_fetching_loader(http_fetch=...) Online loader; optional http_fetch (defaults to default_http_fetch)
Field Type Default Description
loader_timeout float 5.0 HTTP timeout (seconds) for online / fetching loaders

Contribute

pip install -e ".[dev]"
pytest
ruff check src tests

See CHANGELOG.md for release notes.

License

BSD-3-Clause © Subfile, LLC

Download files

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

Source Distribution

vcb_verify-2.0.0.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcb_verify-2.0.0-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file vcb_verify-2.0.0.tar.gz.

File metadata

  • Download URL: vcb_verify-2.0.0.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vcb_verify-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f008b8b76792dd8d5777d60580dc881cebd653ce34bc5fedc6c4c673777760bb
MD5 64c8b136c2b289a07c87450ac6653012
BLAKE2b-256 b70ce2f9a15bb306c3f1721fe17614023d4650b66b997d2773131ccfe7437a3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcb_verify-2.0.0.tar.gz:

Publisher: publish.yml on subfile-llc/vcb-verify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcb_verify-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: vcb_verify-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vcb_verify-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28765ee8baedcdbf38dc9f345f74f9da7123b2404bad2531257449ad7d7e7ff6
MD5 f7c67c5e43502d53b91a5124e7a5234e
BLAKE2b-256 33dac5b0aed5c0f30c5bfcd5e6997547f864df0a47b39a105c5d25eca2e84d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcb_verify-2.0.0-py3-none-any.whl:

Publisher: publish.yml on subfile-llc/vcb-verify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.0.0

2 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