MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Derive

Method Derive

src/pubkey.cpp:341–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc, uint256* bip32_tweak_out) const {
342 assert(IsValid());
343 assert((nChild >> 31) == 0);
344 assert(size() == COMPRESSED_SIZE);
345 unsigned char out[64];
346 BIP32Hash(cc, nChild, *begin(), begin()+1, out);
347 memcpy(ccChild.begin(), out+32, 32);
348 if (bip32_tweak_out) {
349 memcpy(bip32_tweak_out->begin(), out, 32);
350 }
351 secp256k1_pubkey pubkey;
352 if (!secp256k1_ec_pubkey_parse(secp256k1_context_static, &pubkey, vch, size())) {
353 return false;
354 }
355 if (!secp256k1_ec_pubkey_tweak_add(secp256k1_context_static, &pubkey, out)) {
356 return false;
357 }
358 unsigned char pub[COMPRESSED_SIZE];
359 size_t publen = COMPRESSED_SIZE;
360 secp256k1_ec_pubkey_serialize(secp256k1_context_static, pub, &publen, &pubkey, SECP256K1_EC_COMPRESSED);
361 pubkeyChild.Set(pub, pub + publen);
362 return true;
363}
364
365EllSwiftPubKey::EllSwiftPubKey(std::span<const std::byte> ellswift) noexcept
366{

Callers

nothing calls this directly

Calls 9

sizeFunction · 0.85
BIP32HashFunction · 0.85
beginFunction · 0.85
beginMethod · 0.45
SetMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected