hello-message-sdk


Namehello-message-sdk JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/aimxlabs/hello-message-python
SummaryA Python SDK for AI agents to securely generate and verify 'hello' authentication messages, enabling seamless interaction between AI agents and AI-centric services.
upload_time2024-12-22 01:45:27
maintainerNone
docs_urlNone
authoranythingmachine
requires_python>=3.6
licenseNone
keywords hello-message authentication ethereum sdk ai artificial-intelligence autonomous-agents ai-first-services blockchain ai-authentication
VCS
bugtrack_url
requirements eth-account pytest
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
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

```python
# 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

```python
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:

- `True` if the signature is valid.
- `False` otherwise.

---

## Testing

Run the tests using `pytest`:

```bash
python -m pytest
```

---

## Contributing

We welcome contributions from the community! To get started:

1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Submit a pull request with a detailed description of your changes.

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

## Support

- [Discussions](https://github.com/aimxlabs/hello-message-python/discussions): Join the conversation.
- [Issues](https://github.com/aimxlabs/hello-message-python/issues): Report bugs or request features.

---

Happy coding with Hello-Message Python SDK!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aimxlabs/hello-message-python",
    "name": "hello-message-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "hello-message, authentication, ethereum, sdk, ai, artificial-intelligence, autonomous-agents, ai-first-services, blockchain, ai-authentication",
    "author": "anythingmachine",
    "author_email": "anythingmachine@aimx.com",
    "download_url": "https://files.pythonhosted.org/packages/4b/db/d808ecfe9109531c6aafce79caee5a9fb78c9c684cfca143833be5d1a240/hello_message_sdk-0.3.0.tar.gz",
    "platform": null,
    "description": "# Hello-Message Python SDK\n\nThe 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.\n\n---\n\n## Installation\n\nInstall the SDK from PyPI using pip:\n\n```bash\npip install hello-message-sdk\n```\n\n---\n\n## Features\n\n- **Generate Hello Messages**: Create signed \"hello\" messages using Ethereum private keys.\n- **Verify Signatures**: Validate the authenticity of signed \"hello\" messages.\n\n---\n\n## Quick Start\n\n### Generate and use a \"Hello\" Message\n\n```python\n# Initialize the Hello SDK with your private key\n# This private key is for verification purposes only -- should not be used in production\ndef key_provider():\n    # E.g. should retrieve from environment or secure vault, not hardcoded like it is here.\n    private_key = '0x4c0883a6910395b1e8dcd7db363c124593f3e8e62e4a8c32ef45b3ef82317b03'  # Replace with your actual private key\n    return private_key\n\nhello = Hello(key_provider)\n\n# Generate a signed message\nsigned_message = hello.generate_hello_message()\n\n# Define the URL of the protected route\nurl = 'API_ENDPOINT_URL'  # Adjust the URL if your Flask service is hosted elsewhere\n\n# Set up the headers with the signed message for authentication\nheaders = {\n    'X-Hello-Message': signed_message\n}\n\nresponse = requests.get(url, headers=headers)\n```\n\n### Verify a \"Hello\" Message\n\n```python\nfrom hello_message import Hello\n\nmessage = request.headers.get('X-Hello-Message')\n\n# Verify the signed message\nvalidation_response = Hello.verify_signature(message):\nprint(\"Is valid:\", validation_response[\"valid\"])\n\n# If the message is valid, you should use the nonce to check if it has already been used to prevent replay attacks\nprint(\"Nonce to check:\", validation_response[\"nonce\"])\n```\n\n---\n\n## API Reference\n\n### Class: `Hello`\n\n#### **`Hello(key_provider: callable)`**\n\nInitialize the Hello object with an Ethereum private key provider.\n\n- `key_provider`: Ethereum private key provider to use retrieve the private key for signing messages.\n\n#### **`get_address() -> str`**\n\nGet the Ethereum address corresponding to the private key.\n\n#### **`generate_hello_message() -> dict`**\n\nGenerate a signed \"hello\" message.\n\n#### **`verify_signature(signature: str, message: str, address: str) -> bool`**\n\nVerify the authenticity of a \"hello\" message signature.\n\n- `signature`: The signed \"hello\" message (string).\n- `message`: The message to verify (string).\n- `address`: The Ethereum address expected to have signed the message (string).\n\nReturns:\n\n- `True` if the signature is valid.\n- `False` otherwise.\n\n---\n\n## Testing\n\nRun the tests using `pytest`:\n\n```bash\npython -m pytest\n```\n\n---\n\n## Contributing\n\nWe welcome contributions from the community! To get started:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Submit a pull request with a detailed description of your changes.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Support\n\n- [Discussions](https://github.com/aimxlabs/hello-message-python/discussions): Join the conversation.\n- [Issues](https://github.com/aimxlabs/hello-message-python/issues): Report bugs or request features.\n\n---\n\nHappy coding with Hello-Message Python SDK!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python SDK for AI agents to securely generate and verify 'hello' authentication messages, enabling seamless interaction between AI agents and AI-centric services.",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/aimxlabs/hello-message-python"
    },
    "split_keywords": [
        "hello-message",
        " authentication",
        " ethereum",
        " sdk",
        " ai",
        " artificial-intelligence",
        " autonomous-agents",
        " ai-first-services",
        " blockchain",
        " ai-authentication"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d30d862974ccbe12c7e56cf8572782f98e417fb7491727fab2f75162af36545d",
                "md5": "8ae154efe02f6320b364bae940e508d7",
                "sha256": "c7314bdd271102414b46eb49a6b497d941bf42a98c403a217d56e44385e0dfba"
            },
            "downloads": -1,
            "filename": "hello_message_sdk-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8ae154efe02f6320b364bae940e508d7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5323,
            "upload_time": "2024-12-22T01:45:25",
            "upload_time_iso_8601": "2024-12-22T01:45:25.059980Z",
            "url": "https://files.pythonhosted.org/packages/d3/0d/862974ccbe12c7e56cf8572782f98e417fb7491727fab2f75162af36545d/hello_message_sdk-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4bdbd808ecfe9109531c6aafce79caee5a9fb78c9c684cfca143833be5d1a240",
                "md5": "a99332370482d63ac33693ad055b1b0c",
                "sha256": "7ed4504ca152615f2fa9f4175733b58edaa98a5cb4b6d93a4eb8e62916ab1b7d"
            },
            "downloads": -1,
            "filename": "hello_message_sdk-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a99332370482d63ac33693ad055b1b0c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5213,
            "upload_time": "2024-12-22T01:45:27",
            "upload_time_iso_8601": "2024-12-22T01:45:27.978981Z",
            "url": "https://files.pythonhosted.org/packages/4b/db/d808ecfe9109531c6aafce79caee5a9fb78c9c684cfca143833be5d1a240/hello_message_sdk-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-22 01:45:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aimxlabs",
    "github_project": "hello-message-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "eth-account",
            "specs": [
                [
                    "==",
                    "0.13.4"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.3.4"
                ]
            ]
        }
    ],
    "lcname": "hello-message-sdk"
}
        
Elapsed time: 0.43059s