Heat oil to moderate in a small wok or pan. Place garlic and onion flakes in a fine wire strainer and lower into the oil. Cook until golden. Drain on paper towels. Fry whole chiles until puffed and crisp, about 40 seconds. Remove. Drain on paper towels. Let cool. Discard chile seeds. Fry shrimp paste in oil remaining in pan, crushing with the back of a spoon. Add lime juice and soy sauce. Remove from heat.
Add peanut butter and sugar. Stir to blend well. Cool. Crumble garlic flakes, onion flakes, and chiles into small pieces and add to mixture. Combine well. Serve at room temperature.
Advance preparation: Prepare 1 week in advance. Store in a tightly covered glass container in refrigerator. If sauce is too thick, add coconut milk or water to the desired consistency.