PyPI Attestation Models
A library to convert between Sigstore Bundles and PEP 740 Attestation objects
Installation
python -m pip install pypi-attestation-models
Usage
See the full API documentation here.
Signing and verification
Use these APIs to create a PEP 740-compliant Attestation object by signing a Python artifact
(i.e: sdist or wheel files), and to verify an Attestation object against a Python artifact.
from pathlib import Path
from pypi_attestation_models import Attestation, AttestationPayload
from sigstore.oidc import Issuer
from sigstore.sign import SigningContext
from sigstore.verify import Verifier, policy
artifact_path = Path("test_package-0.0.1-py3-none-any.whl")
# Sign a Python artifact
issuer = Issuer.production()
identity_token = issuer.identity_token()
signing_ctx = SigningContext.production()
with signing_ctx.signer(identity_token, cache=True) as signer:
attestation = AttestationPayload.from_dist(artifact_path).sign(signer)
print(attestation.model_dump_json())
# Verify an attestation against a Python artifact
attestation_path = Path("test_package-0.0.1-py3-none-any.whl.attestation")
attestation = Attestation.model_validate_json(attestation_path.read_bytes())
verifier = Verifier.production()
policy = policy.Identity(identity="example@gmail.com", issuer="https://accounts.google.com")
attestation.verify(verifier, policy, attestation_path)
Low-level model conversions
These conversions assume that any Sigstore Bundle used as an input was created
by signing an AttestationPayload object.
from pathlib import Path
from pypi_attestation_models import pypi_to_sigstore, sigstore_to_pypi, Attestation
from sigstore.models import Bundle
# Sigstore Bundle -> PEP 740 Attestation object
bundle_path = Path("test_package-0.0.1-py3-none-any.whl.sigstore")
with bundle_path.open("rb") as f:
sigstore_bundle = Bundle.from_json(f.read())
attestation_object = sigstore_to_pypi(sigstore_bundle)
print(attestation_object.model_dump_json())
# PEP 740 Attestation object -> Sigstore Bundle
attestation_path = Path("attestation.json")
with attestation_path.open("rb") as f:
attestation = Attestation.model_validate_json(f.read())
bundle = pypi_to_sigstore(attestation)
print(bundle.to_json())
Metadata
Release files for pypi-attestation-models 0.0.5
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 |
|---|---|---|---|---|
| pypi_attestation_models-0.0.5.tar.gz | 9.7 kB | Without provenance | Details for pypi_attestation_models-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypi_attestation_models-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for pypi_attestation_models-0.0.5-py3-none-any.whl |
Total release size: 19.7 kB
Release files / pypi_attestation_models-0.0.5.tar.gz
| Download URL | pypi_attestation_models-0.0.5.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cceb48aec1c9d93d880d2a6c8c9581bedb503b66203e37081e1ba2e863b6bac9
|
|
BLAKE2b-256 checksum How to use checksums |
f047c5c791a553e6b07d8bdebaec8239921aa4f70134ddc804ac0aa95a575f56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / pypi_attestation_models-0.0.5-py3-none-any.whl
| Download URL | pypi_attestation_models-0.0.5-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d105bc4cf167d4d1db180177bc464bcc4cea8437cdc583c6598424b712c8b068
|
|
BLAKE2b-256 checksum How to use checksums |
0e06accdc6d290d52eaa398dd7c6d1d8dced62075550325b1145c76502e0f442
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for pypi-attestation-models 0.0.5
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.