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

Method Derive

src/key.cpp:292–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const {
293 assert(IsValid());
294 assert(IsCompressed());
295 std::vector<unsigned char, secure_allocator<unsigned char>> vout(64);
296 if ((nChild >> 31) == 0) {
297 CPubKey pubkey = GetPubKey();
298 assert(pubkey.size() == CPubKey::COMPRESSED_SIZE);
299 BIP32Hash(cc, nChild, *pubkey.begin(), pubkey.begin()+1, vout.data());
300 } else {
301 assert(size() == 32);
302 BIP32Hash(cc, nChild, 0, UCharCast(begin()), vout.data());
303 }
304 memcpy(ccChild.begin(), vout.data()+32, 32);
305 keyChild.Set(begin(), begin() + 32, true);
306 bool ret = secp256k1_ec_seckey_tweak_add(secp256k1_context_static, (unsigned char*)keyChild.begin(), vout.data());
307 if (!ret) keyChild.ClearKeyData();
308 return ret;
309}
310
311EllSwiftPubKey CKey::EllSwiftCreate(std::span<const std::byte> ent32) const
312{

Callers 8

GetDerivedExtKeyMethod · 0.45
GetPubKeyMethod · 0.45
GetPrivKeyMethod · 0.45
SignMuSig2Function · 0.45
RunTestFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
DoCheckFunction · 0.45
key.cppFile · 0.45

Calls 13

GetPubKeyFunction · 0.85
BIP32HashFunction · 0.85
sizeFunction · 0.85
UCharCastFunction · 0.85
beginFunction · 0.85
ClearKeyDataMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45
SetMethod · 0.45
GetIDMethod · 0.45

Tested by 3

RunTestFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
DoCheckFunction · 0.36