Sigstore Rekor Types

0.0.18 · active · verified Thu Apr 16

This package provides Python data models for the Sigstore Rekor API types. It primarily consists of Pydantic models generated from the Rekor OpenAPI specification, enabling programmatic interaction with Rekor's data structures. The library is currently at version 0.0.18 and receives updates as the upstream Rekor API evolves, maintaining an active release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate core Pydantic models provided by `sigstore-rekor-types`, specifically `HashedRekord` which is a primary entry type in Rekor v2, and a generic `LogEntry` structure. This library focuses purely on data models, not client interaction with the Rekor API itself. For full client functionality (uploading, verifying), integrate with `sigstore-python`.

import datetime
from sigstore_rekor_types.models.hashedrekord import HashedRekord, HashedRekordSchema
from sigstore_rekor_types.models.log_entry import LogEntry
from sigstore_rekor_types.models.rekord import RekordObj, RekordObjSchema, RekordObjSignature, RekordObjSignaturePublicKey, RekordObjSignatureData

# Example of creating a HashedRekord object (a common Rekor v2 type)
# Note: This library provides models, not client functionality to upload to Rekor.
# For a full client, see sigstore-python.

try:
    hashed_rekord_content = HashedRekordSchema(
        apiVersion='0.0.1',
        kind='hashedrekord',
        spec=HashedRekord(
            signature=RekordObjSignature(
                content='base64encodedsignature==',
                format='minisign',
                publicKey=RekordObjSignaturePublicKey(
                    content='base64encodedpublickey=='
                )
            ),
            data=RekordObjData(
                hash=RekordObjHash(
                    algorithm='sha256',
                    value='a' * 64 # Example SHA256 hash
                )
            )
        )
    )
    print("HashedRekord object created successfully:")
    print(hashed_rekord_content.model_dump_json(indent=2))

    # Example of a generic LogEntry structure, often returned by Rekor
    example_log_entry = LogEntry(
        apiVersion="1.0.0",
        kind="hashedrekord",
        spec=hashed_rekord_content.spec.model_dump(mode='json'), # embed the spec
        uuid="some-unique-uuid",
        integratedTime=int(datetime.datetime.now(datetime.timezone.utc).timestamp()),
        logID="some-log-id",
        logIndex=12345,
        body="base64encodedlogentrybody==",
        verification=None
    )
    print("\nExample LogEntry object (often retrieved from Rekor):")
    print(example_log_entry.model_dump_json(indent=2))

except Exception as e:
    print(f"Error creating models: {e}")

view raw JSON →