Skip to content

Commit

Permalink
Annotations for nacl.bindings.crypto_kx (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
DMRobertson committed Dec 1, 2021
1 parent 46489f5 commit 4539ada
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module = [
"nacl.bindings.crypto_core",
"nacl.bindings.crypto_hash",
"nacl.bindings.crypto_generichash",
"nacl.bindings.crypto_kx",
"nacl.encoding",
"nacl.exceptions",
"nacl.utils",
Expand Down
26 changes: 15 additions & 11 deletions src/nacl/bindings/crypto_kx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Tuple

from nacl import exceptions as exc
from nacl._sodium import ffi, lib
Expand All @@ -30,13 +30,13 @@
"""
Implementations of client, server key exchange
"""
crypto_kx_PUBLIC_KEY_BYTES = lib.crypto_kx_publickeybytes()
crypto_kx_SECRET_KEY_BYTES = lib.crypto_kx_secretkeybytes()
crypto_kx_SEED_BYTES = lib.crypto_kx_seedbytes()
crypto_kx_SESSION_KEY_BYTES = lib.crypto_kx_sessionkeybytes()
crypto_kx_PUBLIC_KEY_BYTES: int = lib.crypto_kx_publickeybytes()
crypto_kx_SECRET_KEY_BYTES: int = lib.crypto_kx_secretkeybytes()
crypto_kx_SEED_BYTES: int = lib.crypto_kx_seedbytes()
crypto_kx_SESSION_KEY_BYTES: int = lib.crypto_kx_sessionkeybytes()


def crypto_kx_keypair():
def crypto_kx_keypair() -> Tuple[bytes, bytes]:
"""
Generate a keypair.
This is a duplicate crypto_box_keypair, but
Expand All @@ -55,7 +55,7 @@ def crypto_kx_keypair():
)


def crypto_kx_seed_keypair(seed):
def crypto_kx_seed_keypair(seed: bytes) -> Tuple[bytes, bytes]:
"""
Generate a keypair with a given seed.
This is functionally the same as crypto_box_seed_keypair, however
Expand Down Expand Up @@ -85,8 +85,10 @@ def crypto_kx_seed_keypair(seed):


def crypto_kx_client_session_keys(
client_public_key, client_secret_key, server_public_key
):
client_public_key: bytes,
client_secret_key: bytes,
server_public_key: bytes,
) -> Tuple[bytes, bytes]:
"""
Generate session keys for the client.
:param client_public_key:
Expand Down Expand Up @@ -141,8 +143,10 @@ def crypto_kx_client_session_keys(


def crypto_kx_server_session_keys(
server_public_key, server_secret_key, client_public_key
):
server_public_key: bytes,
server_secret_key: bytes,
client_public_key: bytes,
) -> Tuple[bytes, bytes]:
"""
Generate session keys for the server.
:param server_public_key:
Expand Down

0 comments on commit 4539ada

Please sign in to comment.