From what I understand of it it's a mixture of the two. The calorie deficit means that you're only taking in the bare minimum amount of calories to ensure your body stays healthy you don't have any 'spare' calories left for energy so first of all your body will use it's easy energy stores like sugar and carbs. Ketosis is the process where your body starts to burn your fat stores for energy rather than sugar/ carb stores. You need to make sure you drink enough fluids to help with ketosis as the fat stores a lot more water than the sugar/ carbs therefore you can become more dehydrated and hamper weight loss.
If any of my sketchy science doesn't quite sound right please feel free to correct it. Wikipedia has quite a good explanation of it.