Skip to main content

ECDSA-based signer for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_signing_ecdsa


Swarmauri Signing ECDSA

An asynchronous ECDSA-based signer that implements the ISigning interface for detached signatures over raw bytes and canonicalized envelopes.

Features

  • JSON canonicalization built in, with optional CBOR canonicalization via cbor2
  • Supports the ECDSA-P256-SHA256, ECDSA-P384-SHA384, and ECDSA-P521-SHA512 curves provided by cryptography
  • Multi-signature aware verification with opt-in algorithm restrictions through the require mapping
  • Detached signature generation for both raw byte payloads and Swarmauri envelopes

Installation

pip

pip install swarmauri_signing_ecdsa
# Optional CBOR support
pip install "swarmauri_signing_ecdsa[cbor]"

Poetry

poetry add swarmauri_signing_ecdsa
# Optional CBOR support
poetry add "swarmauri_signing_ecdsa[cbor]"

uv

# Install uv if it is not already available on your system
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install the signer package
uv pip install swarmauri_signing_ecdsa
# Optional CBOR support
uv pip install "swarmauri_signing_ecdsa[cbor]"

Usage

The signer operates asynchronously and expects private keys to be supplied via the KeyRef mappings defined in swarmauri_core. When verifying, provide the corresponding public keys through the opts={"pubkeys": [...]} option.

import asyncio
from cryptography.hazmat.primitives.asymmetric import ec

from swarmauri_signing_ecdsa import EcdsaEnvelopeSigner


async def main() -> None:
    signer = EcdsaEnvelopeSigner()

    # Provide the private key as a KeyRef understood by swarmauri_core
    private_key = ec.generate_private_key(ec.SECP256R1())
    key_ref = {"kind": "cryptography_obj", "obj": private_key}

    envelope = {
        "headers": {"kid": "example"},
        "payload": {"message": "signed hello"},
    }

    signatures = await signer.sign_envelope(
        key_ref,
        envelope,
        canon="json",
    )

    is_valid = await signer.verify_envelope(
        envelope,
        signatures,
        canon="json",
        opts={"pubkeys": [private_key.public_key()]},
    )

    print(f"Signature valid? {is_valid}")


if __name__ == "__main__":
    asyncio.run(main())

Entry Point

The signer registers under the swarmauri.signings entry point as EcdsaEnvelopeSigner.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_signing_ecdsa-0.3.0.dev42.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_signing_ecdsa-0.3.0.dev42-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_signing_ecdsa-0.3.0.dev42.tar.gz.

File metadata

  • Download URL: swarmauri_signing_ecdsa-0.3.0.dev42.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_signing_ecdsa-0.3.0.dev42.tar.gz
Algorithm Hash digest
SHA256 fd2e10015f818ce34620fd12f61107521f70ac1a6d5614aa8acb192175b75ae8
MD5 cc78b8370ecc977a3c5f4fe5fd9be6e5
BLAKE2b-256 10aeb3070f6f3f86ba1f61628c11d17c8ba7b2bc8ded1c6761bba29b9f0501ee

See more details on using hashes here.

File details

Details for the file swarmauri_signing_ecdsa-0.3.0.dev42-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_signing_ecdsa-0.3.0.dev42-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_signing_ecdsa-0.3.0.dev42-py3-none-any.whl
Algorithm Hash digest
SHA256 b95055013ca23bb9d511d2684c0d4054d0778c553628b6d95dac76f4b0322f70
MD5 87b3f22b61f32ac3e0dbef5ecd490069
BLAKE2b-256 b09a8d5b4377221d7e92163dea73ccef41e37dc169a612a2dfb37ea455017a57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page