SGAIP Python Reference Implementation
- Package: sgaip
- Version: 0.1.1 (ready for PyPI)
- License: Apache-2.0
- Python: 3.10+
- Repository: https://github.com/k-kaundal/sgaip
- PyPI: https://pypi.org/project/sgaip/
Overview
sgaip is a production-ready reference implementation of the Stateless Global Agent Identity Protocol (SGAIP).
It provides:
- Core library – deterministic identity derivation, Ed25519 operations
- CLI tool – global
sgaipcommand for key generation, signing, verification - Full type safety – complete type hints with mypy support
- Comprehensive tests – unit tests with pytest + coverage
- Production quality – linting, formatting, strict type checking
Installation
From PyPI
pip install sgaip
From Source
git clone https://github.com/k-kaundal/sgaip.git
cd sgaip/reference/python
pip install -e .
With Development Tools
pip install -e .[dev]
CLI Usage
The sgaip command provides three main operations:
1. Generate a Keypair
sgaip keygen --private agent.sk --public agent.pk
Outputs:
agent.sk– private key (keep secret!)agent.pk– public key- Derived Agent ID (AID) to console
2. Sign a Message
sgaip sign --private agent.sk --message "Hello, World!"
sgaip sign --private agent.sk --file data.txt --out data.sig
Creates:
signature.bin(or custom--outfile)
3. Verify Offline
sgaip verify --public agent.pk --signature signature.bin --message "Hello, World!"
sgaip verify --public agent.pk --signature data.sig --file data.txt
Prints:
- ✅ Signature validity
- Derived Agent ID (AID)
All operations work completely offline – no internet required.
Python API
Basic Usage
from sgaip import (
generate_keypair,
serialize_public_key,
derive_agent_id,
sign_challenge,
verify_proof,
)
# Generate identity
private_key, public_key = generate_keypair()
public_bytes = serialize_public_key(public_key)
# Derive Agent Identity
aid = derive_agent_id(public_bytes)
print(f"Agent ID: {aid}")
# Sign a challenge
challenge = b"verifier-challenge-123"
signature = sign_challenge(private_key, challenge)
# Verify offline
is_valid = verify_proof(public_bytes, challenge, signature, expected_aid=aid)
assert is_valid
Advanced: Import from Package
import sgaip
# All public functions available
print(sgaip.__version__)
keypair = sgaip.generate_keypair()
aid = sgaip.derive_agent_id(sgaip.serialize_public_key(keypair[1]))
Development
Setup
cd sgaip/reference/python
python -m venv venv
source venv/bin/activate
pip install -e .[dev]
Testing
# Run all tests
pytest tests/
# With coverage
pytest tests/ --cov=sgaip --cov-report=html
# Watch mode
pytest-watch tests/
Linting & Formatting
# Format code
black sgaip/ tests/ bin/
# Check style
black --check sgaip/ tests/
# Lint with ruff
ruff check sgaip/ tests/
ruff check --fix sgaip/ tests/
# Type check
mypy sgaip/
Running Individual Commands
# Keygen
python -m sgaip keygen --private test.sk --public test.pk
# Sign
python -m sgaip sign --private test.sk --message "test"
# Verify
python -m sgaip verify --public test.pk --signature signature.bin --message "test"
Security Notes
⚠️ Reference implementation — not security audited.
- Protect private key files (
.sk) – anyone with the key controls the identity - Loss of private key means loss of identity (no recovery mechanism)
- SGAIP provides authentication only, not trust or authorization
- See specs/threat-model.md for detailed security analysis
Specifications
This package implements:
Testing & Interoperability
Python tests verify:
- ✅ Deterministic identity derivation (same AID for same public key)
- ✅ Ed25519 signature scheme correctness
- ✅ Offline verification
- ✅ CLI command handling
Run the full suite:
pytest tests/ --cov=sgaip
Troubleshooting
Issue: ModuleNotFoundError: No module named 'cryptography'
pip install cryptography
Issue: Type checking fails
mypy sgaip/ --ignore-missing-imports
Issue: Tests fail on import
Ensure you've installed in editable mode:
pip install -e .
Contributing
See DEVELOPMENT.md for contribution guidelines.
Key areas for contribution:
- Additional test vectors
- Performance optimizations
- Documentation improvements
- Additional language bindings
License
Apache License 2.0 – see LICENSE
Related Projects
- JavaScript/TypeScript: reference/js/
- Protocol Specification: specs/
- Test Vectors: test-vectors/
Questions?
Open an issue on GitHub or see GOVERNANCE.md.
Metadata
Release files for sgaip 0.1.3
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 | |
|---|---|---|---|---|
| sgaip-0.1.3.tar.gz | 8.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sgaip-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.9 kB
Release files / sgaip-0.1.3.tar.gz
| Download URL | sgaip-0.1.3.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d06e2fffa21200c7318e02b22b16340bc814c86316545a4482c7da053c2841da
|
|
BLAKE2b-256 checksum How to use checksums |
f02dbc926ebc31b14870795aca98dc104a3dc5bebb39098a77aa9436d384bf07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / sgaip-0.1.3-py3-none-any.whl
| Download URL | sgaip-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd4e6f07814abf41399cbf542236ed66ce42c40e653fa0f22dd59a65f84e077c
|
|
BLAKE2b-256 checksum How to use checksums |
c9fe1b5b716092039e9ecf406c9f31ab5626e7906136c4518a2f9029d1b17980
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for sgaip 0.1.3
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.