A Python SDK for AI agents to securely generate and verify 'hello' authentication messages, enabling seamless interaction between AI agents and AI-centric services.
Project description
Hello-Message Python SDK
The Hello-Message Python SDK provides a simple interface for generating and verifying "hello" authentication messages for AI-to-AI and AI-to-AI-first services. This SDK is designed to work by using cryptographic signatures for secure authentication.
Installation
Install the SDK from PyPI using pip:
pip install hello-message-sdk
Features
- Generate Hello Messages: Create signed "hello" messages using Ethereum private keys.
- Verify Signatures: Validate the authenticity of signed "hello" messages.
Quick Start
Generate and use a "Hello" Message
# Initialize the Hello SDK with your private key
# This private key is for verification purposes only -- should not be used in production
def key_provider():
# E.g. should retrieve from environment or secure vault, not hardcoded like it is here.
private_key = '0x4c0883a6910395b1e8dcd7db363c124593f3e8e62e4a8c32ef45b3ef82317b03' # Replace with your actual private key
return private_key
hello = Hello(key_provider)
# Generate a signed message
signed_message = hello.generate_hello_message()
# Define the URL of the protected route
url = 'API_ENDPOINT_URL' # Adjust the URL if your Flask service is hosted elsewhere
# Set up the headers with the signed message for authentication
headers = {
'X-Hello-Message': signed_message
}
response = requests.get(url, headers=headers)
Verify a "Hello" Message
from hello_message import Hello
message = request.headers.get('X-Hello-Message')
# Verify the signed message
validation_response = Hello.verify_signature(message):
print("Is valid:", validation_response["valid"])
# If the message is valid, you should use the nonce to check if it has already been used to prevent replay attacks
print("Nonce to check:", validation_response["nonce"])
API Reference
Class: Hello
Hello(key_provider: callable)
Initialize the Hello object with an Ethereum private key provider.
key_provider: Ethereum private key provider to use retrieve the private key for signing messages.
get_address() -> str
Get the Ethereum address corresponding to the private key.
generate_hello_message() -> dict
Generate a signed "hello" message.
verify_signature(signature: str, message: str, address: str) -> bool
Verify the authenticity of a "hello" message signature.
signature: The signed "hello" message (string).message: The message to verify (string).address: The Ethereum address expected to have signed the message (string).
Returns:
Trueif the signature is valid.Falseotherwise.
Testing
Run the tests using pytest:
python -m pytest
Contributing
We welcome contributions from the community! To get started:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
- Discussions: Join the conversation.
- Issues: Report bugs or request features.
Happy coding with Hello-Message Python SDK!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hello_message_sdk-0.3.0.tar.gz.
File metadata
- Download URL: hello_message_sdk-0.3.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed4504ca152615f2fa9f4175733b58edaa98a5cb4b6d93a4eb8e62916ab1b7d
|
|
| MD5 |
a99332370482d63ac33693ad055b1b0c
|
|
| BLAKE2b-256 |
4bdbd808ecfe9109531c6aafce79caee5a9fb78c9c684cfca143833be5d1a240
|
Provenance
The following attestation bundles were made for hello_message_sdk-0.3.0.tar.gz:
Publisher:
python-publish.yml on aimxlabs/hello-message-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hello_message_sdk-0.3.0.tar.gz -
Subject digest:
7ed4504ca152615f2fa9f4175733b58edaa98a5cb4b6d93a4eb8e62916ab1b7d - Sigstore transparency entry: 157298907
- Sigstore integration time:
-
Permalink:
aimxlabs/hello-message-python@b843f603063108373042b9567155f40f7924112f -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/aimxlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b843f603063108373042b9567155f40f7924112f -
Trigger Event:
release
-
Statement type:
File details
Details for the file hello_message_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: hello_message_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7314bdd271102414b46eb49a6b497d941bf42a98c403a217d56e44385e0dfba
|
|
| MD5 |
8ae154efe02f6320b364bae940e508d7
|
|
| BLAKE2b-256 |
d30d862974ccbe12c7e56cf8572782f98e417fb7491727fab2f75162af36545d
|
Provenance
The following attestation bundles were made for hello_message_sdk-0.3.0-py3-none-any.whl:
Publisher:
python-publish.yml on aimxlabs/hello-message-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hello_message_sdk-0.3.0-py3-none-any.whl -
Subject digest:
c7314bdd271102414b46eb49a6b497d941bf42a98c403a217d56e44385e0dfba - Sigstore transparency entry: 157298908
- Sigstore integration time:
-
Permalink:
aimxlabs/hello-message-python@b843f603063108373042b9567155f40f7924112f -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/aimxlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b843f603063108373042b9567155f40f7924112f -
Trigger Event:
release
-
Statement type: