<<  >> (p.128)
    Author Topic: Pollard's kangaroo ECDLP solver  (Read 62812 times)
    wedom
    Jr. Member
    *
    Offline Offline

    Activity: 48
    Merit: 11


    View Profile
    July 29, 2022, 02:00:24 PM
    Last edit: July 29, 2022, 06:50:20 PM by wedom
     #2541

    from fastecdsa import curve
    from fastecdsa.point import Point
    import bit

    def pub2point(pub_hex):
        x = int(pub_hex[2:66], 16)
        if len(pub_hex) < 70:
            y = bit.format.x_to_y(x, int(pub_hex[:2], 16) % 2)
        else:
            y = int(pub_hex[66:], 16)
        return Point(x, y, curve=curve.secp256k1)

    G = curve.secp256k1.G
    N = curve.secp256k1.q
    DIV = '02AE3482B19E840288CC9B302AD9F5DC017AB796D3690CC8029017A8AF3503BE8E'
    pubkey = '03ec0f4d728d248698a59d3a50a0469da06fdb8019700dfc5de9eae2dd93fc2bc8'

    Q = pub2point(pubkey)
    R = pub2point(DIV)
    z= Q R

    print(z)


    -----------------------------------------
    >>>    z= Q R
    TypeError: unsupported operand type(s) for: 'Point' and 'Point'




    CAN ANYONE HELP,HOW TO CORRECT THIS

    THANKS


    You can't divide a point by a point. A point can only be multiplied by a number. In this case we are multiplying by an inverse number, thus imitating the division of a point by a number.

    Code:
    from fastecdsa import curve
    from fastecdsa.point import Point
    import bit

    G = curve.secp256k1.G
    N = curve.secp256k1.q

    def pub2point(pub_hex):
        x = int(pub_hex[2:66], 16)
        if len(pub_hex) < 70:
            y = bit.format.x_to_y(x, int(pub_hex[:2], 16) % 2)
        else:
            y = int(pub_hex[66:], 16)
        return Point(x, y, curve=curve.secp256k1)

    DIV = 123456789
    d = pow(DIV, N - 2, N)

    pubkey = '03ec0f4d728d248698a59d3a50a0469da06fdb8019700dfc5de9eae2dd93fc2bc8'
    Q = pub2point(pubkey)
    z = Q * d

    print(z)

Page 127
Viewing Page: 128