from sympy import mod_inverse
import secp256k1 as ice
pub=ice.pub2upub('Here Compressed Public Key')
N=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
k=mod_inverse(2,N)
neg1=ice.point_negation(ice.scalar_multiplication(1))
def ters(Qx,Scalar):
ScalarBin = str(bin(Scalar))[2:]
le=len(ScalarBin)
for i in range (1,le+1):
if ScalarBin[le-i] == "0":
Qx=ice.point_multiplication(k,Qx)
else:
Qx=ice.point_addition(Qx,neg1)
Qx=ice.point_multiplication(k,Qx)
return ice.point_to_cpub(Qx)
for x in range(1,65536):
f= (ters(pub,x))
data= open(“halfpub.txt”,”a”)
data.write(f+”\n”)
data.close()
Note this is where you decide how many bits should be reduced
for x in range(1,65536):
For example reducing 26 bits requires 67108864 to be generated, 1 of them is the correct 26 bit reduced key.
Will you release for public to use?
Yes this is my code, I can write bit reduction code in another way if you want. If you want, you can reduce bits by subtraction.
I'm developing a new algorithm for downgrading from a known bit range to the bit range I want. When I complete it by giving only 1 correct pubkey, I will share it here.
@lordfrs, I was thinking, why do we need to keep all the 65556 keys if we are reducing 16 bits? One other thing, if we multiply one of the keys from the end of the output file by 65556 we should see our target, correct? I haven't thought about on how to calculate, since we are subtracting one dividing by 2, one result if multiplied by 2^16 should reach the target or close to target, so why not discarding 90% of the generated keys and start multiplying the remaining 10% by 2^16? Could you add such operation to your script?
I guess if we could operate on private keys instead of public keys using your script, we could reach some results, ( as a test of course )
To test with scalar only, I use this script :
from sympy import mod_inverse
N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
def ters(scalar):
k = mod_inverse(2, N)
scalar_bin = bin(scalar)[2:]
result = 2
for i in range(len(scalar_bin)):
if scalar_bin[i] == '0':
result = (result * k) % N
else:
result = ((result * k) % N + N - 1) % N
return hex(result)[2:].zfill(64)
for x in range(1, 20):
f = ters(x)
print(f)
It was a lucky shot at AI generated code and it worked.😅
Btw, the first "result" in the script above, represents your target, I couldn't risk the AI to mess one thing she has done right. So result = 2, replace 2 with your own scalar in decimal.