<p>Remember, as Pieter Wuille said, all exposed functions (only those that you'd need to use) are in <a href="https://github.com/bitcoin-core/secp256k1/blob/7b50483/include/secp256k1.h" rel="nofollow noreferrer"><code>include/secp256k1.h</code></a></p>

<p>You can use <a href="https://github.com/bitcoin-core/secp256k1/blob/7b50483/include/secp256k1.h#L566" rel="nofollow noreferrer"><code>secp256k1_ec_pubkey_create</code></a> like this:</p>



<pre><code>secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
secp256k1_pubkey pubkey;

// Here our private key is 1, little endian
const unsigned char seckey[32] = {1};

if (!secp256k1_ec_pubkey_create(sign, &amp;pubkey, seckey)) {
    // Private key out of range
    // abort!
    secp256k1_context_destroy(sign);
    exit(1);
}

// Use 65 and SECP256K1_EC_UNCOMPRESSED for uncompressed public key
unsigned char outpubkey[33];
size_t written_bytes = 33;
secp256k1_ec_pubkey_serialize(sign, outpubkey, &amp;written_bytes, &amp;pubkey, SECP256K1_EC_COMPRESSED);

printf("Public key: ");

for (int i = 0; i &lt; 33; i++) {
    printf("%.2x", (unsigned int) outpubkey[i]);
}

printf("\n");

secp256k1_context_destroy(sign);
</code></pre>

<p>Whose output can be verified with <a href="https://gobittest.appspot.com/Address" rel="nofollow noreferrer">ThePiachu's tool</a> and the private key <code>0100000000000000000000000000000000000000000000000000000000000000</code></p>

CC BY-SA 4.0
2020-04-19T09:10:58.557Z
2020-04-19T09:10:58.557Z
MCCCS
<p>I'm trying to work out a minimal example with the bitcoin core secp256k1 library but am a bit lost due to the many options available. Concretely, I simply want to use libsecp256k1 to multiply the generator point G as defined by the standard with an integer k, ie <code>H = k*G</code>.</p>

<p>So far, I found <code>secp256k1_scalar_mul</code>, which multiplies two scalars and <code>secp256k1_fe_mul</code> which multiplies two field elements, while close neither is what I'm looking for. So I was wondering if someone could point me to a suitable function in libsecp256k1? </p>

<p>Thanks!</p>

CC BY-SA 4.0
2020-04-18T16:02:26.730Z
https://github.com/bitcoin-core/secp256k1/blob/7b50483/include/secp256k1.h#L566 ?
MCCCS
CC BY-SA 4.0
2020-04-18T19:51:27.070Z
@MCCCS Exactly, you should turn that into an answer. The functions listed by OP are internal operations that aren't exposed outside the library.
Pieter Wuille
<bitcoin-core><ecdsa><secp256k1><c>
Basic point multiplication with G in libsecp256k1
fdffd
# Basic point multiplication with G in libsecp256k1

(Asked by: username_0 on 2020-04-18)

I'm trying to work out a minimal example with the bitcoin core secp256k1 library but am a bit lost due to the many options available. Concretely, I simply want to use libsecp256k1 to multiply the generator point G as defined by the standard with an integer k, ie `H = k*G`.

So far, I found `secp256k1_scalar_mul`, which multiplies two scalars and `secp256k1_fe_mul` which multiplies two field elements, while close neither is what I'm looking for. So I was wondering if someone could point me to a suitable function in libsecp256k1?

Thanks!

**Tags:** bitcoin-core, ecdsa, secp256k1, c

> **Comments:**
> **username_1**: https://github.com/bitcoin-core/secp256k1/blob/7b50483/include/secp256k1.h#L566 ?  
> **username_2**: @username_1 Exactly, you should turn that into an answer. The functions listed by OP are internal operations that aren't exposed outside the library.  

---

## 1 answers

### Answer by username_1 on 2020-04-19. Score: 2 | Accepted answer

Remember, as username_2 said, all exposed functions (only those that you'd need to use) are in include/secp256k1.h
You can use secp256k1_ec_pubkey_create like this:
secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
secp256k1_pubkey pubkey;

// Here our private key is 1, little endian
const unsigned char seckey[32] = {1};

if (!secp256k1_ec_pubkey_create(sign, &pubkey, seckey)) {
    // Private key out of range
    // abort!
    secp256k1_context_destroy(sign);
    exit(1);
}

// Use 65 and SECP256K1_EC_UNCOMPRESSED for uncompressed public key
unsigned char outpubkey[33];
size_t written_bytes = 33;
secp256k1_ec_pubkey_serialize(sign, outpubkey, &written_bytes, &pubkey, SECP256K1_EC_COMPRESSED);

printf("Public key: ");

for (int i = 0; i < 33; i++) {
    printf("%.2x", (unsigned int) outpubkey[i]);
}

printf("\n");

secp256k1_context_destroy(sign);

Whose output can be verified with ThePiachu's tool and the private key 0100000000000000000000000000000000000000000000000000000000000000


---

