Soak tamarind in water for 10 minutes. Strain. Discard hard bits. Set aside.
Coconut paste:
Heat oil in a frying pan over low heat. Add grated coconut, coriander seeds, cumin seeds, dried red chilies and black peppercorns. Fry, stirring constantly, for 4-5 minutes or until coconut is browned. Remove from heat. Leave to cool slightly. Transfer mixture to a grinder. Add a little water, and process to a smooth paste.
Curry:
Heat oil in a frying pan over medium heat. Add mustard seeds, curry leaves and red chili. Splutter mustard seeds. Add shallots. Fry, stirring occasionally, for 3-4 minutes or fry until golden brown.
Add asafetida and ground fenugreek. Season with salt. Stir to combine. Add tamarind extract. Cover with water. Bring to boil. Simmer 2-3 minutes. Stir in coconut paste and sugar (if using). Simmer for another 5-6 minutes.