Author

Topic: (Same public key) * (Same public key) = Public key possible or not. (Read 175 times)

staff
Activity: 4284
Merit: 8808
In Elliptic Curve Cryptography you can't multiply two points. The only thing that is defined is multiplication of a point with a number which is defined as adding that point to itself number times. If you are converting that other point to a scalar (public_key_to_scalar) with a workaround, then you are already doing what I said not what you asked in your title.

It's less that it's not defined it's that there is no known efficient algorithm for it.  If you had an efficient algorithm for the DLP in the group you could give point point multiplication answers.  If you could compute the product of points directly you could solve the decisional DH problem, which is believed to be hard in groups like secp256k1.

sr. member
Activity: 420
Merit: 315
Top Crypto Casino
Converting from Pubkey to scalar is not really valid in the elliptic curve.
You can only multiply by a scalar or add the Pubkeys
For example
Code:
Pubkey A
A=(5,7)
Pubkey B
B=(3,4)
Say A is converted to scalar A=x1=5
It wouldn't be valid to multiply the converted pubkey with the point B, as it does not adhere to the curve mathematical property.

But you can either choose to add the Pubkeys or perform direct scalar multiplication to get another point in the curve, like kA where k is the scalar and shows the amount of time the Pubkey A would be added to itself.
C=A+B

legendary
Activity: 3472
Merit: 10611
In Elliptic Curve Cryptography you can't multiply two points. The only thing that is defined is multiplication of a point with a number which is defined as adding that point to itself number times. If you are converting that other point to a scalar (public_key_to_scalar) with a workaround, then you are already doing what I said not what you asked in your title.
jr. member
Activity: 40
Merit: 3
Research Bitcoin I have a question. Public key*(private key) = Public key has operation and device. (Same public key) * (Same public key) = Public key
I'd like to know if the second one is possible or not.

from ecdsa import SECP256k1, VerifyingKey
from ecdsa.ellipticcurve import Point

def public_key_to_scalar(public_key) -> int:
    """Converts a public key to an integer scalar."""
    return int.from_bytes(public_key.to_string(), 'big')

def multiply_public_key_by_scalar(pub_key, scalar) -> Point:
    """Multiplies a public key by a scalar."""
    return pub_key.pubkey.point * scalar

def point_to_hex(point) -> str:
    """Converts an elliptic curve point to a hexadecimal string in 0x format."""
    x_hex = "0x" + format(point.x(), '064x')
    y_hex = "0x" + format(point.y(), '064x')
    return x_hex, y_hex

# Input public key as a hexadecimal string (should be a valid uncompressed public key)
####Corresponds to the decimal value
input_hex1 = "b84a76136d0c86725a8a305f4a87aeeaa9f44eead621dd1e84d0ea1ad85d82ab" + \
             "9deccad50c1d1b9575d2fd2223215b5d74e29a87cd7879e343296eb688206713"

# Convert the hexadecimal string to a VerifyingKey object
pub_key1 = VerifyingKey.from_string(bytes.fromhex(input_hex1), curve=SECP256k1)

# Define a valid scalar (could be a private key or a large random integer)
# Corresponds to a private key value of 0.1
scalar = 0x2  # Example scalar value

# Multiply the public key by the scalar
result_point = multiply_public_key_by_scalar(pub_key1, scalar)

# Convert the result to a hexadecimal string in 0x format
x_hex, y_hex = point_to_hex(result_point)
print(f"Result of multiplication in hex (x): {x_hex}")
print(f"Result of multiplication in hex (y): {y_hex}")
Jump to: