diff --git a/model_signing/manifest/manifest.py b/model_signing/manifest/manifest.py index 9c53410c..be8d8672 100644 --- a/model_signing/manifest/manifest.py +++ b/model_signing/manifest/manifest.py @@ -41,6 +41,8 @@ from typing import Self from typing_extensions import override +from model_signing.hashing import hashing + class ManifestItem(metaclass=ABCMeta): """An item that can be included in the manifest. @@ -114,28 +116,21 @@ def from_str(as_str: str) -> Self: return ManifestFileChunkItem(file, start, end) -@dataclass(frozen=True) -class ManifestDigest: - """A computed digest (algorithm and hash) for a `ManifestItem`.""" - algorithm: str - digest: bytes - - class Manifest(metaclass=ABCMeta): """Generic manifest file to represent a model.""" - objects: dict[ManifestItem, ManifestDigest] = {} + objects: dict[ManifestItem, hashing.Digest] = {} constraints: list[set[ManifestItem]] = set() - def prepare_manifest_for_signing(self) -> Any: - """Computes the final form of the manifest for signing in memory. + #def prepare_manifest_for_signing(self) -> Any: + # """Computes the final form of the manifest for signing in memory. - Implementations decide the output type, as this can be from an - external dependency. + # Implementations decide the output type, as this can be from an + # external dependency. - This method is optional, but implementations must define at least one - of `prepare_manifest_for_signing` and `write_manifest`. - """ - pass + # This method is optional, but implementations must define at least one + # of `prepare_manifest_for_signing` and `write_manifest`. + # """ + # pass def write_manifest(self, path: pathlib.Path) -> None: """Writes the manifest to a file to be signed afterwards. @@ -171,7 +166,7 @@ def verify(self, only_for_objects: list[ManifestItem]) -> bool: @abstractmethod def update( self, - objects: dict[ManifestItem, ManifestDigest], + objects: dict[ManifestItem, hashing.Digest], constraints: list[set[ManifestItem]], ) -> None: """Updates the manifest with new integrity data."""