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

Method is_valid_public_key

ciphers/diffie_hellman.py:229–234  ·  view source on GitHub ↗
(self, key: int)

Source from the content-addressed store, hash-verified

227 return hex(public_key)[2:]
228
229 def is_valid_public_key(self, key: int) -> bool:
230 # check if the other public key is valid based on NIST SP800-56
231 return (
232 2 <= key <= self.prime - 2
233 and pow(key, (self.prime - 1) // 2, self.prime) == 1
234 )
235
236 def generate_shared_key(self, other_key_str: str) -> str:
237 other_key = int(other_key_str, base=16)

Callers 1

generate_shared_keyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected