Not sure what doing it that way would do, except cause confusion lol.
You know about point torsion? It subtracts 1 from target then divides either by 2 or anything you want, but we want similar code to subtract whatever we want, keeps all the subtracted keys, does the division and repeat the same with the results, in this *way when we work with scalar instead of points, we can observe and learn by tweaking our values step by step. That's how you learn, by studying the small details.
I just used my double point torsion script and it seems it doesn't work the way I wanted, that's why I tried to save the results of that script to separate files and use another script to subtract the results in the files.
One other thing, I thought if we multiply by n/4 -2 , 3, 4 or by n/4 + 2, 3, 4 we could get for example target.75 or 1/75, or 1/25 of our target, I haven't tried it yet on scalar, but I know for sure that if you multiply by n/2 +2 you would get 1/5 or one and half of your target 1.5, then imagine dividing that by 2, you'd get 0.75 of target, then multiply that by 3 to get 2.25 of target, 2.25/2 = 1.125, then you could continue that and see what happens in scalar. You could find patterns that way.
I might cause some confusion sometimes, it's for the best, as hyenas are lurking around the corner.😉
Edit, I'm not sure if I have shared the 2 point torsion subtraction script before, it's useless. Ignore it.😅
*= 5 w in a row. Lol
Second edit : (hey Joe mentality mode activated, lol)
Anyone has any idea how to make this thing find lambda and beta quick? With small values it says there is no result very fast and for large values of P and N, it takes forever without any results. This is beyond my pay grade to handle properly, and AI, well this is the product of asking AI for help. 😂
import random
from math import isqrt
def find_lambda_beta(n: int, p: int) -> tuple[int, int]:
# Check if n and p are valid inputs
if not (is_prime(n) and is_prime(p)):
raise ValueError("n and p must be prime numbers")
if n <= 2 or p <= 2:
raise ValueError("n and p must be greater than 2")
# Find prime factors of n and p
factors_n = prime_factors(n)
factors_p = prime_factors(p)
# Choose two different prime factors q, m of n and p, respectively
found = False
while not found:
q = random.choice(factors_n)
m = random.choice(factors_p)
if q != m:
found = True
# Find a primitive root of 1 modulo q
a = find_primitive_root(q)
# Compute the cube root of 1 modulo q
k = pow(a, (q-1)//3, q)
# Find a primitive root of 1 modulo m
b = find_primitive_root(m)
# Compute lambda as the cube root of 1 modulo m
lam = pow(b, (m-1)//3, m)
# Check which cube root of 1 modulo q matches lambda
match_found = False
for c in [2, 3]:
if pow(lam, c, q) == k:
beta = pow(k, ((q-1)//3 * (m-1)//2) % (p-1), p)
match_found = True
break
if match_found:
return lam, beta
else:
raise ValueError("No solutions found")
def is_prime(n: int) -> bool:
if n <= 3:
return n > 1
elif n % 2 == 0 or n % 3 == 0:
return False
else:
i = 5
while i*i <= n:
if n % i == 0 or n % (i+2) == 0:
return False
i += 6
return True
def prime_factors(n: int) -> list[int]:
factors = []
while n % 2 == 0:
factors.append(2)
n //= 2
for i in range(3, isqrt(n) + 1, 2):
while n % i == 0:
factors.append(i)
n //= i
if n > 2:
factors.append(n)
return factors
def find_primitive_root(p: int) -> int:
if not is_prime(p):
raise ValueError("p must be a prime number")
phi = p-1
factors = prime_factors(phi)
for r in range(2, p):
is_primitive = True
for factor in factors:
if pow(r, phi//factor, p) == 1:
is_primitive = False
break
if is_primitive:
return r
raise ValueError("Cannot find primitive root")
# Example usage:
n = 0xd82254710ec6131d
p = 0xa4dd92ac1ff9dd0f
lam, beta = find_lambda_beta(n, p)
print("Lambda:", lam)
print("Beta:", beta)