Bitcoin Forum
June 24, 2024, 05:54:51 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Reverse Algorithm for Elliptic Curve - Subtract and Halve  (Read 52 times)
ihsotas91 (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
March 30, 2024, 12:51:40 AM
 #1


import ecdsa
from ecdsa import SECP256k1
from ecdsa.ellipticcurve import Point
import bitcoin


def point_halving(point):
    """ Halving the provided point """
    return point * 57896044618658097711785492504343953926418782139537452191302581570759080747169


def point_subtract(point, other, curve):
    """Subtract one point from another on the given elliptic curve."""
    # Inverting the y-coordinate of 'other' point
    inverse_y = (-other.y() % curve.p())
    inverse_point = Point(curve, other.x(), inverse_y)

    # Adding point to the inverse of the other point
    return point + inverse_point


def get_first_point():
    pubkey = bitcoin .privkey_to_pubkey(1)
    return Point(SECP256k1.curve,
                 pubkey[0],
                 pubkey[1])


def get_infinity_point():
    return Point(SECP256k1.curve,
                 None,
                 None)

def slope_at_point(point, a):
    """Calculate the slope at a given point on the elliptic curve."""
    try:
        slope = (3 * point.x()**2 + a) / (2 * point.y())
    except ZeroDivisionError:
        raise ValueError("Slope is undefined for y=0.")
    return slope

def is_point_odd(P):
    slope = (slope_at_point(P, SECP256k1.curve.a()))
    if slope % 3 >= 1:
        return "odd"
    else:
        return "even"


def get_private_key_from_public_point(point):
    """ Extracts private key from a public key point, this method reverses Double and Add method by Subtract and Halve """

    G = ecdsa.SECP256k1.generator
    NEXT = point
    BINARY_ORDER = ""

    for i in range(0, 256):
        if NEXT == get_first_point():
            break

        PSUB = point_subtract(NEXT, G, SECP256k1.curve)
        SUBTRACT_AND_HALVE = point_halving(PSUB)
        JUST_HALVE = point_halving(NEXT)
        IPO = is_point_odd(NEXT)

        if IPO == "odd":
            BINARY_ORDER = BINARY_ORDER + "1"
            NEXT = SUBTRACT_AND_HALVE
        else:
            BINARY_ORDER = BINARY_ORDER + "0"
            NEXT = JUST_HALVE

    return int(BINARY_ORDER, 2)


G = ecdsa.SECP256k1.generator
PK = 880564733841876926926749214863536422911
   
pubkey = bitcoin .privkey_to_pubkey(
    PK)

Q = Point(SECP256k1.curve,
          pubkey[0],
          pubkey[1])

PKV = get_private_key_from_public_point(Q)

print(PKV)

assert PK == PKV


Find the real implementation of "is_point_odd" method, or check JUST_HALVE, when you halve the point, if JUST_HALVE is on the left side of the curve, this means NEXT is even. Find the way, and break the curve.

I'm done. I lost all my money, my job, my wife left me, and I lost all my years by being a slave to others for a living.
I'm planning to end my life.

My followers will continue work on this, but I want to make this code public.

This is the donation address, if one day anyone wants to support my scholars:

1XXXSTL5DrcyvBfF64riYvdchZjCF6Nt9

Alphazet
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
April 01, 2024, 02:13:01 PM
 #2

It would be much more better if you add more Info about the Algorithm so anyone can understand your point of view
I would suggest to edit OP and explain it how it works what it does etc

Good luck on your project
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!