code: func (key *Key) NewChildKey(childIdx uint32) (*Key, error) {
  	// Fail early if trying to create hardned child from public key
  	if !key.IsPrivate && childIdx >= FirstHardenedChild {
  		return nil, ErrHardnedChildPublicKey
  	}
  
  	intermediary, err := key.getIntermediary(childIdx)
  	if err != nil {
  		return nil, err
  	}
  
  	// Create child Key with data common to all both scenarios
  	childKey := &Key{
  		ChildNumber: uint32Bytes(childIdx),
  		ChainCode:   intermediary[32:],
  		Depth:       key.Depth + 1,
  		IsPrivate:   key.IsPrivate,
  	}
  
  	// Bip32 CKDpriv
  	if key.IsPrivate {
  		childKey.Version = PrivateWalletVersion
  		fingerprint, err := hash160(publicKeyForPrivateKey(key.Key))
  		if err != nil {
  			return nil, err
  		}
  		childKey.FingerPrint = fingerprint[:4]
  		childKey.Key = addPrivateKeys(intermediary[:32], key.Key)
  
  		// Validate key
  		err = validatePrivateKey(childKey.Key)
  		if err != nil {
  			return nil, err
  		}
  		// Bip32 CKDpub
  	} else {
  		keyBytes := publicKeyForPrivateKey(intermediary[:32])
  
  		// Validate key
  		err := validateChildPublicKey(keyBytes)
  		if err != nil {
  			return nil, err
  		}
  
  		childKey.Version = PublicWalletVersion
  		fingerprint, err := hash160(key.Key)
  		if err != nil {
  			return nil, err
  		}
  		childKey.FingerPrint = fingerprint[:4]
  		childKey.Key = addPublicKeys(keyBytes, key.Key)
  	}
  
  	return childKey, nil
  }
docs: // NewChildKey derives a child key from a given parent as outlined by bip32