In a sauce pan, toast the dry spices until fragrant (around 1 minute). Pour in the oil, then peel and half the shallots and garlic, slice the ginger and add them to the pan as well. Heat until rapid bubbles form around the spices and aromatics (at around 110 °C (230 °F)), then reduce the heat to low and simmer for 30 minutes.
Meanwhile, toast the chillis (if using) in a dry frying pan for 2-3 minutes until they just begin to darken. Transfer to a bowl and allow to cool slightly, then trim and deseed them and blend (or use a spice grinder) into a coarse powder that is slightly smaller than ordinary chilli flakes. Add the crushed chillis to a heat-proof bowl.
When the infusion is ready, place a sieve over the heat-proof bowl. Increase the heat until the oil reaches 180 °C (356 °F). If you don’t have a thermometer, heat it until the shallots begin to turn dark brown. Use a slotted spoon to swiftly remove the aromatics and most of the spices (do this ideally just before it reaches 180 °C (356 °F)), then strain half of the oil over the crushed chillis. Give it a mix, while you allow the rest of the oil to cool down to 160 °C (320 °F) (2-3 minutes). Now strain the rest of the oil over the chillis, mix well and stir in the salt. Leave to cool to room temperature (around 45 minutes) and use straightaway or close airtight and store in the fridge.
