For the dipping sauce: Pound the garlic, chopped turmeric (if using), and flaked sea salt to a rough paste in a mortar and pestle. Transfer to a small serving bowl; stir in the mirin, lime juice, and chile; and set aside.
In a medium bowl, stir together the buttermilk, vinegar, and grated turmeric and set aside.
Mix together the flour, nigella seeds, caraway seeds, lime zest, and table salt in a high-sided dish or wide container.
Set up two large racks on two baking sheets, lining one rack with plenty of paper towels.
Working in batches, coat the onion rings and green onions in the flour mixture, then in the buttermilk mixture. Lift them out, shaking off any excess, then coat once more in the flour and place, spaced apart, on the unlined rack.
Heat the sunflower oil in a large, high-sided sauté pan on medium-high heat. Once hot (355°F / 180°C if you have a thermometer), add the onion rings and green onions in three or four batches and fry for 2 to 3 minutes, turning them over halfway through, until crisp and golden. Use a slotted spoon to transfer to the lined rack. Sprinkle with plenty of flaked sea salt, then arrange on a platter and serve with the dipping sauce and the lime wedges alongside.