Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Sablotny <msablotny@nvidia.com>
  • Loading branch information
susperius committed Jul 24, 2024
1 parent 24ef543 commit edc7a77
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions model_signing/signature/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

PAYLOAD_TYPE = "application/vnd.in-toto+json"

# The proto contains a Statement message.
# pylint: disable=no-member


def pae(statement: statement_pb.Statement) -> bytes:
"""Generates the PAE encoding of the statement.
Expand Down
1 change: 0 additions & 1 deletion model_signing/signature/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""This package provides the functionality to generate and verify
bundles without invoking signing."""

from cryptography.hazmat.primitives import serialization
from google.protobuf import json_format
from in_toto_attestation.v1 import statement
from sigstore_protobuf_specs.dev.sigstore.bundle import v1 as bundle_pb
Expand Down
5 changes: 3 additions & 2 deletions model_signing/signature/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ def from_path(cls, key_path: str):

def verify(self, bundle: bundle_pb.Bundle) -> None:
statement = json_format.Parse(
bundle.dsse_envelope.payload, statement_pb.Statement())
bundle.dsse_envelope.payload,
statement_pb.Statement()) # pylint: disable=no-member
pae = encoding.pae(statement)
try:
self._public_key.verify(
bundle.dsse_envelope.signatures[0].sig,
pae, ec.ECDSA(SHA256()))
except Exception as e:
raise VerificationError(
'signature verification failed ' + str(e))
'signature verification failed ' + str(e)) from e
4 changes: 2 additions & 2 deletions model_signing/signature/sigstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from sigstore import dsse
from sigstore import oidc
from sigstore import sign
from sigstore import models as sig_models
from sigstore.verify import verifier as sig_verifier
from sigstore.verify import policy as sig_policy
from sigstore.verify import models as sig_models
from sigstore_protobuf_specs.dev.sigstore.bundle import v1 as bundle_pb

from model_signing.signature.signing import Signer
Expand Down Expand Up @@ -102,4 +102,4 @@ def verify(self, bundle: bundle_pb.Bundle) -> None:
sig_bundle = sig_models.Bundle(bundle)
_ = self._verifier.verify_dsse(sig_bundle, self._policy)
except Exception as e:
raise VerificationError(str(e))
raise VerificationError(str(e)) from e

0 comments on commit edc7a77

Please sign in to comment.