Skip to content

Class swarmauri_core.keys.IKeyProvider.IKeyProvider

swarmauri_core.keys.IKeyProvider.IKeyProvider

Bases: ABC

Stable, minimal surface for key lifecycle and randomness/KDF utilities.

Implementations MUST populate the fingerprint attribute on returned :class:~swarmauri_core.crypto.types.KeyRef instances. The fingerprint is a provider-defined stable identifier derived from the key's material or public representation.

supports abstractmethod

supports()

Return capability map for this provider.

Source code in swarmauri_core/keys/IKeyProvider.py
20
21
22
@abstractmethod
def supports(self) -> Mapping[str, Iterable[str]]:
    """Return capability map for this provider."""

create_key abstractmethod async

create_key(spec)

Generate a new key and return a :class:KeyRef.

Source code in swarmauri_core/keys/IKeyProvider.py
24
25
26
@abstractmethod
async def create_key(self, spec: KeySpec) -> KeyRef:
    """Generate a new key and return a :class:`KeyRef`."""

import_key abstractmethod async

import_key(spec, material, *, public=None)

Import an existing key and return its :class:KeyRef.

Source code in swarmauri_core/keys/IKeyProvider.py
28
29
30
31
32
33
34
35
36
@abstractmethod
async def import_key(
    self,
    spec: KeySpec,
    material: bytes,
    *,
    public: Optional[bytes] = None,
) -> KeyRef:
    """Import an existing key and return its :class:`KeyRef`."""

rotate_key abstractmethod async

rotate_key(kid, *, spec_overrides=None)

Create a new version for an existing key.

Source code in swarmauri_core/keys/IKeyProvider.py
38
39
40
41
42
@abstractmethod
async def rotate_key(
    self, kid: str, *, spec_overrides: Optional[dict] = None
) -> KeyRef:
    """Create a new version for an existing key."""

destroy_key abstractmethod async

destroy_key(kid, version=None)

Destroy a key or specific version.

Source code in swarmauri_core/keys/IKeyProvider.py
44
45
46
@abstractmethod
async def destroy_key(self, kid: str, version: Optional[int] = None) -> bool:
    """Destroy a key or specific version."""

get_key abstractmethod async

get_key(kid, version=None, *, include_secret=False)

Fetch a :class:KeyRef for the given key id/version.

Source code in swarmauri_core/keys/IKeyProvider.py
48
49
50
51
52
53
54
55
56
@abstractmethod
async def get_key(
    self,
    kid: str,
    version: Optional[int] = None,
    *,
    include_secret: bool = False,
) -> KeyRef:
    """Fetch a :class:`KeyRef` for the given key id/version."""

get_key_by_ref async

get_key_by_ref(key_ref, *, include_secret=False)

Resolve an opaque key reference into a :class:KeyRef instance.

Source code in swarmauri_core/keys/IKeyProvider.py
58
59
60
61
62
63
64
65
66
67
68
async def get_key_by_ref(
    self,
    key_ref: str,
    *,
    include_secret: bool = False,
) -> KeyRef:
    """Resolve an opaque key reference into a :class:`KeyRef` instance."""

    raise NotImplementedError(
        "get_key_by_ref() is not implemented for this provider"
    )

list_versions abstractmethod async

list_versions(kid)

Return available versions for a key.

Source code in swarmauri_core/keys/IKeyProvider.py
70
71
72
@abstractmethod
async def list_versions(self, kid: str) -> Tuple[int, ...]:
    """Return available versions for a key."""

get_public_jwk abstractmethod async

get_public_jwk(kid, version=None)

Return an RFC 7517 JWK for the public portion of the key.

Source code in swarmauri_core/keys/IKeyProvider.py
74
75
76
@abstractmethod
async def get_public_jwk(self, kid: str, version: Optional[int] = None) -> dict:
    """Return an RFC 7517 JWK for the public portion of the key."""

jwks abstractmethod async

jwks(*, prefix_kids=None)

Return a JWKS document containing the latest versions of keys.

Source code in swarmauri_core/keys/IKeyProvider.py
78
79
80
@abstractmethod
async def jwks(self, *, prefix_kids: Optional[str] = None) -> dict:
    """Return a JWKS document containing the latest versions of keys."""

random_bytes abstractmethod async

random_bytes(n)

Return n cryptographically secure random bytes.

Source code in swarmauri_core/keys/IKeyProvider.py
82
83
84
@abstractmethod
async def random_bytes(self, n: int) -> bytes:
    """Return ``n`` cryptographically secure random bytes."""

hkdf abstractmethod async

hkdf(ikm, *, salt, info, length)

Derive key material using HKDF-SHA256.

Source code in swarmauri_core/keys/IKeyProvider.py
86
87
88
@abstractmethod
async def hkdf(self, ikm: bytes, *, salt: bytes, info: bytes, length: int) -> bytes:
    """Derive key material using HKDF-SHA256."""