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