xref: /aosp_15_r20/external/tink/python/tink/signature/_public_key_sign.py (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Interface for PublicKeySign."""
16
17import abc
18
19
20class PublicKeySign(metaclass=abc.ABCMeta):
21  """Interface for public key signing.
22
23  Digital Signatures provide functionality of signing data and verification of
24  the signatures. They are represented by a pair of primitives (interfaces)
25  'PublicKeySign' for signing of data, and 'PublicKeyVerify' for verification
26  of signatures. Implementations of these interfaces are secure against
27  adaptive chosen-message attacks. Signing data ensures the authenticity and
28  the integrity of that data, but not its secrecy.
29  """
30
31  @abc.abstractmethod
32  def sign(self, data: bytes) -> bytes:
33    """Computes the signature for data.
34
35    Args:
36      data: bytes, the input data.
37    Returns:
38      The signature as bytes.
39    """
40    raise NotImplementedError()
41