Skip to content

Models

Common models shared between signing and verification.

TransparencyLogEntry(inner)

Represents a transparency log entry.

Creates a new TransparencyLogEntry from the given inner object.

@private

Source code in sigstore/models.py
70
71
72
73
74
75
76
77
def __init__(self, inner: _TransparencyLogEntry) -> None:
    """
    Creates a new `TransparencyLogEntry` from the given inner object.

    @private
    """
    self._inner = inner
    self._validate()

TimestampVerificationData(inner)

Represents a TimestampVerificationData structure.

@private

Init method.

Source code in sigstore/models.py
236
237
238
239
def __init__(self, inner: _TimestampVerificationData) -> None:
    """Init method."""
    self._inner = inner
    self._verify()

rfc3161_timestamps property

Returns a list of signed timestamp.

from_json(raw) classmethod

Deserialize the given timestamp verification data.

Source code in sigstore/models.py
263
264
265
266
267
268
269
@classmethod
def from_json(cls, raw: str | bytes) -> TimestampVerificationData:
    """
    Deserialize the given timestamp verification data.
    """
    inner = _TimestampVerificationData.from_json(raw)
    return cls(inner)

VerificationMaterial(inner)

Represents a VerificationMaterial structure.

Init method.

Source code in sigstore/models.py
277
278
279
def __init__(self, inner: _VerificationMaterial) -> None:
    """Init method."""
    self._inner = inner

timestamp_verification_data property

Returns the Timestamp Verification Data, if present.

InvalidBundle

Bases: Error

Raised when the associated Bundle is invalid in some way.

diagnostics()

Returns diagnostics for the error.

Source code in sigstore/models.py
299
300
301
302
303
304
305
306
307
308
309
310
311
312
def diagnostics(self) -> str:
    """Returns diagnostics for the error."""

    return dedent(
        f"""\
    An issue occurred while parsing the Sigstore bundle.

    The provided bundle is malformed and may have been modified maliciously.

    Additional context:

    {self}
    """
    )

Bundle(inner)

Represents a Sigstore bundle.

Creates a new bundle. This is not a public API; use from_json instead.

@private

Source code in sigstore/models.py
334
335
336
337
338
339
340
341
342
def __init__(self, inner: _Bundle) -> None:
    """
    Creates a new bundle. This is not a public API; use
    `from_json` instead.

    @private
    """
    self._inner = inner
    self._verify()

signing_certificate property

Returns the bundle's contained signing (i.e. leaf) certificate.

log_entry property

Returns the bundle's log entry, containing an inclusion proof (with checkpoint) and an inclusion promise (if the latter is present).

signature property

Returns the signature bytes of this bundle. Either from the DSSE Envelope or from the message itself.

verification_material property

Returns the bundle's verification material.

BundleType

Bases: str, Enum

Known Sigstore bundle media types.

from_json(raw) classmethod

Deserialize the given Sigstore bundle.

Source code in sigstore/models.py
502
503
504
505
506
507
508
509
510
511
@classmethod
def from_json(cls, raw: bytes | str) -> Bundle:
    """
    Deserialize the given Sigstore bundle.
    """
    try:
        inner = _Bundle.from_json(raw)
    except ValueError as exc:
        raise InvalidBundle(f"failed to load bundle: {exc}")
    return cls(inner)

to_json()

Return a JSON encoding of this bundle.

Source code in sigstore/models.py
513
514
515
516
517
def to_json(self) -> str:
    """
    Return a JSON encoding of this bundle.
    """
    return self._inner.to_json()

from_parts(cert, sig, log_entry) classmethod

Construct a Sigstore bundle (of hashedrekord type) from its constituent parts.

Source code in sigstore/models.py
536
537
538
539
540
541
542
543
544
545
546
547
@classmethod
def from_parts(
    cls, cert: Certificate, sig: bytes, log_entry: TransparencyLogEntry
) -> Bundle:
    """
    Construct a Sigstore bundle (of `hashedrekord` type) from its
    constituent parts.
    """

    return cls._from_parts(
        cert, MessageSignature(signature=base64.b64encode(sig)), log_entry
    )