swarmauri_crypto_composite 0.2.0.dev4__tar.gz → 0.2.0.dev10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_crypto_composite
3
+ Version: 0.2.0.dev10
4
+ Summary: Algorithm-routing crypto provider for Swarmauri
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,sdk,standards,crypto,composite,cryptography
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.13
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Development Status :: 3 - Alpha
18
+ Classifier: Topic :: Security :: Cryptography
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3 :: Only
23
+ Requires-Dist: swarmauri_base
24
+ Requires-Dist: swarmauri_core
25
+ Description-Content-Type: text/markdown
26
+
27
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
28
+
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
31
+ <img src="https://img.shields.io/pypi/dm/swarmauri_crypto_composite" alt="PyPI - Downloads"/></a>
32
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite/">
33
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite.svg"/></a>
34
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
35
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_crypto_composite" alt="PyPI - Python Version"/></a>
36
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
37
+ <img src="https://img.shields.io/pypi/l/swarmauri_crypto_composite" alt="PyPI - License"/></a>
38
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
39
+ <img src="https://img.shields.io/pypi/v/swarmauri_crypto_composite?label=swarmauri_crypto_composite&color=green" alt="PyPI - swarmauri_crypto_composite"/></a>
40
+ </p>
41
+
42
+ ---
43
+
44
+ ## Swarmauri Crypto Composite
45
+
46
+ `CompositeCrypto` is an algorithm-routing crypto provider that delegates encryption
47
+ operations to the first child provider that advertises support for the requested
48
+ algorithm. Its behaviour is defined entirely by the wrapped providers:
49
+
50
+ - Aggregates each provider's `supports()` capabilities and removes duplicates.
51
+ - Normalises requested algorithms before routing so stylistic variants still match.
52
+ - Requires at least one child provider to be supplied at construction time.
53
+ - Exposes the full asynchronous `ICrypto` surface area (encrypt, wrap, seal, etc.).
54
+
55
+ ## Installation
56
+
57
+ Choose the tool that best fits your workflow:
58
+
59
+ ```bash
60
+ pip install swarmauri_crypto_composite
61
+ ```
62
+
63
+ ```bash
64
+ poetry add swarmauri_crypto_composite
65
+ ```
66
+
67
+ ```bash
68
+ uv add swarmauri_crypto_composite
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ```python
74
+ """Route crypto operations to the provider that supports the requested algorithm."""
75
+ import asyncio
76
+
77
+ from swarmauri_crypto_composite import CompositeCrypto
78
+ from swarmauri_core.crypto.ICrypto import ICrypto
79
+ from swarmauri_core.crypto.types import (
80
+ AEADCiphertext,
81
+ ExportPolicy,
82
+ KeyRef,
83
+ KeyType,
84
+ KeyUse,
85
+ )
86
+
87
+
88
+ class DummyCrypto(ICrypto):
89
+ def __init__(self, name: str, alg: str) -> None:
90
+ self._name = name
91
+ self._alg = alg
92
+
93
+ def supports(self):
94
+ return {"encrypt": (self._alg,)}
95
+
96
+ async def encrypt(self, key, pt, *, alg=None, aad=None, nonce=None):
97
+ return AEADCiphertext(
98
+ kid="dummy",
99
+ version=1,
100
+ alg=alg or self._alg,
101
+ nonce=b"",
102
+ ct=self._name.encode(),
103
+ tag=b"",
104
+ )
105
+
106
+ async def decrypt(self, key, ct, *, aad=None): # pragma: no cover - demo only
107
+ raise NotImplementedError
108
+
109
+ async def wrap(self, kek, *, dek=None, wrap_alg=None, nonce=None): # pragma: no cover - demo only
110
+ raise NotImplementedError
111
+
112
+ async def unwrap(self, kek, wrapped): # pragma: no cover - demo only
113
+ raise NotImplementedError
114
+
115
+ async def seal(self, recipient, pt, *, alg=None): # pragma: no cover - demo only
116
+ raise NotImplementedError
117
+
118
+ async def unseal(self, recipient_priv, sealed, *, alg=None): # pragma: no cover - demo only
119
+ raise NotImplementedError
120
+
121
+
122
+ async def main() -> None:
123
+ # Compose two providers that advertise different algorithms.
124
+ chacha = DummyCrypto("chacha", "CHACHA20-POLY1305")
125
+ aes = DummyCrypto("aes", "A256GCM")
126
+ composite = CompositeCrypto([chacha, aes])
127
+
128
+ key = KeyRef(
129
+ kid="k",
130
+ version=1,
131
+ type=KeyType.SYMMETRIC,
132
+ uses=(KeyUse.ENCRYPT, KeyUse.DECRYPT),
133
+ export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
134
+ material=b"\x00" * 32,
135
+ )
136
+
137
+ ciphertext = await composite.encrypt(key, b"payload", alg="A256GCM")
138
+ print(f"Selected provider: {ciphertext.ct.decode()}")
139
+
140
+
141
+ if __name__ == "__main__":
142
+ asyncio.run(main())
143
+ ```
144
+
145
+ ## Entry point
146
+
147
+ The provider is registered under the `swarmauri.cryptos` entry-point as `CompositeCrypto`.
148
+
149
+ ## Want to help?
150
+
151
+ If you want to contribute to swarmauri-sdk, read up on our
152
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
153
+ that will help you get started.
@@ -0,0 +1,127 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_crypto_composite" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite.svg"/></a>
8
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
9
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_crypto_composite" alt="PyPI - Python Version"/></a>
10
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
11
+ <img src="https://img.shields.io/pypi/l/swarmauri_crypto_composite" alt="PyPI - License"/></a>
12
+ <a href="https://pypi.org/project/swarmauri_crypto_composite/">
13
+ <img src="https://img.shields.io/pypi/v/swarmauri_crypto_composite?label=swarmauri_crypto_composite&color=green" alt="PyPI - swarmauri_crypto_composite"/></a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ ## Swarmauri Crypto Composite
19
+
20
+ `CompositeCrypto` is an algorithm-routing crypto provider that delegates encryption
21
+ operations to the first child provider that advertises support for the requested
22
+ algorithm. Its behaviour is defined entirely by the wrapped providers:
23
+
24
+ - Aggregates each provider's `supports()` capabilities and removes duplicates.
25
+ - Normalises requested algorithms before routing so stylistic variants still match.
26
+ - Requires at least one child provider to be supplied at construction time.
27
+ - Exposes the full asynchronous `ICrypto` surface area (encrypt, wrap, seal, etc.).
28
+
29
+ ## Installation
30
+
31
+ Choose the tool that best fits your workflow:
32
+
33
+ ```bash
34
+ pip install swarmauri_crypto_composite
35
+ ```
36
+
37
+ ```bash
38
+ poetry add swarmauri_crypto_composite
39
+ ```
40
+
41
+ ```bash
42
+ uv add swarmauri_crypto_composite
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ```python
48
+ """Route crypto operations to the provider that supports the requested algorithm."""
49
+ import asyncio
50
+
51
+ from swarmauri_crypto_composite import CompositeCrypto
52
+ from swarmauri_core.crypto.ICrypto import ICrypto
53
+ from swarmauri_core.crypto.types import (
54
+ AEADCiphertext,
55
+ ExportPolicy,
56
+ KeyRef,
57
+ KeyType,
58
+ KeyUse,
59
+ )
60
+
61
+
62
+ class DummyCrypto(ICrypto):
63
+ def __init__(self, name: str, alg: str) -> None:
64
+ self._name = name
65
+ self._alg = alg
66
+
67
+ def supports(self):
68
+ return {"encrypt": (self._alg,)}
69
+
70
+ async def encrypt(self, key, pt, *, alg=None, aad=None, nonce=None):
71
+ return AEADCiphertext(
72
+ kid="dummy",
73
+ version=1,
74
+ alg=alg or self._alg,
75
+ nonce=b"",
76
+ ct=self._name.encode(),
77
+ tag=b"",
78
+ )
79
+
80
+ async def decrypt(self, key, ct, *, aad=None): # pragma: no cover - demo only
81
+ raise NotImplementedError
82
+
83
+ async def wrap(self, kek, *, dek=None, wrap_alg=None, nonce=None): # pragma: no cover - demo only
84
+ raise NotImplementedError
85
+
86
+ async def unwrap(self, kek, wrapped): # pragma: no cover - demo only
87
+ raise NotImplementedError
88
+
89
+ async def seal(self, recipient, pt, *, alg=None): # pragma: no cover - demo only
90
+ raise NotImplementedError
91
+
92
+ async def unseal(self, recipient_priv, sealed, *, alg=None): # pragma: no cover - demo only
93
+ raise NotImplementedError
94
+
95
+
96
+ async def main() -> None:
97
+ # Compose two providers that advertise different algorithms.
98
+ chacha = DummyCrypto("chacha", "CHACHA20-POLY1305")
99
+ aes = DummyCrypto("aes", "A256GCM")
100
+ composite = CompositeCrypto([chacha, aes])
101
+
102
+ key = KeyRef(
103
+ kid="k",
104
+ version=1,
105
+ type=KeyType.SYMMETRIC,
106
+ uses=(KeyUse.ENCRYPT, KeyUse.DECRYPT),
107
+ export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
108
+ material=b"\x00" * 32,
109
+ )
110
+
111
+ ciphertext = await composite.encrypt(key, b"payload", alg="A256GCM")
112
+ print(f"Selected provider: {ciphertext.ct.decode()}")
113
+
114
+
115
+ if __name__ == "__main__":
116
+ asyncio.run(main())
117
+ ```
118
+
119
+ ## Entry point
120
+
121
+ The provider is registered under the `swarmauri.cryptos` entry-point as `CompositeCrypto`.
122
+
123
+ ## Want to help?
124
+
125
+ If you want to contribute to swarmauri-sdk, read up on our
126
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
127
+ that will help you get started.
@@ -1,11 +1,11 @@
1
1
  [project]
