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

Method Derive

src/pubkey.cpp:227–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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