MCPcopy Create free account
hub / github.com/LUX-Core/lux / Derive

Method Derive

src/key.cpp:256–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const {
257 assert(IsValid());
258 assert(IsCompressed());
259 std::vector<unsigned char, secure_allocator<unsigned char>> vout(64);
260 if ((nChild >> 31) == 0) {
261 CPubKey pubkey = GetPubKey();
262 assert(pubkey.size() == CPubKey::COMPRESSED_PUBLIC_KEY_SIZE);
263 BIP32Hash(cc, nChild, *pubkey.begin(), pubkey.begin()+1, vout.data());
264 } else {
265 assert(size() == 32);
266 BIP32Hash(cc, nChild, 0, begin(), vout.data());
267 }
268 memcpy(ccChild.begin(), vout.data()+32, 32);
269 memcpy((unsigned char*)keyChild.begin(), begin(), 32);
270 bool ret = secp256k1_ec_privkey_tweak_add(secp256k1_context_sign, (unsigned char*)keyChild.begin(), vout.data());
271 keyChild.fCompressed = true;
272 keyChild.fValid = ret;
273 return ret;
274}
275
276bool CExtKey::Derive(CExtKey& out, unsigned int nChild) const {
277 out.nDepth = nDepth + 1;

Callers 1

DeriveChildExtKeyMethod · 0.45

Calls 10

BIP32HashFunction · 0.85
sizeFunction · 0.85
beginFunction · 0.85
memcpyFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45
GetIDMethod · 0.45
GetPubKeyMethod · 0.45

Tested by

no test coverage detected