2
2
  name = "swarmauri_crypto_composite"
3
- version = "0.2.0.dev4"
3
+ version = "0.2.0.dev10"
4
4
  description = "Algorithm-routing crypto provider for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
7
7
  requires-python = ">=3.10,<3.13"
8
- authors = [{ name = "Swarmauri", email = "opensource@swarmauri.com" }]
8
+ authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
9
9
  classifiers = [
10
10
  "License :: OSI Approved :: Apache Software License",
11
11
  "Natural Language :: English",
@@ -16,11 +16,22 @@ classifiers = [
16
16
  "Development Status :: 3 - Alpha",
17
17
  "Topic :: Security :: Cryptography",
18
18
  "Intended Audience :: Developers",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
19
22
  ]
20
23
  dependencies = [
21
24
  "swarmauri_core",
22
25
  "swarmauri_base",
23
26
  ]
27
+ keywords = [
28
+ 'swarmauri',
29
+ 'sdk',
30
+ 'standards',
31
+ 'crypto',
32
+ 'composite',
33
+ 'cryptography',
34
+ ]
24
35
 
25
36
  [tool.uv.sources]
26
37
  swarmauri_core = { workspace = true }
@@ -35,6 +46,7 @@ markers = [
35
46
  "r8n: Regression tests",
36
47
  "acceptance: Acceptance tests",
37
48
  "perf: Performance tests",
49
+ "example: README-backed usage examples",
38
50
  ]
39
51
  timeout = 300
40
52
  log_cli = true
@@ -1,60 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_crypto_composite
3
- Version: 0.2.0.dev4
4
- Summary: Algorithm-routing crypto provider for Swarmauri
5
- License: Apache-2.0
6
- Author: Swarmauri
7
- Author-email: opensource@swarmauri.com
8
- Requires-Python: >=3.10,<3.13
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Natural Language :: English
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Development Status :: 3 - Alpha
16
- Classifier: Topic :: Security :: Cryptography
17
- Classifier: Intended Audience :: Developers
18
- Requires-Dist: swarmauri_base
19
- Requires-Dist: swarmauri_core
20
- Description-Content-Type: text/markdown
21
-
22
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
23
-
24
- <p align="center">
25
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
26
- <img src="https://img.shields.io/pypi/dm/swarmauri_crypto_composite" alt="PyPI - Downloads"/></a>
27
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite/">
28
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite.svg"/></a>
29
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
30
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_crypto_composite" alt="PyPI - Python Version"/></a>
31
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
32
- <img src="https://img.shields.io/pypi/l/swarmauri_crypto_composite" alt="PyPI - License"/></a>
33
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
34
- <img src="https://img.shields.io/pypi/v/swarmauri_crypto_composite?label=swarmauri_crypto_composite&color=green" alt="PyPI - swarmauri_crypto_composite"/></a>
35
- </p>
36
-
37
- ---
38
-
39
- ## Swarmauri Crypto Composite
40
-
41
- Algorithm-routing crypto provider delegating to child providers based on requested algorithms.
42
-
43
- ## Installation
44
-
45
- ```bash
46
- pip install swarmauri_crypto_composite
47
- ```
48
-
49
- ## Usage
50
-
51
- ```python
52
- from swarmauri_crypto_composite import CompositeCrypto
53
-
54
- crypto = CompositeCrypto([...]) # pass in other ICrypto providers
55
- ```
56
-
57
- ## Entry point
58
-
59
- The provider is registered under the `swarmauri.cryptos` entry-point as `CompositeCrypto`.
60
-
@@ -1,38 +0,0 @@
1
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
2
-
3
- <p align="center">
4
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
5
- <img src="https://img.shields.io/pypi/dm/swarmauri_crypto_composite" alt="PyPI - Downloads"/></a>
6
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite/">
7
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_crypto_composite.svg"/></a>
8
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
9
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_crypto_composite" alt="PyPI - Python Version"/></a>
10
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
11
- <img src="https://img.shields.io/pypi/l/swarmauri_crypto_composite" alt="PyPI - License"/></a>
12
- <a href="https://pypi.org/project/swarmauri_crypto_composite/">
13
- <img src="https://img.shields.io/pypi/v/swarmauri_crypto_composite?label=swarmauri_crypto_composite&color=green" alt="PyPI - swarmauri_crypto_composite"/></a>
14
- </p>
15
-
16
- ---
17
-
18
- ## Swarmauri Crypto Composite
19
-
20
- Algorithm-routing crypto provider delegating to child providers based on requested algorithms.
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install swarmauri_crypto_composite
26
- ```
27
-
28
- ## Usage
29
-
30
- ```python
31
- from swarmauri_crypto_composite import CompositeCrypto
32
-
33
- crypto = CompositeCrypto([...]) # pass in other ICrypto providers
34
- ```
35
-
36
- ## Entry point
37
-
38
- The provider is registered under the `swarmauri.cryptos` entry-point as `CompositeCrypto`.