| 226 | } |
| 227 | |
| 228 | bool 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 | |
| 249 | void CExtPubKey::Encode(unsigned char code[74]) const { |
| 250 | code[0] = nDepth; |
nothing calls this directly
no test coverage detected