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

Method Derive

src/pubkey.cpp:228–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const {
229 assert(IsValid());
230 assert((nChild >> 31) == 0);
231 assert(begin() + 33 == end());
232 unsigned char out[64];
233 BIP32Hash(cc, nChild, *begin(), begin()+1, out);
234 memcpy(ccChild.begin(), out+32, 32);
235 secp256k1_pubkey pubkey;
236 if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) {
237 return false;
238 }
239 if (!secp256k1_ec_pubkey_tweak_add(secp256k1_context_verify, &pubkey, out)) {
240 return false;
241 }
242 unsigned char pub[33];
243 size_t publen = 33;
244 secp256k1_ec_pubkey_serialize(secp256k1_context_verify, pub, &publen, &pubkey, SECP256K1_EC_COMPRESSED);
245 pubkeyChild.Set(pub, pub + publen);
246 return true;
247}
248
249void CExtPubKey::Encode(unsigned char code[74]) const {
250 code[0] = nDepth;

Callers

nothing calls this directly

Calls 8

BIP32HashFunction · 0.85
memcpyFunction · 0.85
GetIDMethod · 0.80
beginMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected