I am inquiring about the feasibility of calculating the point difference between two distinct secp256k1 elliptic curve points. Given the nature of secp256k1, which is widely used in cryptographic applications such as blockchain technology, I am interested in understanding the process and potential challenges involved in determining the point difference between these specific curve points.
Could you please provide a detailed explanation of the mathematical and computational methods that can be employed for such a calculation, along with any relevant considerations or limitations?
For example:
Pub_key_A= 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9
(private key is 2)
pub_key_B= 2c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
(private key is 3)
The deference between 2 points is 1; I need the difference in number of points between point A and B.
Code that I tried:
import ecdsa
# Convert hexadecimal public keys to bytes
public_key1_hex = "02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"
public_key2_hex = "02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"
public_key1_bytes = bytes.fromhex(public_key1_hex)
public_key2_bytes = bytes.fromhex(public_key2_hex)
# Create ecdsa.VerifyingKey objects for the first and second public keys
vk1 = ecdsa.VerifyingKey.from_string(public_key1_bytes, curve=ecdsa.SECP256k1)
vk2 = ecdsa.VerifyingKey.from_string(public_key2_bytes, curve=ecdsa.SECP256k1)
# Get the generator point of the elliptic curve
generator_point = ecdsa.SECP256k1.generator
# Calculate the inverse of vk2's public key point
vk2_inverse_point = generator_point - vk2.pubkey.point
# Calculate the difference between the public key points
difference_point = vk1.pubkey.point + vk2_inverse_point
# Convert the difference point to hexadecimal
difference_hex = "04" + difference_point.x().to_bytes(32, byteorder="big").hex() + difference_point.y().to_bytes(32, byteorder="big").hex()
print("Difference between public key points:", difference_hex)