Skip to content

Commit

Permalink
verification
Browse files Browse the repository at this point in the history
  • Loading branch information
susperius committed Aug 5, 2024
1 parent 827b813 commit 3743871
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion model_signing/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def verify(sig: signing.Signature,
serializer: serialization.Serializer,
ignore_paths: list[pathlib.Path] = []):
peer_manifest = verifier.verify(sig)
local_manifest = serializer.serialize(model_path, ignore_paths)
local_manifest = serializer.serialize(
model_path, ignore_paths=ignore_paths)
if peer_manifest != local_manifest:
raise verifying.VerificationError('the manifest do not match')
File renamed without changes.
12 changes: 7 additions & 5 deletions model_signing/verify.py → verify_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from model_signing.signature import pki
from model_signing.signature import sigstore
from model_signing.signature import fake
from model_signing.signing import in_toto

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -131,22 +132,23 @@ def main():

log.info(f'Verifying model signature from {args.sig_path}')

bundle = bundle_pb.Bundle().from_json(
value=args.sig_path.read_text())
sig = in_toto.IntotoSignature.read(args.sig_path)

def hasher_factory(file_path: pathlib.Path) -> file.FileHasher:
return file.SimpleFileHasher(
file=file_path,
content_hasher=memory.SHA256(),
)

serializer = serialize_by_file.FilesSerializer(
serializer = serialize_by_file.ManifestSerializer(
file_hasher_factory=hasher_factory)

intoto_verifier = in_toto.IntotoVerifier(verifier)

try:
model.verify(
bundle=bundle,
verifier=verifier,
sig=sig,
verifier=intoto_verifier,
model_path=args.model_path,
serializer=serializer,
ignore_paths=[args.sig_path])
Expand Down

0 comments on commit 3743871

Please sign in to comment.