hyugit / EllipticCurve

An elliptic curve library written in Swift 4
MIT License
22 stars 5 forks source link

Secp256k1 generate a radom private key? #5

Closed OHeroJ closed 6 years ago

OHeroJ commented 6 years ago

hello, Can Secp256k1 generate a radom private key? And it can obtain the corresponding public key. like this:

def generate_ECDSA_keys():
    sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)  #this is your sign (private key)
    private_key = sk.to_string().hex()  #convert your private key to hex
    vk = sk.get_verifying_key()  #this is your verification key (public key)
hyugit commented 6 years ago

this library is only for curves and finite fields. but if you want to generate a random private key, you can use the arc4random_uniform in UInt256 library

hyugit commented 6 years ago

again, this library is VERY SLOW, its not for production use. please refer to libsecp256k1 for production purposes.

OHeroJ commented 6 years ago

get it , very slow, 3Q very much