MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / is_valid_public_key_static

Method is_valid_public_key_static

ciphers/diffie_hellman.py:244–249  ·  view source on GitHub ↗
(remote_public_key_str: int, prime: int)

Source from the content-addressed store, hash-verified

242
243 @staticmethod
244 def is_valid_public_key_static(remote_public_key_str: int, prime: int) -> bool:
245 # check if the other public key is valid based on NIST SP800-56
246 return (
247 2 <= remote_public_key_str <= prime - 2
248 and pow(remote_public_key_str, (prime - 1) // 2, prime) == 1
249 )
250
251 @staticmethod
252 def generate_shared_key_static(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected