Post
Topic
Board Development & Technical Discussion
Merits 2 from 1 user
Re: position of two secp256k1 public keys
by
digaran
on 24/10/2023, 22:23:35 UTC
⭐ Merited by vapourminer (2)
Here, repeat this script with the same points several times and compare each time result.

Code:
import time
import gmpy2

# Define function to convert SEC-encoded public key to coordinates
def sec_to_public_pair(sec):
    if sec[0] != 2 and sec[0] != 3:
        raise ValueError("Invalid SEC format")
    x = gmpy2.mpz(int.from_bytes(sec[1:], 'big'))
    y_squared = x**3 + 7
    y = gmpy2.mpz(gmpy2.sqrt(y_squared))
    if sec[0] == 3 and y % 2 == 0 or sec[0] == 2 and y % 2 == 1:
        y = -y
    return (x, y)

# Public keys in hexadecimal format
hex_pubkey1 = "02b23790a42be63e1b251ad6c94fdef07271ec0aada31db6c3e8bd32043f8be384"
hex_pubkey2 = "034a4a6dc97ac7c8b8ad795dbebcb9dcff7290b68a5ef74e56ab5edde01bced775"

# Convert public keys to coordinates
point1 = sec_to_public_pair(bytes.fromhex(hex_pubkey1))
point2 = sec_to_public_pair(bytes.fromhex(hex_pubkey2))

# Measure execution time
start_time = time.time()

# Compare the x-coordinates of the points
if point1[0] == point2[0]:
    print("The public keys are the same.")
else:
    print("The public keys are different.")

end_time = time.time()
execution_time = end_time - start_time
print(f"Execution time: {execution_time} seconds")

Calculating public keys take around the same amount of time, uncompressed public keys take double the time of compressed keys.
As I told you before, the distance between 50 and 100 would take e.g, 25 seconds if your key rate is 2 keys/s.
10keys/s = estimated time 5 seconds.
50keys/s = around 1 second etc.

Public key generation difficulty is not based on the distance between 2 points, because 1 point addition will always take the same time doesn't matter if you are adding 2+1 or 5000+2^250, it's not like a point representing a 256 bit key weighs more computationally and a point representing 1 bit key weighs less, no they all are the same computationally.