I suggest using a more efficient way to generate the downscaled public keys by utilizing the add and double operations of elliptic curve cryptography. Here is a modified version of the shiftdown function:
def shiftdown(pubkey, divisor, file, convert=True):
Q = pub2point(pubkey) if convert else pubkey
# k = 1/divisor
k = pow(divisor, N - 2, N)
R = Point.identity(curve=curve.secp256k1)
for i in range(divisor):
R += Q # Equivalent to subtracting (divisor - i) * G
P = k * R
if (P.y % 2 == 0):
prefix = "02"
else:
prefix = "03"
hx = hex(P.x)[2:].zfill(64)
hy = hex(P.y)[2:].zfill(64)
file.write(prefix+ " " + hx+"\n") # Writes compressed key to file
file.write("\n") # Writes compressed key to file
This modified version adds the public key Q to a running variable R, which is initially the identity element. On each loop iteration, R is incremented by Q using the add operation, which is much faster than subtracting a multiple of G. Then, the public key P is computed by multiplying R by the inverse of the divisor modulo N, using the pow function. Finally, P is written to the output file in compressed form, as before. This algorithm has a time complexity of O(divisor), which is much faster than the original algorithm's O(divisor^2) time complexity.
That AI-generated version of my shiftdown is horseshit and will promptly be reported for spam.