I keep asking myself how that works but always get very confused too. If there were an alleged calculator you could prescribe and a little bit of some explanation as to how the addition and subtraction works it'd be very understandable. I even tried to write a code to add and multiply below is the code. still all I got was an awkward result.
"import argparse
import ecdsa
from ecdsa.ellipticcurve import Point
# Function ato perform point addition
def point_addition(point1, point2):
return point1 + point2
# Function to perform point subtraction
def point_subtraction(point1, point2):
return point1 - point2
# Function to perform point multiplication
def point_multiplication(point, scalar):
return scalar * point
# Function to perform point division (using scalar multiplication by the inverse)
def point_division(point, scalar):
return point_multiplication(point, ecdsa.numbertheory.inverse_mod(scalar, curve.order()))
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Elliptic Curve Point Operations")
parser.add_argument("-p1", dest="public_key1", type=str, help="Public key 1 (in hexadecimal)")
parser.add_argument("-p2", dest="public_key2", type=str, help="Public key 2 (in hexadecimal)")
parser.add_argument("operation", choices=["+", "-", "*", "/"], help="Operation to perform (+ for add, - for subtract, * for multiply, / for divide)")
args = parser.parse_args()
# Define the elliptic curve parameters (SECP256k1 in Bitcoin)
curve = ecdsa.SECP256k1
# Parse the public keys from the command-line arguments
public_key1 = ecdsa.VerifyingKey.from_string(bytes.fromhex(args.public_key1), curve=curve).pubkey.point
public_key2 = ecdsa.VerifyingKey.from_string(bytes.fromhex(args.public_key2), curve=curve).pubkey.point
# Perform the specified operation on the public keys
if args.operation == "+":
result_point = point_addition(public_key1, public_key2)
elif args.operation == "-":
result_point = point_subtraction(public_key1, public_key2)
elif args.operation == "*":
scalar = int(input("Enter the scalar value (private key): "), 16)
result_point = point_multiplication(public_key1, scalar)
elif args.operation == "/":
scalar = int(input("Enter the scalar value (private key): "), 16)
result_point = point_division(public_key1, scalar)
# Print the coordinates of the result point
result_x, result_y = ecdsa.util.number_to_string(result_point.x(), curve.order), ecdsa.util.number_to_string(result_point.y(), curve.order)
print("Result Point (x, y):", result_x.hex(), ",", result_y.hex())" result was awkward but anyway,
how do we go about the addition and subtraction, division and multiplication and how do we make sense off of the result from this process??
what tools are required?
Calculators and procedures involved. I'm down to learn too