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

Method Derive

src/pubkey.cpp:253–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const
254{
255 assert(IsValid());
256 assert((nChild >> 31) == 0);
257 assert(size() == COMPRESSED_PUBLIC_KEY_SIZE);
258 unsigned char out[64];
259 BIP32Hash(cc, nChild, *begin(), begin() + 1, out);
260 memcpy(ccChild.begin(), out + 32, 32);
261 secp256k1_pubkey pubkey;
262 if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) {
263 return false;
264 }
265 if (!secp256k1_ec_pubkey_tweak_add(secp256k1_context_verify, &pubkey, out)) {
266 return false;
267 }
268 unsigned char pub[COMPRESSED_PUBLIC_KEY_SIZE];
269 size_t publen = COMPRESSED_PUBLIC_KEY_SIZE;
270 secp256k1_ec_pubkey_serialize(secp256k1_context_verify, pub, &publen, &pubkey, SECP256K1_EC_COMPRESSED);
271 pubkeyChild.Set(pub, pub + publen);
272return true;
273}
274
275void CExtPubKey::Encode(unsigned char code[74]) const
276{

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected