1

I am just writing a small test program by using secp256k1 C lib, targeting to generate various random ecdsa key pairs, by using secp256k1-zkp API, simply follow up some example in tests.c.

However, a little bit surprised, I find that I can not get the varied key-pair, every time I run the test program I get the exact same private key (thereafter the same public key).

This does not make sense but I can not figure out where is the problem, someone can kindly give help and suggestion?

Below are the sample code I am using:

random_scalar_order_test(&rand);
secp256k1_scalar_get_b32(privkey, &rand);
CHECK(secp256k1_ec_seckey_verify(ctx, privkey) == 1);
CHECK(secp256k1_ec_pubkey_create(ctx, pubkey, &pubkeylen, 
                                 privkey, (secp256k1_rand32() & 3) != 0) == 1);

It looks after compiling, every time I run the test, the first two lines of code always provide the exact same privkey, so the public key will be also fixed. Is there any rand seed API can be used to generate the different private key every time called?

4

1 回答 1

0

即使对于相同的私钥,曲线公钥也总是不同的。这是正常行为。

于 2021-12-28T19:06:11.587 回答