Metadata-Version: 2.4
Name: rh-sigstore-a2a
Version: 0.0.1rc2
Summary: Keyless signing library for A2A Agent Cards using Sigstore and SLSA provenance (Red Hat Tech Preview)
Project-URL: Homepage, https://securesign.github.io/sigstore-a2a
Project-URL: Changelog, https://github.com/securesign/sigstore-a2a/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/securesign/sigstore-a2a
Project-URL: Source, https://github.com/securesign/sigstore-a2a
Project-URL: Issues, https://github.com/securesign/sigstore-a2a/issues
Project-URL: PyPI, https://pypi.org/project/rh-sigstore-a2a/
Author-email: Sigstore Authors <sigstore-dev@googlegroups.com>
Maintainer-email: Sachin Sampras M <sampras343@gmail.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Keywords: AI agent card signing,AI trust framework,Sigstore for agents,agent attestation,agent card verification,agent supply chain security,agent-to-agent communication,digital signatures for AI,keyless signing,transparency log,verifiable provenance
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Classifier: Topic :: Security :: Cryptography
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: a2a-sdk>=0.2.16
Requires-Dist: click>=8.0.0
Requires-Dist: cryptography>=41.0.0
Requires-Dist: fastapi>=0.100.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: pydantic<3.0.0,>=2.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: sigstore>=4.2.0
Requires-Dist: uvicorn>=0.23.0
Description-Content-Type: text/markdown

# sigstore-a2a

> ⚠️ **Warning:** Prototype code - not for production use. Code is not reviewed and has not undergone a security audit.

