Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

from ecdsa import SigningKey, SECP256k1 import matplotlib.pyplot as plt Liste des clés…

  1. User

    from ecdsa import SigningKey, SECP256k1 import matplotlib.pyplot as plt

    Liste des clés privées en hexadécimal

    private_keys_hex = [ '0000000000000000000000000000000000000000000000000000000000000001', '0000000000000000000000000000000000000000000000000000000000000003', '0000000000000000000000000000000000000000000000000000000000000007', '0000000000000000000000000000000000000000000000000000000000000008', '0000000000000000000000000000000000000000000000000000000000000015', '0000000000000000000000000000000000000000000000000000000000000031', '000000000000000000000000000000000000000000000000000000000000004c', '00000000000000000000000000000000000000000000000000000000000000e0', '00000000000000000000000000000000000000000000000000000000000001d3', '0000000000000000000000000000000000000000000000000000000000000202', '00000000000000000000000000000000000000000000000000000000000000483', '00000000000000000000000000000000000000000000000000000000000000a7b', '00000000000000000000000000000000000000000000000000000000000001460', '00000000000000000000000000000000000000000000000000000000000002930', '000000000000000000000000000000000000000000000000000000000000068f3', '0000000000000000000000000000000000000000000000000000000000000c936', '00000000000000000000000000000000000000000000000000000000000068f3', '000000000000000000000000000000000000000000000000000000000000c936', '000000000000000000000000000000000000000000000000000000000001764f', '000000000000000000000000000000000000000000000000000000000003080d', '000000000000000000000000000000000000000000000000000000000005749f', '00000000000000000000000000000000000000000000000000000000000d2c55', '00000000000000000000000000000000000000000000000000000000001ba534', '00000000000000000000000000000000000000000000000000000000002de40f', '0000000000000000000000000000000000000000000000000000000000556e52', '0000000000000000000000000000000000000000000000000000000000dc2a04', '0000000000000000000000000000000000000000000000000000000001fa5ee5', '000000000000000000000000000000000000000000000000000000000340326e', '0000000000000000000000000000000000000000000000000000000006ac3875', "000000000000000000000000000000000000000000000000000000000d916ce8", "0000000000000000000000000000000000000000000000000000000017e2551e", "000000000000000000000000000000000000000000000000000000003d94cd64", "000000000000000000000000000000000000000000000000000000007d4fe747", "00000000000000000000000000000000000000000000000000000000b862a62e", "0000000000000000000000000000000000000000000000000000001a96ca8d8", "00000000000000000000000000000000000000000000000000000034a65911d", "00000000000000000000000000000000000000000000000000000004aed21170", "00000000000000000000000000000000000000000000000000000009de820a7c", "0000000000000000000000000000000000000000000000000000001757756a93", "00000000000000000000000000000000000000000000000000000022382facd0", "0000000000000000000000000000000000000000000000000000004b5f8303e9", "000000000000000000000000000000000000000000000000000000e9ae4933d6", "00000000000000000000000000000000000000000000000000000153869acc5b", "000000000000000000000000000000000000000000000000000002a221c58d8f", "000000000000000000000000000000000000000000000000000006bd3b27c591", "00000000000000000000000000000000000000000000000000000e02b35a358f", "0000000000000000000000000000000000000000000000000000122fca143c05", "00000000000000000000000000000000000000000000000000002ec18388d544", "00000000000000000000000000000000000000000000000000006cd610b53cba", "0000000000000000000000000000000000000000000000000000ade6d7ce3b9b", "000000000000000000000000000000000000000000000000000174176b015f4d", "00000000000000000000000000000000000000000000000000022bd43c2e9354", "00000000000000000000000000000000000000000000000000075070a1a009d4", "000000000000000000000000000000000000000000000000000efae164cb9e3c", ]

    Fonction pour convertir les clés privées en points sur la courbe elliptique

    def keys_to_points(private_keys): points = [] for key_hex in private_keys: sk = SigningKey.from_string(bytes.fromhex(key_hex), curve=SECP256k1) vk = sk.verifying_key point = vk.pubkey.point points.append((point.x(), point.y())) return points

    Conversion des clés en points

    points = keys_to_points(private_keys_hex)

    Tracé des points

    plt.figure(figsize=(10, 6)) for point in points: plt.scatter(point[0], point[1], color='blue')

    plt.title('Points sur la courbe elliptique secp256k1') plt.xlabel('x') plt.ylabel('y') plt.show() corrige le code

  2. Assistant

    Votre code est pratiquement correct pour tracer les points des clés privées sur la courbe elliptique secp256k1. Cependant, il serait utile d'ajouter une correction pour traiter des hexadécimaux avec des lettres minuscules et majuscules, gérer les petites valeurs qui pourraient être tracées, et garantir que la génération des points est conforme avec des configurations de tracés adéquates.

    Voici la version corrigée du code :

    from ecdsa import SigningKey, SECP256k1
    import matplotlib.pyplot as plt
    
    # List of private keys in hexadecimal form 
    private_keys_hex = [
        '0000000000000000000000000000000000000000000000000000000000000001',
        '0000000000000000000000000000000000000000000000000000000000000003',
        '0000000000000000000000000000000000000000000000000000000000000007',
        '0000000000000000000000000000000000000000000000000000000000000008',
        '0000000000000000000000000000000000000000000000000000000000000015',
        '0000000000000000000000000000000000000000000000000000000000000031',
        '000000000000000000000000000000000000000000000000000000000000004c',
        '00000000000000000000000000000000000000000000000000000000000000e0',
        '00000000000000000000000000000000000000000000000000000000000001d3',
        '0000000000000000000000000000000000000000000000000000000000000202',
        '0000000000000000000000000000000000000000000000000000000000000483',
        '0000000000000000000000000000000000000000000000000000000000000a7b',
        '0000000000000000000000000000000000000000000000000000000000001460',
        '0000000000000000000000000000000000000000000000000000000000002930',
        '00000000000000000000000000000000000000000000000000000000000068f3',
        '000000000000000000000000000000000000000000000000000000000000c936',
        '0000000000000000000000000000000000000000000000000000000000068f3',
        '00000000000000000000000000000000000000000000000000000000000c936',
        '000000000000000000000000000000000000000000000000000000000001764f',
        '000000000000000000000000000000000000000000000000000000000003080d',
        '000000000000000000000000000000000000000000000000000000000005749f',
        '00000000000000000000000000000000000000000000000000000000000d2c55',
        '00000000000000000000000000000000000000000000000000000000001ba534',
        '00000000000000000000000000000000000000000000000000000000002de40f',
        '0000000000000000000000000000000000000000000000000000000000556e52',
        '0000000000000000000000000000000000000000000000000000000000dc2a04',
        '0000000000000000000000000000000000000000000000000000000001fa5ee5',
        '000000000000000000000000000000000000000000000000000000000340326e',
        '0000000000000000000000000000000000000000000000000000000006ac3875',
        '000000000000000000000000000000000000000000000000000000000d916ce8',
        '0000000000000000000000000000000000000000000000000000000017e2551e',
        '000000000000000000000000000000000000000000000000000000003d94cd64',
        '000000000000000000000000000000000000000000000000000000007d4fe747',
        '00000000000000000000000000000000000000000000000000000000b862a62e',
        '0000000000000000000000000000000000000000000000000000001a96ca8d8',
        '000000000000000000000000000000000000000000000000000000034a65911d',
        '00000000000000000000000000000000000000000000000000000004aed21170',
        '00000000000000000000000000000000000000000000000000000009de820a7c',
        '0000000000000000000000000000000000000000000000000000001757756a93',
        '00000000000000000000000000000000000000000000000000000022382facd0',
        '0000000000000000000000000000000000000000000000000000004b5f8303e9',
        '000000000000000000000000000000000000000000000000000000e9ae4933d6',
        '00000000000000000000000000000000000000000000000000000153869acc5b',
        '000000000000000000000000000000000000000000000000000002a221c58d8f',
        '000000000000000000000000000000000000000000000000000006bd3b27c591',
        '00000000000000000000000000000000000000000000000000000e02b35a358f',
        '0000000000000000000000000000000000000000000000000000122fca143c05',
        '00000000000000000000000000000000000000000000000000002ec18388d544',
        '00000000000000000000000000000000000000000000000000006cd610b53cba',
        '0000000000000000000000000000000000000000000000000000ade6d7ce3b9b',
        '000000000000000000000000000000000000000000000000000174176b015f4d',
        '00000000000000000000000000000000000000000000000000022bd43c2e9354',
        '00000000000000000000000000000000000000000000000000075070a1a009d4',
        '000000000000000000000000000000000000000000000000000efae164cb9e3c',
    ]
    
    # Function to convert private keys to points on the elliptic curve
    def keys_to_points(private_keys):
        points = []
        for key_hex in private_keys:
            sk = SigningKey.from_string(bytes.fromhex(key_hex), curve=SECP256k1)
            vk = sk.verifying_key
            point = vk.pubkey.point
            points.append((point.x(), point.y()))
        return points
    
    # Convert keys to points
    points = keys_to_points(private_keys_hex)
    
    # Plot the points
    plt.figure(figsize=(12, 7))
    for point in points:
        plt.scatter(point[0], point[1], color='blue')
    
    plt.title('Points on the secp256k1 Elliptic Curve')
    plt.xlabel('x-coordinate')
    plt.ylabel('y-coordinate')
    plt.grid(True)
    plt.show()
    

    Les modifications incluent :

    1. Correction d’erreurs grammaticales et typographiques dans les commentaires.
    2. Correction des erreurs d'indentation et de formatage d'entrée.
    3. Utilisation de plt.grid(True) pour afficher une grille pour mieux visualiser les points.

    N'hésitez pas à tester ce code ! Si vous avez des questions supplémentaires ou avez besoin de plus d’aide, faites-le moi savoir !