If using roasted peanuts, process in a high-speed blender or food processor until a paste the texture of wet sand forms, 3 to 4 minutes. Transfer peanut paste to a small bowl and set aside.
Add shallots, garlic, red chiles, bird’s eye chiles, palm sugar, salt, and shrimp paste (if using) to the now empty food processor or blender and pulse, stopping to scrape down the sides of the bowl as needed with a flexible spatula, until the mixture resembles cooked oatmeal, 30 seconds to 1 minute. If paste is too thick and not turning in the food processor, add water, 1 teaspoon at a time, until it loosens to your desired consistency.
In a small saucepan, bring lime leaves, tamarind, and 1 cup (240 ml) water to a gentle boil over medium heat. Simmer, using a spoon or spatula to break up the tamarind pulp as much as possible and infuse the flavors, about 5 minutes. Remove the lime leaves and remaining tamarind solids.
Stir in ground peanuts and chile paste, and cook over medium heat. When the mixture starts bubbling, reduce heat to medium-low and simmer until thick and creamy, stirring often to prevent sauce from sticking to bottom of the pot, 4 to 6 minutes. If you prefer a looser sauce, add water 1 tablespoon at a time until you reach your desired consistency. Adjust seasoning to taste. Serve.