A Python library and CLI tool for keyless signing of A2A (Agent-to-Agent) AgentCards using
[Sigstore](https://sigstore.dev/) and [SLSA](https://slsa.dev/) provenance attestations.

## Overview

This library enables verifiable supply chain security for A2A agents by providing:

- **Keyless signing** of A2A Agent Cards using Sigstore's infrastructure
- **SLSA provenance generation** to link Agent Cards to their source repositories and build workflows
- **Identity verification** to establish trust in agent origins
- **Discovery integration** for serving signed Agent Cards at well-known endpoints

## Requirements

- Python 3.11+
- UV package manager (recommended) or pip

## Installation

```bash
# Install from source using UV (recommended)
git clone https://github.com/sigstore/sigstore-a2a
cd sigstore-a2a
uv sync --prerelease=allow

# Alternative: Install from source using pip
pip install -e .
```

## Getting Started

### Signing in CI/CD

The library uses ambient OIDC credentials from CI/CD environments like GitHub Actions to perform keyless signing. This creates a verifiable link between your Agent Card and the source code repository:

```bash
# Sign an Agent Card using CI/CD OIDC credentials
sigstore-a2a sign agent-card.json --output signed-agent-card.json

# Sign with explicit repository binding
sigstore-a2a sign agent-card.json --repository $GITHUB_REPOSITORY

# Verify with repository constraint
sigstore-a2a verify signed-agent-card.json --repository owner/repo
```

### Library Usage

```python
from sigstore-a2a.signer import AgentCardSigner
from sigstore-a2a.verifier import AgentCardVerifier
from sigstore-a2a.provenance import ProvenanceBuilder

# Signing (requires OIDC credentials from CI/CD)
signer = AgentCardSigner()
provenance_builder = ProvenanceBuilder()

provenance = provenance_builder.build_provenance("agent-card.json")
signed_card = signer.sign_agent_card("agent-card.json", provenance_bundle=provenance)

# Verify a signed Agent Card
verifier = AgentCardVerifier()
result = verifier.verify_signed_card(signed_card)

if result.valid:
    print(f"Valid signature from {result.identity}")
else:
    print(f"Invalid signature: {result.errors}")
```

## Agent Card Structure

Agent Cards are extended with cryptographic verification material:

```json
{
  "agentCard": {
    "protocolVersion": "0.2.9",
    "name": "Example Agent",
    "description": "An example AI agent",
    "url": "https://example.com/agent",
    "version": "1.0.0",
    "capabilities": {...},
    "skills": [...]
  },
  "verificationMaterial": {
    "signatureBundle": {
      "signature": "base64-encoded-signature",
      "certificate": "-----BEGIN CERTIFICATE-----...",
      "transparencyLogEntry": {...},
      "timestamp": "2024-01-01T00:00:00Z"
    },
    "provenanceBundle": {
      "provenance": {
        "subject": [...],
        "runDetails": {...},
        "buildDefinition": {...}
      }
    }
  }
}
```

## GitHub Actions Integration

Setting up automated Agent Card signing in GitHub Actions creates a secure and auditable process for publishing AI agents. The workflow below demonstrates how to integrate sigstore-a2a into your CI/CD pipeline, ensuring that every Agent Card published from your repository carries cryptographic proof of its origin.

The key to this integration is the OIDC (OpenID Connect) token that GitHub Actions provides. This token contains claims about the repository, workflow, and actor that triggered the build, which Sigstore embeds into the signing certificate. This creates an immutable link between your Agent Card and its source code.

```yaml
name: Build and Sign Agent Card
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  id-token: write  # Required for Sigstore OIDC token
  contents: read   # Required to checkout repository

jobs:
  sign-agent-card:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: Install UV package manager
        run: |
          curl -LsSf https://astral.sh/uv/install.sh | sh
          echo "$HOME/.cargo/bin" >> $GITHUB_PATH

      - name: Install sigstore-a2a
        run: |
          uv sync --prerelease=allow

      - name: Sign Agent Card
        env:
          UV_PRERELEASE: allow
        run: |
          uv run sigstore-a2a sign agent-card.json \
            --output signed-agent-card.json \
            --repository ${{ github.repository }}

      - name: Verify signature locally
        env:
          UV_PRERELEASE: allow
        run: |
          uv run sigstore-a2a verify signed-agent-card.json \
            --repository ${{ github.repository }} \
            --workflow "${{ github.workflow }}"

      - name: Upload signed Agent Card
        uses: actions/upload-artifact@v4
        with:
          name: signed-agent-card
          path: signed-agent-card.json
          retention-days: 30

      - name: Display signature information
        env:
          UV_PRERELEASE: allow
        run: |
          echo "Agent Card signed successfully!"
          echo "Repository: ${{ github.repository }}"
          echo "Workflow: ${{ github.workflow }}"
          echo "SHA: ${{ github.sha }}"
          echo "Actor: ${{ github.actor }}"
```

### Understanding the Signing Process

When your GitHub Actions workflow runs, several important things happen during the signing process. First, GitHub generates an OIDC token that contains metadata about the workflow execution, including the repository name, workflow name, commit SHA, and the user or system that triggered the run. The sigstore-a2a library detects this token automatically and uses it to authenticate with Sigstore's certificate authority "fulcio".

Sigstore then issues a short-lived X.509 certificate that embeds the OIDC claims as certificate extensions. This certificate is used to sign your Agent Card using standard cryptographic algorithms. The signature, certificate, and a reference to the transparency log entry are all bundled together in the signed Agent Card file.

The transparency log entry in Rekor provides public auditability. Anyone can verify that a signature was created at a specific time and tied to a specific repository and workflow, even if the signing certificate has expired. This creates a permanent, tamper-evident record of your Agent Card's provenance.

## Verification and Trust

Agent Card verification is a critical component of the A2A security model. When you receive a signed Agent Card, you can cryptographically verify its authenticity and establish trust based on its provenance. The verification process checks both the signature validity and the identity claims embedded in the signing certificate. It then helps you tie back the 
card to a specific repository, workflow, and actor that created it.

### Basic Verification

The simplest verification check confirms that the signature is valid and the Agent Card hasn't been tampered with:

```bash
# Basic signature verification
uv run sigstore-a2a verify signed-agent-card.json

# Verification with verbose output
uv run sigstore-a2a --verbose verify signed-agent-card.json
```

When verification succeeds, you'll see details about the signing identity, including the repository, workflow, and other metadata from the CI/CD environment where the Agent Card was signed.

### Identity Constraints

Yyou'll typically want to enforce identity constraints that ensure the Agent Card came from a trusted source. These constraints allow you to specify exactly which repositories, workflows, or actors you trust:

```bash
# Verify that the card came from a specific repository
uv run sigstore-a2a verify signed-agent-card.json --repository myorg/trusted-repo

# Verify repository and workflow
uv run sigstore-a2a verify signed-agent-card.json \
  --repository myorg/trusted-repo \
  --workflow "Build and Sign Agent Card"

# Multiple constraints including actor
uv run sigstore-a2a verify signed-agent-card.json \
  --repository myorg/trusted-repo \
  --workflow "Build and Sign Agent Card" \
  --actor trusted-user
```


Identity constraints provide defense against several attack scenarios. They prevent an attacker who has compromised a different repository from creating Agent Cards that appear to come from your trusted source. They also ensure that Agent Cards are only created through approved CI/CD workflows, not through manual processes that might bypass security controls.

### Transparency Log Verification

Every signature created with Sigstore is automatically logged in the public Rekor transparency log. This provides an additional layer of security by creating a tamper-evident record of when the signature was created. You can search the transparency log to verify that a signature was properly logged:

```bash
# The transparency log entry is automatically verified during signature verification
# Additional tooling like rekor-cli can be used for direct transparency log queries

# Example: Search for entries from a specific repository
rekor-cli search --rekor-url https://rekor.sigstore.dev \
  --type dsse \
  --query "repository:myorg/trusted-repo"
```

The transparency log serves multiple purposes in the security model. It provides public auditability, allowing anyone to verify that signatures were created at specific times. It also enables detection of backdated signatures or other anomalies that might indicate compromise. For Agent Cards, this creates a public record of when each version was signed and published.

### Keyless Signing Security

Traditional code signing requires managing long-lived private keys, which creates operational overhead and security risks. Sigstore's keyless signing eliminates these concerns by using short-lived certificates tied to OIDC identity tokens. When you sign an Agent Card in GitHub Actions, the process uses an OIDC token that is valid for only the duration of your workflow run. This token is automatically exchanged for a signing certificate that expires within minutes.

This approach provides several security benefits. There are no long-lived secrets to manage or protect. The signing identity is cryptographically tied to your CI/CD environment, making it nearly impossible for an attacker to forge signatures without compromising your entire development infrastructure. The short certificate lifetime means that even if a certificate were somehow compromised, its window of misuse would be extremely limited.

### Supply Chain Protection

Agent Cards represent code and AI models that will be executed in distributed environments, making supply chain security critical. The combination of Sigstore signatures and SLSA provenance creates a verifiable chain of custody from source code to deployed agent.

When you sign an Agent Card, the signature embeds metadata about the exact source code revision, the build environment, and the CI/CD workflow used. This creates an immutable link between the Agent Card and its origins. Consumers can verify not just that the signature is valid, but that the Agent Card came from a trusted repository and was built using an approved process.

### Verification Best Practices

For production deployments, always use identity constraints when verifying Agent Cards. A basic signature verification only confirms that the signature is cryptographically valid, but doesn't establish whether you should trust the signer. Identity constraints allow you to specify exactly which repositories, workflows, and actors you trust.

Consider implementing a policy where Agent Cards must come from repositories within your organization and must be built using standardized workflows. This prevents the use of Agent Cards that might have been signed by external parties or through non-standard processes.

The transparency log provides an additional verification layer that should be leveraged in high-security environments. By checking that signatures are properly logged in Rekor, you can detect attempts to backdate signatures or other anomalies that might indicate compromise.

### Operational Security

When setting up signing workflows, ensure that your GitHub repository has appropriate branch protection rules and required status checks. The security of your Agent Card signatures is only as strong as the security of your development environment.

Consider using environment-specific signing, where Agent Cards intended for production are only signed from protected branches, while development versions can be signed from feature branches. This can be implemented using different repository constraints in your verification policies.

## API Reference

### AgentCardSigner

```python
class AgentCardSigner:
    def __init__(self, issuer=None, identity_token=None, staging=False)
    def sign_agent_card(self, agent_card, provenance_bundle=None) -> SignedAgentCard
    def sign_file(self, input_path, output_path=None, provenance_bundle=None) -> Path
```

**Parameters:**
- `staging`: Use Sigstore staging environment
- `issuer`: Custom OIDC issuer (optional)
- `identity_token`: Pre-obtained OIDC token (optional)

### AgentCardVerifier

```python
class AgentCardVerifier:
    def __init__(self, staging=False)
    def verify_signed_card(self, signed_card, constraints=None) -> VerificationResult
    def verify_file(self, file_path, constraints=None) -> VerificationResult
```

**Parameters:**
- `staging`: Use Sigstore staging environment
- `constraints`: IdentityConstraints object for repository/workflow verification

### ProvenanceBuilder

```python
class ProvenanceBuilder:
    def __init__(self, build_type="https://github.com/actions/workflow@v1")
    def build_provenance(self, agent_card, source_repo=None, commit_sha=None) -> SLSAProvenance
    def create_subject(self, agent_card, name=None) -> ProvenanceSubject
```

## CLI Reference

The sigstore-a2a command-line interface provides comprehensive tooling for signing, verifying, and serving Agent Cards. Each command supports both testing and production modes, allowing for seamless development and deployment workflows.

### Signing Commands

```bash
# Sign in CI/CD environment
sigstore-a2a sign agent-card.json --repository owner/repo --output signed-card.json

# Sign with SLSA provenance
sigstore-a2a sign agent-card.json --repository owner/repo --commit-sha abc123

# Use staging environment
sigstore-a2a sign agent-card.json --staging
```

### Verification Commands

```bash
# Basic verification
sigstore-a2a verify signed-card.json

# Verification with constraints
sigstore-a2a verify signed-card.json --repository owner/repo --workflow build

# Verbose output with identity details
sigstore-a2a --verbose verify signed-card.json
```

### Utility Commands

```bash
# Serve Agent Card at well-known endpoint
sigstore-a2a serve signed-card.json --port 8080

# Check dependencies and environment
sigstore-a2a check-deps

# Run demo with example Agent Card
sigstore-a2a demo
```

## Troubleshooting

### OIDC Token Issues

In CI/CD environments, ensure:
- `id-token: write` permission is set
- Repository has OIDC enabled
- Workflow runs in trusted environment

Note: This library requires real OIDC credentials and does not support local signing outside of CI/CD environments.

## License

Apache License 2.0

## Related Projects

- [Sigstore](https://sigstore.dev/) - Keyless signing infrastructure
- [SLSA](https://slsa.dev/) - Supply chain security framework
- [A2A Protocol](https://a2a-protocol.org) - Agent-to-Agent communication specification
