[Python] How do I get permutations of numbers starting from a certain number in python?

Discussão em 'Python' iniciado por Stack, Maio 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm coding in python and I have a short sympy script that lets me calculate ethereum public key points. I just want to get one permutation of these public key points that I have already generated for some values of x in my sympy summation.

    My code is:

    from sympy import symbols, summation,Eq,Piecewise,Ne,And,Le

    # Define symbolic variable
    i = symbols('i')

    def scalar_multiply(scalar):
    first_result = scalar % (2**256) # convert to x value for ethereum public key
    first_result2 = scalar // (2**256) # convert to y value for ethereum public key
    p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F

    formula = (first_result2**2 - (first_result**3 + 7)) % p # check if is a valid ethereum point
    m1 = Piecewise(
    (scalar, Eq(formula, 0)),

    (0, True)
    )


    return m1

    logic = scalar_multiply(i)
    result = summation(logic, (i, 0, 2**256))

    print(f"Answer: {result}")

    terms = [logic.subs(i, k) for k in range(11348054180919221128807889581113035449130799211171091571728237166715858735154475809278561687252384436057703833250754868270831759143557443456051580904730595, 11348054180919221128807889581113035449130799211171091571728237166715858735154475809278561687252384436057703833250754868270831759143557443456051580904730597)]
    print(terms)


    In this script, I go all the way to 2**256 because the public key points are there. The script to get the public key points that I'm using is:

    from ecdsa import SECP256k1
    from ecdsa.ecdsa import Public_key, generator_secp256k1

    # Base point (G)
    G = generator_secp256k1

    # Scalar multiply: k * G
    k = 5 # You can use any integer here
    point = k * G

    # Get (x, y) as tuple
    x, y = point.x(), point.y()
    print(f"Point for k={k}: ({x}, {y})")
    print(x+(2**256)*y)


    In the logic variable, I placed the public key point for the 5th public key there. I want to get just one permutation for the public key points that I have currently in my summation script. This is for a client on Fiverr because I am a freelancer.

    Can someone show me what to do?

    Continue reading...

Compartilhe esta Página