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

Method Derive

src/key.cpp:268–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const {
269 assert(IsValid());
270 assert(IsCompressed());
271 std::vector<unsigned char, secure_allocator<unsigned char>> vout(64);
272 if ((nChild >> 31) == 0) {
273 CPubKey pubkey = GetPubKey();
274 assert(pubkey.size() == CPubKey::COMPRESSED_PUBLIC_KEY_SIZE);
275 BIP32Hash(cc, nChild, *pubkey.begin(), pubkey.begin()+1, vout.data());
276 } else {
277 assert(size() == 32);
278 BIP32Hash(cc, nChild, 0, begin(), vout.data());
279 }
280 memcpy(ccChild.begin(), vout.data()+32, 32);
281 memcpy((unsigned char*)keyChild.begin(), begin(), 32);
282 bool ret = secp256k1_ec_privkey_tweak_add(secp256k1_context_sign, (unsigned char*)keyChild.begin(), vout.data());
283 keyChild.fCompressed = true;
284 keyChild.fValid = ret;
285 return ret;
286}
287
288bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const {
289 out.nDepth = nDepth + 1;

Callers 3

DeriveNewChildKeyMethod · 0.45
GetPubKeyMethod · 0.45
RunTestFunction · 0.45

Calls 9

GetPubKeyFunction · 0.85
BIP32HashFunction · 0.85
memcpyFunction · 0.85
GetIDMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45
GetPubKeyMethod · 0.45

Tested by 1

RunTestFunction · 0.36