Skip to main content

enterprise_ai.packs.sign

Source: sdks/python/src/enterprise_ai/packs/sign.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Functions​

generate_key_pair​

generate_key_pair(directory: str | Path, password: str | None = None) -> tuple[Path, Path]

cosign generate-key-pair into directory: (cosign.key, cosign.pub).

NameTypeDefaultRequiredDescription
directorystr | PathyesFolder receiving the key pair, created when missing.
passwordstr | NoneNonenoPassword protecting the private key; default the COSIGN_PASSWORD environment variable.

Returns: tuple[Path, Path]. Tuple of the paths (cosign.key, cosign.pub).

sign_digest​

sign_digest(digest: str, key: str | Path, password: str | None = None) -> str

Signature of the digest string, ready for the Marketplace (ecdsa-p256:<base64>).

NameTypeDefaultRequiredDescription
digeststryesDigest string sha256:<hex> of the pack archive.
keystr | PathyesPath of the cosign private key.
passwordstr | NoneNonenoPassword of the key; default the COSIGN_PASSWORD environment variable.

Returns: str. Signature ecdsa-p256:<base64>; a cosign failure raises RuntimeError.

verify_digest​

verify_digest(digest: str, signature: str, public_key: str | Path) -> bool

cosign verify-blob of a signature produced by :func:sign_digest.

NameTypeDefaultRequiredDescription
digeststryesDigest string that was signed.
signaturestryesSignature, with or without the ecdsa-p256: prefix.
public_keystr | PathyesPath of the cosign public key.

Returns: bool. True when the signature matches the digest and the key, else False.