Roast the chilies, garlic and shallots in a hot wok until slightly browned.
Grind the chilies and salt together until you get a fine powder. Add the garlic, shallots, tamarind and shrimp paste. Mash and grind until you get a small stiff ball of paste.
Fry the ball of paste in oil until the herbs and spices are loosened up and become a thin, oily paste. Let it get hot, then reduce the flame and fry slowly for about 5 minutes to soften all of the bits of chili, etc.
Add in the fish sauce, water, and sugar. Stir it up, let it get hot again, then cook slowly until the sugar all melts. Continue stirring so it doesn't burn, keeping the flame low so it's just bubbling a little.
After the sugar is all melted, let it cook slowly for about another couple of minutes. Then remove from the heat and let it cool. The paste should be thin and oily, and the oil will be sitting on top.