Created
October 23, 2022 06:13
-
-
Save paulsc/0ba2ad96842abc1d99b1156633430dc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
get_context().precision = self.limit_precision(precision) | |
attempts += 1 | |
testPrefix = prefix + urandom(self.keysize_bytes - len(prefix)) | |
signatureCandidate = ( | |
toBytes( | |
self.nthroot( | |
self.public_exponent, | |
toInt(testPrefix), | |
self.limit_precision(precision), | |
), | |
self.keysize_bytes, | |
)[: -len(signatureSuffix)] | |
+ signatureSuffix | |
) | |
sc = toInt(signatureCandidate) | |
p = pow(sc, self.public_exponent) | |
pbl = p.bit_length() | |
if pbl > self.keysize_bits: | |
self.report_small(pbl) | |
return None | |
toCheck = toBytes(p, (pbl + 7) // 8) | |
if 0 not in toCheck[: -len(signatureSuffix)]: | |
if progress: | |
if not self.quiet: | |
print("") | |
if attempts > 1: | |
if not self.quiet: | |
print("Found in", attempts, "attempt(s)") | |
return signatureCandidate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment